From aa739a70b7ac9f20a4a4e52f6cc1c8dfdd40954b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 12 Aug 2018 16:14:34 +0200 Subject: [PATCH 1/2] many things --- .../{SwimmingFish.anim => Fish.anim} | 32 ++--- ...{SwimmingFish.anim.meta => Fish.anim.meta} | 2 +- Assets/Animations/Fish.controller | 60 +--------- Assets/Prefabs/Fish Spawner.prefab | 8 +- Assets/Prefabs/Fish.prefab | 66 ++++++++++- Assets/Prefabs/Sea.prefab | 112 +++++++++--------- Assets/Prefabs/Ship.prefab | 6 +- Assets/Scenes/Game.unity | 60 +++++++++- Assets/Scripts/Cannon.cs | 4 +- Assets/Scripts/FishAi.cs | 43 +++++++ Assets/Scripts/FishAi.cs.meta | 11 ++ Assets/Scripts/FishCatcher.cs | 17 +++ Assets/Scripts/FishCatcher.cs.meta | 11 ++ Assets/Scripts/FishSpawner.cs | 5 +- Assets/Scripts/Harpoon.cs | 13 +- Assets/Scripts/PlayerMovement.cs | 15 ++- Assets/Sprites/Fish1.png.meta | 2 +- Assets/Sprites/Fish2.png.meta | 2 +- Assets/Sprites/mirino.png.meta | 88 ++++++++++++++ 19 files changed, 389 insertions(+), 168 deletions(-) rename Assets/Animations/{SwimmingFish.anim => Fish.anim} (61%) rename Assets/Animations/{SwimmingFish.anim.meta => Fish.anim.meta} (79%) create mode 100644 Assets/Scripts/FishAi.cs create mode 100644 Assets/Scripts/FishAi.cs.meta create mode 100644 Assets/Scripts/FishCatcher.cs create mode 100644 Assets/Scripts/FishCatcher.cs.meta create mode 100644 Assets/Sprites/mirino.png.meta diff --git a/Assets/Animations/SwimmingFish.anim b/Assets/Animations/Fish.anim similarity index 61% rename from Assets/Animations/SwimmingFish.anim rename to Assets/Animations/Fish.anim index c55b933..aad3bc8 100644 --- a/Assets/Animations/SwimmingFish.anim +++ b/Assets/Animations/Fish.anim @@ -5,7 +5,7 @@ AnimationClip: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInternal: {fileID: 0} - m_Name: SwimmingFish + m_Name: Fish serializedVersion: 6 m_Legacy: 0 m_Compressed: 0 @@ -16,44 +16,26 @@ AnimationClip: m_PositionCurves: [] m_ScaleCurves: [] m_FloatCurves: [] - m_PPtrCurves: - - curve: - - time: 0 - value: {fileID: 21300000, guid: 13b9b471ab4f9bf4b9fbf69db9962f28, type: 3} - - time: 0.25 - value: {fileID: 21300000, guid: 13b9b471ab4f9bf4b9fbf69db9962f28, type: 3} - attribute: m_Sprite - path: - classID: 212 - script: {fileID: 0} - m_SampleRate: 4 + m_PPtrCurves: [] + m_SampleRate: 60 m_WrapMode: 0 m_Bounds: m_Center: {x: 0, y: 0, z: 0} m_Extent: {x: 0, y: 0, z: 0} m_ClipBindingConstant: - genericBindings: - - serializedVersion: 2 - path: 0 - attribute: 0 - script: {fileID: 0} - typeID: 212 - customType: 23 - isPPtrCurve: 1 - pptrCurveMapping: - - {fileID: 21300000, guid: 13b9b471ab4f9bf4b9fbf69db9962f28, type: 3} - - {fileID: 21300000, guid: 13b9b471ab4f9bf4b9fbf69db9962f28, type: 3} + genericBindings: [] + pptrCurveMapping: [] m_AnimationClipSettings: serializedVersion: 2 m_AdditiveReferencePoseClip: {fileID: 0} m_AdditiveReferencePoseTime: 0 m_StartTime: 0 - m_StopTime: 0.5 + m_StopTime: 1 m_OrientationOffsetY: 0 m_Level: 0 m_CycleOffset: 0 m_HasAdditiveReferencePose: 0 - m_LoopTime: 0 + m_LoopTime: 1 m_LoopBlend: 0 m_LoopBlendOrientation: 0 m_LoopBlendPositionY: 0 diff --git a/Assets/Animations/SwimmingFish.anim.meta b/Assets/Animations/Fish.anim.meta similarity index 79% rename from Assets/Animations/SwimmingFish.anim.meta rename to Assets/Animations/Fish.anim.meta index 22d5976..854593a 100644 --- a/Assets/Animations/SwimmingFish.anim.meta +++ b/Assets/Animations/Fish.anim.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 69bbcb7123e43354aa536335d9a6ce4b +guid: e205bc343f188294b9b6d0b3237935f4 NativeFormatImporter: externalObjects: {} mainObjectFileID: 7400000 diff --git a/Assets/Animations/Fish.controller b/Assets/Animations/Fish.controller index 0d2a1b6..8cf6cb1 100644 --- a/Assets/Animations/Fish.controller +++ b/Assets/Animations/Fish.controller @@ -8,62 +8,4 @@ AnimatorController: m_Name: Fish serializedVersion: 5 m_AnimatorParameters: [] - m_AnimatorLayers: - - serializedVersion: 5 - m_Name: Base Layer - m_StateMachine: {fileID: 1107146383291903174} - m_Mask: {fileID: 0} - m_Motions: [] - m_Behaviours: [] - m_BlendingMode: 0 - m_SyncedLayerIndex: -1 - m_DefaultWeight: 0 - m_IKPass: 0 - m_SyncedLayerAffectsTiming: 0 - m_Controller: {fileID: 9100000} ---- !u!1102 &1102471393210197512 -AnimatorState: - serializedVersion: 5 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: SwimmingFish - m_Speed: 1 - m_CycleOffset: 0 - m_Transitions: [] - m_StateMachineBehaviours: [] - m_Position: {x: 50, y: 50, z: 0} - m_IKOnFeet: 0 - m_WriteDefaultValues: 1 - m_Mirror: 0 - m_SpeedParameterActive: 0 - m_MirrorParameterActive: 0 - m_CycleOffsetParameterActive: 0 - m_TimeParameterActive: 0 - m_Motion: {fileID: 7400000, guid: 69bbcb7123e43354aa536335d9a6ce4b, type: 2} - m_Tag: - m_SpeedParameter: - m_MirrorParameter: - m_CycleOffsetParameter: - m_TimeParameter: ---- !u!1107 &1107146383291903174 -AnimatorStateMachine: - serializedVersion: 5 - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_Name: Base Layer - m_ChildStates: - - serializedVersion: 1 - m_State: {fileID: 1102471393210197512} - m_Position: {x: 240, y: 120, z: 0} - m_ChildStateMachines: [] - m_AnyStateTransitions: [] - m_EntryTransitions: [] - m_StateMachineTransitions: {} - m_StateMachineBehaviours: [] - m_AnyStatePosition: {x: 48, y: 36, z: 0} - m_EntryPosition: {x: 50, y: 120, z: 0} - m_ExitPosition: {x: 800, y: 120, z: 0} - m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} - m_DefaultState: {fileID: 1102471393210197512} + m_AnimatorLayers: [] diff --git a/Assets/Prefabs/Fish Spawner.prefab b/Assets/Prefabs/Fish Spawner.prefab index 04ff0fd..1bdaa32 100644 --- a/Assets/Prefabs/Fish Spawner.prefab +++ b/Assets/Prefabs/Fish Spawner.prefab @@ -34,7 +34,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1634593922401586} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 4.136495, y: 33.203545, z: 1.2109375} + m_LocalPosition: {x: 10.24, y: 27.43, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -51,7 +51,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 638828a10228a7c4abdc105ea02613b1, type: 3} m_Name: m_EditorClassIdentifier: - spawnTime: 5 - randomFactor: 1 + spawnTime: 1 + randomFactor: 0.2 fish: {fileID: 1615301965237016, guid: 3b07c51a898a8e342b3d0236ca47bf8c, type: 2} - sea: {fileID: 1259758189242624, guid: 4dc0408b236da9847b1c799161bbd70a, type: 2} + sea: {fileID: 0} diff --git a/Assets/Prefabs/Fish.prefab b/Assets/Prefabs/Fish.prefab index 0b5e5d0..233e15a 100644 --- a/Assets/Prefabs/Fish.prefab +++ b/Assets/Prefabs/Fish.prefab @@ -21,9 +21,12 @@ GameObject: - component: {fileID: 4139569998151354} - component: {fileID: 95068346191508518} - component: {fileID: 212894136892818758} + - component: {fileID: 114516106445027332} + - component: {fileID: 61996603152329194} + - component: {fileID: 50027558808981732} m_Layer: 0 m_Name: Fish - m_TagString: Untagged + m_TagString: Fish m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -35,12 +38,57 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1615301965237016} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -12.660833, y: 34.92962, z: 0} + m_LocalPosition: {x: 6.22, y: 28.15, z: 0} 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} +--- !u!50 &50027558808981732 +Rigidbody2D: + serializedVersion: 4 + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1615301965237016} + m_BodyType: 1 + m_Simulated: 1 + m_UseFullKinematicContacts: 0 + m_UseAutoMass: 0 + m_Mass: 1 + m_LinearDrag: 0 + m_AngularDrag: 0.05 + m_GravityScale: 1 + m_Material: {fileID: 0} + m_Interpolate: 0 + m_SleepingMode: 1 + m_CollisionDetection: 0 + m_Constraints: 4 +--- !u!61 &61996603152329194 +BoxCollider2D: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1615301965237016} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0.5, y: 0.5} + oldSize: {x: 1.24, y: 0.76} + newSize: {x: 0.62, y: 0.38} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 0.62, y: 0.38} + m_EdgeRadius: 0 --- !u!95 &95068346191508518 Animator: serializedVersion: 3 @@ -59,6 +107,20 @@ Animator: m_HasTransformHierarchy: 1 m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorControllerStateOnDisable: 0 +--- !u!114 &114516106445027332 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1615301965237016} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2c046701cf583b1428cb53ed88c691a1, type: 3} + m_Name: + m_EditorClassIdentifier: + timeBetweenDirectionChanges: 2 + speed: 1 + hook: {fileID: 0} --- !u!212 &212894136892818758 SpriteRenderer: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/Sea.prefab b/Assets/Prefabs/Sea.prefab index 171ffb8..2a2b0d9 100644 --- a/Assets/Prefabs/Sea.prefab +++ b/Assets/Prefabs/Sea.prefab @@ -958,7 +958,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1597028553753178} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 10, y: 35.26, z: 0} + m_LocalPosition: {x: 10, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1023,7 +1023,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1816039587878708} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 35.26, z: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1036,7 +1036,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1728521623291448} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -30, y: 35.26, z: 0} + m_LocalPosition: {x: -30, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1075,7 +1075,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1133676115079054} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 3.1, z: 1.42} + m_LocalPosition: {x: 0, y: -34, z: 1.42} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4061723996323132} @@ -1131,7 +1131,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1461408773294766} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 30, y: 35.26, z: 0} + m_LocalPosition: {x: 30, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1183,7 +1183,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1196428276860490} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 20, y: 35.26, z: 0} + m_LocalPosition: {x: 20, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1274,7 +1274,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1787534442348596} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -10, y: 35.26, z: 0} + m_LocalPosition: {x: -10, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1326,7 +1326,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1278689706069394} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 40, y: 35.26, z: 0} + m_LocalPosition: {x: 40, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1339,7 +1339,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1343260386786534} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -40, y: 35.26, z: 0} + m_LocalPosition: {x: -40, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1404,7 +1404,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1443341134688224} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -50, y: 35.26, z: 0} + m_LocalPosition: {x: -50, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1482,7 +1482,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1259758189242624} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 0, y: 35.26, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 4074214023049084} @@ -1546,7 +1546,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1818792272378828} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 50, y: 35.26, z: 0} + m_LocalPosition: {x: 50, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1626,7 +1626,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1914466178929030} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -20, y: 35.26, z: 0} + m_LocalPosition: {x: -20, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 4672609510335210} @@ -1821,7 +1821,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -1867,7 +1867,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -1959,7 +1959,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2005,7 +2005,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2051,7 +2051,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2097,7 +2097,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: 8d9728b3f1e7dbb44957bf4aecd4a8df, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2143,7 +2143,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2189,7 +2189,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2235,7 +2235,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2281,7 +2281,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2327,7 +2327,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2373,7 +2373,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2419,7 +2419,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2511,7 +2511,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2557,7 +2557,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2603,7 +2603,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2695,7 +2695,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2741,7 +2741,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2787,7 +2787,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2833,7 +2833,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2879,7 +2879,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -2971,7 +2971,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3063,7 +3063,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3109,7 +3109,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3155,7 +3155,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3201,7 +3201,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3293,7 +3293,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3339,7 +3339,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3385,7 +3385,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3431,7 +3431,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3477,7 +3477,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3523,7 +3523,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3569,7 +3569,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3615,7 +3615,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3661,7 +3661,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3707,7 +3707,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3753,7 +3753,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3799,7 +3799,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3845,7 +3845,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -3937,7 +3937,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -4029,7 +4029,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -4075,7 +4075,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -4213,7 +4213,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: -1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: a15b7468ef7ee074198a85ff5d2bd3ae, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 diff --git a/Assets/Prefabs/Ship.prefab b/Assets/Prefabs/Ship.prefab index 31bc26f..2cc167e 100644 --- a/Assets/Prefabs/Ship.prefab +++ b/Assets/Prefabs/Ship.prefab @@ -40,7 +40,7 @@ GameObject: - component: {fileID: 114893472868460232} m_Layer: 8 m_Name: Ship - m_TagString: Untagged + m_TagString: Player m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -246,7 +246,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: -1570049999 m_SortingLayer: 2 - m_SortingOrder: 1 + m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: bdd08b099cc1c614096f43a9ccf99b59, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 @@ -292,7 +292,7 @@ SpriteRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 0 + m_SortingOrder: 2 m_Sprite: {fileID: 21300000, guid: 1f841006c9147454d8eca3d3cae86c0f, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 953c8a7..0e4ce91 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -150,7 +150,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4978811670595372, guid: 633eed510cb97614896a65613c2eb772, type: 2} propertyPath: m_RootOrder - value: 4 + value: 5 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 633eed510cb97614896a65613c2eb772, type: 2} @@ -192,7 +192,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4059627635461364, guid: acb6270a21e7fa744878210a4df90d27, type: 2} propertyPath: m_RootOrder - value: 2 + value: 3 objectReference: {fileID: 0} - target: {fileID: 114070643257783382, guid: acb6270a21e7fa744878210a4df90d27, type: 2} @@ -239,7 +239,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4023639078503100, guid: 0514a38f22bae454d821a12517a141c4, type: 2} propertyPath: m_RootOrder - value: 3 + value: 4 objectReference: {fileID: 0} - target: {fileID: 60970885189888988, guid: 0514a38f22bae454d821a12517a141c4, type: 2} @@ -306,6 +306,58 @@ Prefab: m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 4dc0408b236da9847b1c799161bbd70a, type: 2} m_IsPrefabAsset: 0 +--- !u!1001 &1076540941 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalPosition.x + value: 3.39 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalPosition.y + value: 28.18 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4955254497044876, guid: 343a89599f7365845937eb14b4669b20, type: 2} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 114324088513504716, guid: 343a89599f7365845937eb14b4669b20, + type: 2} + propertyPath: spawnTime + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 114324088513504716, guid: 343a89599f7365845937eb14b4669b20, + type: 2} + propertyPath: randomFactor + value: 0.2 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 343a89599f7365845937eb14b4669b20, type: 2} + m_IsPrefabAsset: 0 --- !u!1001 &1406564692 Prefab: m_ObjectHideFlags: 0 @@ -343,7 +395,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 4279439219186522, guid: 1cf703958a669d942a42326499701367, type: 2} propertyPath: m_RootOrder - value: 1 + value: 2 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1cf703958a669d942a42326499701367, type: 2} diff --git a/Assets/Scripts/Cannon.cs b/Assets/Scripts/Cannon.cs index c460ddf..3ec94a6 100644 --- a/Assets/Scripts/Cannon.cs +++ b/Assets/Scripts/Cannon.cs @@ -27,11 +27,11 @@ public class Cannon : MonoBehaviour { spriteRenderer.flipX = direction.x < 0; if (harpoonAvailable) { - if (Input.GetKey(KeyCode.Space)) + if (Input.GetMouseButton(0)) { force = Mathf.Clamp(force + forceBuildingSpeed * Time.deltaTime, 0, maxForce); } - if (Input.GetKeyUp(KeyCode.Space)) + if (Input.GetMouseButtonUp(0)) { GameObject harpoonInstance = Instantiate(harpoon); harpoonInstance.transform.position = transform.position + (Vector3)direction.normalized; diff --git a/Assets/Scripts/FishAi.cs b/Assets/Scripts/FishAi.cs new file mode 100644 index 0000000..cdbe3e6 --- /dev/null +++ b/Assets/Scripts/FishAi.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FishAi : MonoBehaviour { + + public float timeBetweenDirectionChanges = 1f; + public float speed = 2f; + public GameObject hook = null; + public GameObject sea; + private Vector3 direction; + private Rigidbody2D rigidbody2D; + + void Start () { + rigidbody2D = GetComponent(); + InvokeRepeating("ChangeDirection", 0, timeBetweenDirectionChanges); + } + + void ChangeDirection() + { + direction = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); + } + + void Update () { + if (hook == null) + { + if (transform.position.y > sea.transform.position.y) + { + direction = new Vector3(Random.Range(-1f, 1f), Random.Range(-4f, -2f)); + } + rigidbody2D.MovePosition(transform.position + direction * Time.deltaTime * speed); + } + else + { + rigidbody2D.MovePosition(hook.transform.position); + } + } + + void OnCollisionEnter2D(Collision2D collision) + { + ChangeDirection(); + } +} diff --git a/Assets/Scripts/FishAi.cs.meta b/Assets/Scripts/FishAi.cs.meta new file mode 100644 index 0000000..5fcea0a --- /dev/null +++ b/Assets/Scripts/FishAi.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2c046701cf583b1428cb53ed88c691a1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FishCatcher.cs b/Assets/Scripts/FishCatcher.cs new file mode 100644 index 0000000..8b22abc --- /dev/null +++ b/Assets/Scripts/FishCatcher.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FishCatcher : MonoBehaviour { + + public int fishCaught = 0; + + private void OnCollisionEnter2D(Collision2D collision) + { + if(collision.gameObject.tag == "Fish") + { + fishCaught++; + Destroy(collision.gameObject); + } + } +} diff --git a/Assets/Scripts/FishCatcher.cs.meta b/Assets/Scripts/FishCatcher.cs.meta new file mode 100644 index 0000000..5f92c8f --- /dev/null +++ b/Assets/Scripts/FishCatcher.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1de68aef1b6a89419a36f3455e25bf3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/FishSpawner.cs b/Assets/Scripts/FishSpawner.cs index eae8c66..2823d03 100644 --- a/Assets/Scripts/FishSpawner.cs +++ b/Assets/Scripts/FishSpawner.cs @@ -4,8 +4,8 @@ using UnityEngine; public class FishSpawner : MonoBehaviour { - public float spawnTime = 5; - public float randomFactor = 1; + public float spawnTime = 5f; + public float randomFactor = 1f; public GameObject fish; public GameObject sea; private float timeToSpawn; @@ -20,6 +20,7 @@ public class FishSpawner : MonoBehaviour { { GameObject newFish = Instantiate(fish); newFish.transform.position = transform.position; + newFish.GetComponent().sea = sea; timeToSpawn = Random.Range(spawnTime - randomFactor, spawnTime + randomFactor); } if(transform.position.y > sea.transform.position.y) diff --git a/Assets/Scripts/Harpoon.cs b/Assets/Scripts/Harpoon.cs index 887390a..8555fc6 100644 --- a/Assets/Scripts/Harpoon.cs +++ b/Assets/Scripts/Harpoon.cs @@ -14,6 +14,7 @@ public class Harpoon : MonoBehaviour { { rigidbody2D = GetComponent(); linker = GetComponentInChildren(); + rigidbody2D.useFullKinematicContacts = true; } void Update () @@ -45,7 +46,15 @@ public class Harpoon : MonoBehaviour { void OnCollisionEnter2D(Collision2D collision) { - going = false; - rigidbody2D.bodyType = RigidbodyType2D.Kinematic; + if (going) + { + going = false; + rigidbody2D.bodyType = RigidbodyType2D.Kinematic; + } + if (collision.gameObject.tag == "Fish") + { + collision.gameObject.GetComponent().hook = gameObject; + } + } } diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index 071e9ec..b7bd480 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -18,22 +18,25 @@ public class PlayerMovement : MonoBehaviour { } void FixedUpdate () { - if (Input.GetKey(KeyCode.LeftArrow)) + if (Input.GetAxis("Horizontal") < 0) { hull.transform.localScale = new Vector3(-1, 1, 1); rb.AddForce(Vector2.right * -horizontalShipSpeed); } - if (Input.GetKey(KeyCode.RightArrow)) + if (Input.GetAxis("Horizontal") > 0) { hull.transform.localScale = new Vector3(1, 1, 1); rb.AddForce(Vector2.right * horizontalShipSpeed); } - if (Input.GetKey(KeyCode.UpArrow) && jetFuel > 0f) + if (Input.GetAxis("Vertical") > 0) { - jetFuel = Mathf.Clamp(jetFuel - Time.deltaTime, 0, maxJetFuel); - rb.AddForce(Vector2.up * verticalShipSpeed); + if (jetFuel > 0f) + { + jetFuel = Mathf.Clamp(jetFuel - Time.deltaTime, 0, maxJetFuel); + rb.AddForce(Vector2.up * verticalShipSpeed); + } } - else if(!Input.GetKey(KeyCode.UpArrow)) + else { jetFuel = Mathf.Clamp(jetFuel + Time.deltaTime, 0, maxJetFuel); } diff --git a/Assets/Sprites/Fish1.png.meta b/Assets/Sprites/Fish1.png.meta index b0aeda1..c95d792 100644 --- a/Assets/Sprites/Fish1.png.meta +++ b/Assets/Sprites/Fish1.png.meta @@ -45,7 +45,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 50 + spritePixelsToUnits: 25 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 diff --git a/Assets/Sprites/Fish2.png.meta b/Assets/Sprites/Fish2.png.meta index 5efff85..76a618b 100644 --- a/Assets/Sprites/Fish2.png.meta +++ b/Assets/Sprites/Fish2.png.meta @@ -45,7 +45,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 50 + spritePixelsToUnits: 25 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 diff --git a/Assets/Sprites/mirino.png.meta b/Assets/Sprites/mirino.png.meta new file mode 100644 index 0000000..29d9d7e --- /dev/null +++ b/Assets/Sprites/mirino.png.meta @@ -0,0 +1,88 @@ +fileFormatVersion: 2 +guid: ca8179fb7cd0e2740858e904b954a35e +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 7 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: d774cb8508187cc47a8fc57a1e27d404 + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: From 69a2bcc6f09d23e990efa862c59e7f8e36cb44cc Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 12 Aug 2018 16:22:09 +0200 Subject: [PATCH 2/2] asd --- Assets/Prefabs/Fish Spawner.prefab | 2 +- Assets/Prefabs/Terrain.prefab | 4 ++-- Assets/Scripts/Cannon.cs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Assets/Prefabs/Fish Spawner.prefab b/Assets/Prefabs/Fish Spawner.prefab index 1bdaa32..1795556 100644 --- a/Assets/Prefabs/Fish Spawner.prefab +++ b/Assets/Prefabs/Fish Spawner.prefab @@ -34,7 +34,7 @@ Transform: m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1634593922401586} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 10.24, y: 27.43, z: 0} + m_LocalPosition: {x: 3.39, y: 28.18, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} diff --git a/Assets/Prefabs/Terrain.prefab b/Assets/Prefabs/Terrain.prefab index 501087d..a995e9c 100644 --- a/Assets/Prefabs/Terrain.prefab +++ b/Assets/Prefabs/Terrain.prefab @@ -362,8 +362,8 @@ SpriteRenderer: m_AutoUVMaxDistance: 0.5 m_AutoUVMaxAngle: 89 m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 + m_SortingLayerID: -1570049999 + m_SortingLayer: 2 m_SortingOrder: 0 m_Sprite: {fileID: 21300000, guid: 3504427cef78c5a4ea13eadb8bac91a5, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Scripts/Cannon.cs b/Assets/Scripts/Cannon.cs index 3ec94a6..0be9c90 100644 --- a/Assets/Scripts/Cannon.cs +++ b/Assets/Scripts/Cannon.cs @@ -21,12 +21,12 @@ public class Cannon : MonoBehaviour { private void Update () { - Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position); - Vector2 direction = (Vector2)Input.mousePosition - screenPosition; - transform.rotation = Quaternion.LookRotation(Vector3.forward, direction); - spriteRenderer.flipX = direction.x < 0; if (harpoonAvailable) { + Vector2 screenPosition = Camera.main.WorldToScreenPoint(transform.position); + Vector2 direction = (Vector2)Input.mousePosition - screenPosition; + transform.rotation = Quaternion.LookRotation(Vector3.forward, direction); + spriteRenderer.flipX = direction.x < 0; if (Input.GetMouseButton(0)) { force = Mathf.Clamp(force + forceBuildingSpeed * Time.deltaTime, 0, maxForce);