Commit 36fd7e99 authored by Parsa Rahmaty's avatar Parsa Rahmaty

The direction of the cannonballs is fixed

parent 94759b2c
......@@ -14,6 +14,7 @@ GameObject:
- component: {fileID: 400804237596747917}
- component: {fileID: 5560186350293350528}
- component: {fileID: 1317944747836374153}
- component: {fileID: 5687028221148072821}
m_Layer: 8
m_Name: Cannonball
m_TagString: Cannonball
......@@ -124,3 +125,15 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
speed: 30
--- !u!114 &5687028221148072821
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3972782314967972539}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3cf5829d03eb97459c57901b7efff3d, type: 3}
m_Name:
m_EditorClassIdentifier:
......@@ -25,7 +25,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2984237215047306181}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: -1.5, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
......
......@@ -32,7 +32,7 @@ Transform:
m_GameObject: {fileID: 8953703217792660207}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 10, y: 0.25, z: 10}
m_LocalScale: {x: 10, y: 0.5, z: 10}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
......@@ -98,6 +98,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
rotationSpeed: 20
descendTime: 0.2
nodeHeight: 1
--- !u!114 &5704020906800342289
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -136,7 +137,7 @@ BoxCollider:
m_GameObject: {fileID: 8953703217792660207}
m_Material: {fileID: 13400000, guid: 767de626f0734e747b948a518e3e7918, type: 2}
m_IsTrigger: 0
m_Enabled: 1
m_Enabled: 0
serializedVersion: 2
m_Size: {x: 1.0000001, y: 2, z: 1.0000002}
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697}
......
......@@ -149,7 +149,7 @@ Transform:
m_GameObject: {fileID: 58095958}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -2, z: 15}
m_LocalScale: {x: 30, y: 0.25, z: 30}
m_LocalScale: {x: 25, y: 0.25, z: 25}
m_Children: []
m_Father: {fileID: 768744113}
m_RootOrder: 0
......@@ -214,6 +214,37 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 58095958}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &135398378
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 135398379}
m_Layer: 0
m_Name: Cannon Holder
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &135398379
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 135398378}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1827272339}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &446428163 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2984237215047306180, guid: 90b16e9d09448504aa823b8ca0032ddf,
......@@ -518,7 +549,7 @@ Transform:
m_LocalScale: {x: 1, y: 0.5, z: 1}
m_Children: []
m_Father: {fileID: 1827272339}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!136 &1384577412
CapsuleCollider:
......@@ -612,7 +643,7 @@ Transform:
m_LocalScale: {x: 2, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1827272339}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &1389915129
BoxCollider:
......@@ -674,6 +705,36 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1389915127}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1414855918
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1414855919}
m_Layer: 0
m_Name: Shooting Target
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1414855919
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1414855918}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1827272339}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1827272338
GameObject:
m_ObjectHideFlags: 0
......@@ -686,7 +747,7 @@ GameObject:
- component: {fileID: 1827272340}
m_Layer: 0
m_Name: Cannon
m_TagString: Player
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
......@@ -702,10 +763,11 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1414855919}
- {fileID: 1389915128}
- {fileID: 1384577411}
m_Father: {fileID: 0}
m_RootOrder: 3
m_Father: {fileID: 135398379}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1827272340
MonoBehaviour:
......@@ -929,21 +991,6 @@ PrefabInstance:
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2984237215047306180, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2984237215047306180, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2984237215047306180, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2984237215047306180, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: m_LocalRotation.x
......@@ -984,6 +1031,11 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2984237215047306180, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: m_LocalPosition.y
value: -1.25
objectReference: {fileID: 0}
- target: {fileID: 2984237215047306181, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: m_Name
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 0
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 512
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 256
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 1
m_PVRDenoiserTypeDirect: 1
m_PVRDenoiserTypeIndirect: 1
m_PVRDenoiserTypeAO: 1
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &730895943
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 730895948}
- component: {fileID: 730895947}
- component: {fileID: 730895946}
- component: {fileID: 730895945}
- component: {fileID: 730895944}
m_Layer: 0
m_Name: Cylinder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &730895944
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730895943}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c2e4942c58c31a74397411e2abd06b67, type: 3}
m_Name:
m_EditorClassIdentifier:
isStatic: 0
DeformAxis: 1
Refinecurve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
Multiplier: 1
UseEffector: 0
Effector: {fileID: 0}
--- !u!136 &730895945
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730895943}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5000001
m_Height: 2
m_Direction: 1
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697}
--- !u!23 &730895946
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730895943}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &730895947
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730895943}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &730895948
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 730895943}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 9.761752, y: -6.2907095, z: 10.503202}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1731287385
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1731287387}
- component: {fileID: 1731287386}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!108 &1731287386
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1731287385}
m_Enabled: 1
serializedVersion: 10
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_CullingMatrixOverride:
e00: 1
e01: 0
e02: 0
e03: 0
e10: 0
e11: 1
e12: 0
e13: 0
e20: 0
e21: 0
e22: 1
e23: 0
e30: 0
e31: 0
e32: 0
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingLayerMask: 1
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1731287387
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1731287385}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 3, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1889553401
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1889553404}
- component: {fileID: 1889553403}
- component: {fileID: 1889553402}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1889553402
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1889553401}
m_Enabled: 1
--- !u!20 &1889553403
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1889553401}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1889553404
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1889553401}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
fileFormatVersion: 2
guid: 128561e13f43bd346a528566cbe5223d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -4,10 +4,27 @@ using UnityEngine;
public class Movable : MonoBehaviour
{
// Destination-based movement fields
private Vector3 startPosition;
public Vector3 targetPosition { get; private set; }
private float time;
private float timeToReachTarget;
//=====================================================
// Direction-based movement fields
private Vector3 direction;
private float speed;
private bool isOnWorldSpace;
//=====================================================
enum Mode
{
Destination,
Direction,
Neutral
}
private Mode mode = Mode.Neutral;
void Start()
{
......@@ -16,8 +33,15 @@ public class Movable : MonoBehaviour
void Update()
{
time += Time.deltaTime / timeToReachTarget;
transform.position = Vector3.Lerp(startPosition, targetPosition, time);
if (mode == Mode.Destination)
{
time += Time.deltaTime / timeToReachTarget;
transform.position = Vector3.Lerp(startPosition, targetPosition, time);
}
else if(mode == Mode.Direction)
{
transform.Translate(Vector3.Normalize(direction) * speed * Time.deltaTime, (isOnWorldSpace ? Space.World : Space.Self));
}
}
public void SetDestination(Vector3 destination, float time)
......@@ -26,5 +50,14 @@ public class Movable : MonoBehaviour
startPosition = transform.position;
timeToReachTarget = time;
targetPosition = destination;
mode = Mode.Destination;
}
public void SetDirection(Vector3 direction, float speed, bool isOnWorldSpace)
{
this.direction = direction;
this.speed = speed;
this.isOnWorldSpace = isOnWorldSpace;
mode = Mode.Direction;
}
}
......@@ -8,7 +8,7 @@ public class CannonControls : MonoBehaviour
[SerializeField] private float shootingDelay = 0.2f;
[SerializeField] private Collider[] cannonColliders = null;
private float delay;
private float framesLeftToShoot = 0f; // the number of frames passed since last shot
private float timeLeftToShoot = 0f; // the amount of time passed since last shot
void Start()
{
......@@ -19,28 +19,28 @@ public class CannonControls : MonoBehaviour
{
if(Input.GetKey(KeyCode.Space))
{
if (framesLeftToShoot <= 0f)
if (timeLeftToShoot <= 0f)
{
// start shooting cannonballs
GameObject childObject = Instantiate(projectile) as GameObject;
foreach (Collider collider in cannonColliders)
Physics.IgnoreCollision(childObject.GetComponent<SphereCollider>(), collider, true);
Physics.IgnoreCollision(childObject.GetComponent<Collider>(), collider, true);
childObject.transform.parent = gameObject.transform;
childObject.transform.localPosition = new Vector3(0, 0, 0);
childObject.transform.LookAt(GameObject.Find("Shooting Target").transform);
if(delay > (shootingDelay * 1f) / 2f)
delay *= 0.95f;
framesLeftToShoot = delay;
timeLeftToShoot = delay;
}
else
{
framesLeftToShoot -= Time.deltaTime;
timeLeftToShoot -= Time.deltaTime;
}
}
if (Input.GetKeyUp(KeyCode.Space))
{
delay = shootingDelay;
framesLeftToShoot = 0f;
timeLeftToShoot = 0f;
}
}
}
......@@ -4,13 +4,11 @@ using UnityEngine;
public class Cannonball : MonoBehaviour
{
public int speed = 10;
private new Rigidbody rigidbody;
public float speed = 10f;
void Awake()
{
rigidbody = GetComponent<Rigidbody>();
rigidbody.velocity = new Vector3(0, 0, speed);
GetComponent<Movable>().SetDirection(Vector3.forward, speed, false);
Destroy(this.gameObject, 1f);
}
......
......@@ -8,24 +8,23 @@ public class NodeHolder : MonoBehaviour
[SerializeField] private DestroyableObject stackNodeObject = null;
void Awake()
{
nodes = new LinkedList<DestroyableObject>();
}
public void MakeNodes(int numberOfNodes)
{
for(int i = 0; i < nodes.Count; i++)
if(nodes == null)
nodes = new LinkedList<DestroyableObject>();
for (int i = 0; i < nodes.Count; i++)
{
nodes.First.Value.Kill();
nodes.RemoveFirst();
}
// The linked list is now empty
float nodeHeight = stackNodeObject.gameObject.GetComponent<StackNode>().GetNodeHeight();
for(int i = 0; i < numberOfNodes; i++)
{
DestroyableObject node = Instantiate(stackNodeObject);
node.transform.parent = gameObject.transform;
node.transform.localPosition = new Vector3(0f, i * 0.5f, 0f);
//if(nodeHeight == 0f) nodeHeight = node.gameObject.GetComponent<StackNode>()
node.transform.localPosition = new Vector3(0f, i * nodeHeight, 0f);
nodes.AddLast(node);
}
}
......
......@@ -6,8 +6,8 @@ public class StackNode : MonoBehaviour
{
[SerializeField] private float rotationSpeed = 10f;
[SerializeField] private float descendTime = 0.2f;
[SerializeField] private float nodeHeight = 1f;
private float descendDistance = 0.5f;
private Movable movable;
private void Awake()
......@@ -25,13 +25,18 @@ public class StackNode : MonoBehaviour
transform.localEulerAngles += new Vector3(0f, rotationSpeed * Time.fixedDeltaTime, 0f);
}
private void Descend()
private void OnDestroy()
{
movable.SetDestination(movable.targetPosition - new Vector3(0f, descendDistance, 0f), descendTime);
GameEvents.instance.onHitEvent -= Descend;
}
private void OnDestroy()
public float GetNodeHeight()
{
GameEvents.instance.onHitEvent -= Descend;
return nodeHeight;
}
private void Descend()
{
movable.SetDestination(movable.targetPosition - new Vector3(0f, nodeHeight, 0f), descendTime);
}
}
......@@ -3,7 +3,7 @@
--- !u!55 &1
PhysicsManager:
m_ObjectHideFlags: 0
serializedVersion: 13
serializedVersion: 11
m_Gravity: {x: 0, y: -9.81, z: 0}
m_DefaultMaterial: {fileID: 0}
m_BounceThreshold: 2
......@@ -17,12 +17,11 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8fffffff6fffffff2fffffff9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 0
m_ReuseCollisionCallbacks: 1
m_ClothInterCollisionSettingsToggle: 0
m_ClothGravity: {x: 0, y: -9.81, z: 0}
m_ContactPairsMode: 0
m_BroadphaseType: 0
m_WorldBounds:
......@@ -32,5 +31,4 @@ PhysicsManager:
m_FrictionType: 0
m_EnableEnhancedDeterminism: 0
m_EnableUnifiedHeightmaps: 1
m_SolverType: 0
m_DefaultMaxAngularSpeed: 7
m_DefaultMaxAngluarSpeed: 7
......@@ -4,7 +4,7 @@
PlayerSettings:
m_ObjectHideFlags: 0
serializedVersion: 20
productGUID: 21d8bd3464428934ba031177685f86ed
productGUID: 21a5c9b0a93b4a1459fa4214094e8009
AndroidProfiler: 0
AndroidFilterTouchesWhenObscured: 0
AndroidEnableSustainedPerformanceMode: 0
......@@ -13,7 +13,7 @@ PlayerSettings:
useOnDemandResources: 0
accelerometerFrequency: 60
companyName: DefaultCompany
productName: FireballsClone
productName: NewFireballsClone
defaultCursor: {fileID: 0}
cursorHotspot: {x: 0, y: 0}
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
......
......@@ -3,8 +3,7 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags:
- Cannonball
tags: []
layers:
- Default
- TransparentFX
......@@ -14,10 +13,10 @@ TagManager:
- UI
-
-
- Cannonball
- Stack Node
- Ground
- Stack
-
-
-
-
-
-
-
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment