diff --git a/Assets/Prefabs/Network Prefabs/GamePlayer.prefab b/Assets/Prefabs/Network Prefabs/GamePlayer.prefab index d6440d5..df7b6fd 100644 --- a/Assets/Prefabs/Network Prefabs/GamePlayer.prefab +++ b/Assets/Prefabs/Network Prefabs/GamePlayer.prefab @@ -118,30 +118,43 @@ MonoBehaviour: HookKey: 0 DashKey: 0 UltKey: 0 - topLeftDeath: {x: 0, y: 0, z: 0} - bottomRightDeath: {x: 0, y: 0, z: 0} + ChannelKey: 0 + ChannelKey2: 0 speed: 10 airSpeed: 7 jumpForce: 8 smallJump: 4 gravity: -10 wallJump: 8 - wallJumpPush: 15 + wallJumpPush: 12 smallJumpPush: 5 pushSpeed: 0.2 - hookRange: 15 + playerMask: + serializedVersion: 2 + m_Bits: 1024 + velocity: 0 + hookRange: 10 hookObject: {fileID: 1574484083535614, guid: 798642a34216b3c4e84e665614a0979a, type: 2} - playerHookSpeed: 2 + playerHookSpeed: 10 + springForce: Infinity + damperForce: Infinity + ropeSwing: 5 dashSpeed: 15 smallProjectile: {fileID: 1556668439340832, guid: be1300b1777602f448d537a75a9093c3, type: 2} sProjSpeed: 2 - playerMask: - serializedVersion: 2 - m_Bits: 1024 + energy: 0 + channeling: 0 + largeProjectile: {fileID: 1725627401684318, guid: 3bdc9aa7fe5b6c44dbb49a2ea88300f9, + type: 2} + lProjSpeed: 0.75 + swapProjectile: {fileID: 1815375947999032, guid: 7bf1981eaa398fe4cb42878b4cd942cc, + type: 2} + SwapProjSpeed: 2.5 setuped: 0 gameIsRunning: 1 - velocity: 0 + topLeftDeath: {x: 0, y: 0, z: 0} + bottomRightDeath: {x: 0, y: 0, z: 0} --- !u!114 &114186454880906932 MonoBehaviour: m_ObjectHideFlags: 1 diff --git a/Assets/Prefabs/Network Prefabs/LargeProjectile.prefab b/Assets/Prefabs/Network Prefabs/LargeProjectile.prefab new file mode 100644 index 0000000..818cf13 --- /dev/null +++ b/Assets/Prefabs/Network Prefabs/LargeProjectile.prefab @@ -0,0 +1,129 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1725627401684318} + m_IsPrefabParent: 1 +--- !u!1 &1725627401684318 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4269374570917972} + - component: {fileID: 33808281628002466} + - component: {fileID: 135226103936762874} + - component: {fileID: 23676612741559870} + - component: {fileID: 114935634334871114} + - component: {fileID: 54337341636934470} + m_Layer: 0 + m_Name: LargeProjectile + m_TagString: LargeProjectile + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4269374570917972 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1725627401684318} + 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: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23676612741559870 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1725627401684318} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + 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_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + 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 &33808281628002466 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1725627401684318} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!54 &54337341636934470 +Rigidbody: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1725627401684318} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 0 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 120 + m_CollisionDetection: 0 +--- !u!114 &114935634334871114 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1725627401684318} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d455af6e3ed71b546b353798c6dcd1b6, type: 3} + m_Name: + m_EditorClassIdentifier: + sender: {fileID: 0} + pushForce: 2 + defaultForce: 15 + swapLocation: 0 +--- !u!135 &135226103936762874 +SphereCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1725627401684318} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Prefabs/Network Prefabs/LargeProjectile.prefab.meta b/Assets/Prefabs/Network Prefabs/LargeProjectile.prefab.meta new file mode 100644 index 0000000..cd4d0d9 --- /dev/null +++ b/Assets/Prefabs/Network Prefabs/LargeProjectile.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3bdc9aa7fe5b6c44dbb49a2ea88300f9 +timeCreated: 1521650967 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Network Prefabs/LobbyPlayer.prefab b/Assets/Prefabs/Network Prefabs/LobbyPlayer.prefab index 12009f4..6cdf588 100644 --- a/Assets/Prefabs/Network Prefabs/LobbyPlayer.prefab +++ b/Assets/Prefabs/Network Prefabs/LobbyPlayer.prefab @@ -120,8 +120,8 @@ MonoBehaviour: HookKey: 0 DashKey: 0 UltKey: 0 - topLeftDeath: {x: 0, y: 0, z: 0} - bottomRightDeath: {x: 0, y: 0, z: 0} + ChannelKey: 0 + ChannelKey2: 0 speed: 10 airSpeed: 7 jumpForce: 8 @@ -131,23 +131,32 @@ MonoBehaviour: wallJumpPush: 12 smallJumpPush: 5 pushSpeed: 0.2 + playerMask: + serializedVersion: 2 + m_Bits: 1024 + velocity: 0 hookRange: 10 hookObject: {fileID: 1574484083535614, guid: 798642a34216b3c4e84e665614a0979a, type: 2} - playerHookSpeed: 2 + playerHookSpeed: 10 springForce: Infinity damperForce: Infinity - breakForce: 500 ropeSwing: 5 dashSpeed: 15 smallProjectile: {fileID: 1556668439340832, guid: be1300b1777602f448d537a75a9093c3, type: 2} sProjSpeed: 2 - playerMask: - serializedVersion: 2 - m_Bits: 1024 + energy: 0 + channeling: 0 + largeProjectile: {fileID: 1725627401684318, guid: 3bdc9aa7fe5b6c44dbb49a2ea88300f9, + type: 2} + lProjSpeed: 8 + swapProjectile: {fileID: 1815375947999032, guid: 7bf1981eaa398fe4cb42878b4cd942cc, + type: 2} + SwapProjSpeed: 25 setuped: 0 gameIsRunning: 0 - velocity: 0 + topLeftDeath: {x: 0, y: 0, z: 0} + bottomRightDeath: {x: 0, y: 0, z: 0} --- !u!114 &114478164937343286 MonoBehaviour: m_ObjectHideFlags: 1 @@ -220,10 +229,10 @@ SpringJoint: m_Damper: 0 m_MinDistance: 0 m_MaxDistance: 0 - m_Tolerance: 0.025 + m_Tolerance: 1 m_BreakForce: Infinity m_BreakTorque: Infinity - m_EnableCollision: 1 - m_EnablePreprocessing: 1 + m_EnableCollision: 0 + m_EnablePreprocessing: 0 m_MassScale: 0.1 m_ConnectedMassScale: 1 diff --git a/Assets/Prefabs/Network Prefabs/SwapProjectile.prefab b/Assets/Prefabs/Network Prefabs/SwapProjectile.prefab new file mode 100644 index 0000000..925c312 --- /dev/null +++ b/Assets/Prefabs/Network Prefabs/SwapProjectile.prefab @@ -0,0 +1,129 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1815375947999032} + m_IsPrefabParent: 1 +--- !u!1 &1815375947999032 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4541989753578702} + - component: {fileID: 33629666406638166} + - component: {fileID: 135775905570962300} + - component: {fileID: 23568211497049266} + - component: {fileID: 114394692378807160} + - component: {fileID: 54419120968239260} + m_Layer: 0 + m_Name: SwapProjectile + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4541989753578702 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1815375947999032} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 2.04, z: 0} + m_LocalScale: {x: 0.4, y: 0.4, z: 0.4} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23568211497049266 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1815375947999032} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + 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_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + 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 &33629666406638166 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1815375947999032} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!54 &54419120968239260 +Rigidbody: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1815375947999032} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 0 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 120 + m_CollisionDetection: 0 +--- !u!114 &114394692378807160 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1815375947999032} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d455af6e3ed71b546b353798c6dcd1b6, type: 3} + m_Name: + m_EditorClassIdentifier: + sender: {fileID: 0} + pushForce: 0 + defaultForce: 0 + swapLocation: 1 +--- !u!135 &135775905570962300 +SphereCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1815375947999032} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Prefabs/Network Prefabs/SwapProjectile.prefab.meta b/Assets/Prefabs/Network Prefabs/SwapProjectile.prefab.meta new file mode 100644 index 0000000..1868c1b --- /dev/null +++ b/Assets/Prefabs/Network Prefabs/SwapProjectile.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7bf1981eaa398fe4cb42878b4cd942cc +timeCreated: 1521651642 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/MainMenu.unity b/Assets/Scenes/MainMenu.unity index d8a57c2..065aacf 100644 --- a/Assets/Scenes/MainMenu.unity +++ b/Assets/Scenes/MainMenu.unity @@ -288,6 +288,46 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &995613903 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 995613905} + - component: {fileID: 995613904} + m_Layer: 0 + m_Name: MenuManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &995613904 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 995613903} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a89c64d28c0b58141a701cbb5b8ddc6a, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &995613905 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 995613903} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 16.232784, y: -1.8609884, z: 60.94039} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1030271288 GameObject: m_ObjectHideFlags: 0 @@ -502,7 +542,18 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1353665926} m_OnClick: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 995613904} + m_MethodName: PlayClick + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null --- !u!114 &1353665926 diff --git a/Assets/Script/HookType.cs b/Assets/Script/HookType.cs index ce7657a..cc3ab27 100644 --- a/Assets/Script/HookType.cs +++ b/Assets/Script/HookType.cs @@ -4,5 +4,5 @@ Wall = 1, Player = 2, SmallProjectile = 3, - LargeProjectille = 4, + LargeProjectile = 4, } \ No newline at end of file diff --git a/Assets/Script/NetworkManager.cs b/Assets/Script/NetworkManager.cs index a53fe9c..b43fe55 100644 --- a/Assets/Script/NetworkManager.cs +++ b/Assets/Script/NetworkManager.cs @@ -298,6 +298,7 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = KeyCode.LeftShift; pMovement.DashKey = KeyCode.LeftControl; pMovement.UltKey = KeyCode.F; + pMovement.ChannelKey = KeyCode.A; } else { @@ -307,6 +308,8 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP1 + "Button2"); pMovement.DashKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP1 + "Button3"); pMovement.UltKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP1 + "Button1"); + pMovement.ChannelKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP1 + "Button4"); + pMovement.ChannelKey2 = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP1 + "Button5"); } } else if (player == 2) @@ -322,6 +325,7 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = KeyCode.LeftShift; pMovement.DashKey = KeyCode.LeftControl; pMovement.UltKey = KeyCode.F; + pMovement.ChannelKey = KeyCode.A; } else { @@ -332,6 +336,8 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP2 + "Button2"); pMovement.DashKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP2 + "Button3"); pMovement.UltKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP2 + "Button1"); + pMovement.ChannelKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP2 + "Button4"); + pMovement.ChannelKey2 = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP2 + "Button5"); } } else if (player == 3) @@ -347,6 +353,7 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = KeyCode.LeftShift; pMovement.DashKey = KeyCode.LeftControl; pMovement.UltKey = KeyCode.F; + pMovement.ChannelKey = KeyCode.A; } else { @@ -357,6 +364,8 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP3 + "Button2"); pMovement.DashKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP3 + "Button3"); pMovement.UltKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP3 + "Button1"); + pMovement.ChannelKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP3 + "Button4"); + pMovement.ChannelKey2 = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP3 + "Button5"); } } else if (player == 4) @@ -372,6 +381,7 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = KeyCode.LeftShift; pMovement.DashKey = KeyCode.LeftControl; pMovement.UltKey = KeyCode.F; + pMovement.ChannelKey = KeyCode.A; } else { @@ -382,6 +392,8 @@ public class NetworkManager : NetworkLobbyManager pMovement.HookKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP4 + "Button2"); pMovement.DashKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP4 + "Button3"); pMovement.UltKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP4 + "Button1"); + pMovement.ChannelKey = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP4 + "Button4"); + pMovement.ChannelKey2 = (KeyCode)System.Enum.Parse(typeof(KeyCode), "Joystick" + ControllerP4 + "Button5"); } } diff --git a/Assets/Script/PlayerMovement.cs b/Assets/Script/PlayerMovement.cs index 0a19c20..17abefe 100644 --- a/Assets/Script/PlayerMovement.cs +++ b/Assets/Script/PlayerMovement.cs @@ -1,21 +1,24 @@ using UnityEngine; using System.Linq; using System.Collections.Generic; +using System.Collections; [RequireComponent(typeof(Rigidbody))] public class PlayerMovement : MonoBehaviour { + [Header("Keybinds (changed at runtime)")] public string Horizontal; public string Vertical; public KeyCode JumpKey = KeyCode.None; public KeyCode HookKey = KeyCode.None; public KeyCode DashKey = KeyCode.None; public KeyCode UltKey = KeyCode.None; - - public Vector3 topLeftDeath; - public Vector3 bottomRightDeath; + public KeyCode ChannelKey = KeyCode.None; + public KeyCode ChannelKey2 = KeyCode.None; [Space] + [Space] + [Header("Movement settings")] [SerializeField] private int speed = 10; [SerializeField] private int airSpeed = 7; [SerializeField] private int jumpForce = 8; @@ -25,22 +28,34 @@ public class PlayerMovement : MonoBehaviour [SerializeField] private int wallJumpPush = 10; [SerializeField] private int smallJumpPush = 5; [SerializeField] private float pushSpeed = 0.2f; + [SerializeField] private LayerMask playerMask; + private bool groundedLastFrame = false; + private int wallDirection; + private int wallJumpTimer = 0; + private bool wallJumped; + private float jumpDirection; + private MovingElement movingPlateform; + [HideInInspector] public float velocity = 0; [Space] + [Space] + [Header("Hook variables")] [SerializeField] private float hookRange = 10; [SerializeField] private GameObject hookObject; [SerializeField] private float playerHookSpeed = 15; [SerializeField] private float springForce = Mathf.Infinity; [SerializeField] private float damperForce = Mathf.Infinity; - [SerializeField] private float breakForce = 600; [SerializeField] private float ropeSwing = 1; private GameObject hook; private HookType hookType = HookType.Wall; private GameObject objectHooked; private Vector3 hookPosition; private float hookLength; + private Rigidbody rb; [Space] + [Space] + [Header("Dash variables")] [SerializeField] private float dashSpeed = 15; [SerializeField] private GameObject smallProjectile; [SerializeField] private float sProjSpeed = 2; @@ -48,26 +63,28 @@ public class PlayerMovement : MonoBehaviour private float dashTime = 0; private Vector3 dashVelocity; + [Space] + [Space] + [Header("Ult variables")] + [SerializeField] private float energy = 0; + public bool channeling = false; + + [SerializeField] private GameObject largeProjectile; + [SerializeField] private float lProjSpeed = 4; + + [SerializeField] private GameObject swapProjectile; + [SerializeField] private float SwapProjSpeed = 25; + [SerializeField] private float largeDamper = 200; [Space] [Space] - [SerializeField] private LayerMask playerMask; - - [Space] + [Header("Game Information")] public bool setuped = false; [SerializeField] private bool gameIsRunning = false; + public Vector3 topLeftDeath; + public Vector3 bottomRightDeath; - [HideInInspector] public float velocity = 0; - private bool groundedLastFrame = false; - private int wallDirection; - private int wallJumpTimer = 0; - private bool wallJumped; - private float jumpDirection; - - private MovingElement movingPlateform; - - private Rigidbody rb; private void Start() { @@ -76,7 +93,7 @@ public class PlayerMovement : MonoBehaviour private bool IsGrounded() { - if (Mathf.Abs(RelativeVelocity().y) < 0.1f && hookType != HookType.Wall) + if (Mathf.Abs(RelativeVelocity().y) < 0.1f && hookType != HookType.Wall && hookType != HookType.LargeProjectile) { if (groundedLastFrame) { @@ -239,14 +256,21 @@ public class PlayerMovement : MonoBehaviour if(hook != null) hook.GetComponent().SetPosition(0, rb.position); } - //if (hookType == HookType.SmallProjectile) - //{ - // if (objectHooked != null) - // { - // if (hook != null) - // hook.GetComponent().SetPositions(new Vector3[] { rb.position, objectHooked.transform.position }); - // } - //} + else if (hookType == HookType.SmallProjectile && objectHooked != null && hook != null) + { + hook.GetComponent().SetPositions(new Vector3[] { rb.position, objectHooked.transform.position }); + } + else if(hookType == HookType.LargeProjectile) + { + if(objectHooked != null) + { + if(hook != null) + hook.GetComponent().SetPositions(new Vector3[] { rb.position, objectHooked.transform.position }); + + hookPosition = objectHooked.transform.position; + GetComponent().connectedAnchor = hookPosition; + } + } //Handle dash after user pressed the button if (dashTime > 0) @@ -261,7 +285,7 @@ public class PlayerMovement : MonoBehaviour GameObject proj = Instantiate(smallProjectile, rb.position + new Vector3(rb.velocity.x / 10, rb.velocity.y / 5, 0), Quaternion.identity); proj.name = "SmallProjectile"; proj.GetComponent().velocity = new Vector3(dashVelocity.x * sProjSpeed, dashVelocity.y * sProjSpeed, 0); - proj.GetComponent().sender = this; + proj.GetComponent().sender = this; dashVelocity = Vector3.zero; } @@ -272,10 +296,11 @@ public class PlayerMovement : MonoBehaviour { if (dashTime <= 0) { - if (hookType != HookType.Wall) + if (hookType != HookType.Wall && hookType != HookType.LargeProjectile) { //Normal movement - rb.AddForce(new Vector3(horizontalVel * (isPushing ? pushSpeed : 1) * (airControl ? airSpeed : speed) - (rb.velocity.x - velocity), 0, 0), ForceMode.Impulse); + if(!channeling) + rb.AddForce(new Vector3(horizontalVel * (isPushing ? pushSpeed : 1) * (airControl ? airSpeed : speed) - (rb.velocity.x - velocity), 0, 0), ForceMode.Impulse); } else { @@ -286,6 +311,28 @@ public class PlayerMovement : MonoBehaviour } } + //Channel energy + if (channeling) + { + if (!Input.GetKey(ChannelKey) && !Input.GetKey(ChannelKey2)) + { + StartCoroutine(CancelChanneling()); + } + else + { + energy += Time.deltaTime; + energy = Mathf.Clamp(energy, 0, 3); + } + } + else if (Input.GetKey(ChannelKey) || Input.GetKey(ChannelKey2)) + { + channeling = true; + } + + //Cancel player movement and abilities if he is channeling + if (channeling) + return; + //Make user jump if (Input.GetKey(JumpKey) && isGrounded) { @@ -302,7 +349,6 @@ public class PlayerMovement : MonoBehaviour } else rb.velocity = new Vector3(rb.velocity.x, smallJump, rb.velocity.z); - } //Move with the plateform @@ -340,6 +386,7 @@ public class PlayerMovement : MonoBehaviour if(spring != null) { spring.connectedAnchor = new Vector3(0, 0, 0); + spring.connectedBody = null; spring.spring = 0; spring.damper = 0; spring.maxDistance = 0; @@ -368,18 +415,33 @@ public class PlayerMovement : MonoBehaviour } else if(hit.collider.tag == "SmallProjectile") { - //Cancel et boop le projectile - //hookType = HookType.SmallProjectile; - //hook = Instantiate(hookObject, rb.position, Quaternion.identity); - //hook.GetComponent().SetPositions(new Vector3[] { rb.position, hit.point }); - //objectHooked = hit.collider.gameObject; + hookType = HookType.SmallProjectile; + hook = Instantiate(hookObject, rb.position, Quaternion.identity); + hook.GetComponent().SetPositions(new Vector3[] { rb.position, hit.point }); + objectHooked = hit.collider.gameObject; - //SpringJoint spring = GetComponent(); - //spring.spring = springForce; - //spring.damper = damperForce; - //spring.maxDistance = Vector3.Distance(rb.position, hit.point); - //spring.breakForce = breakForce; - //spring.connectedBody = hit.collider.GetComponent(); + SpringJoint spring = GetComponent(); + spring.spring = springForce; + spring.damper = damperForce; + spring.maxDistance = Vector3.Distance(rb.position, hit.point); + spring.connectedBody = hit.collider.GetComponent(); + StartCoroutine(CancelHook()); + } + else if (hit.collider.tag == "LargeProjectile") + { + hookType = HookType.LargeProjectile; + hook = Instantiate(hookObject, rb.position, Quaternion.identity); + hook.GetComponent().SetPositions(new Vector3[] { rb.position, hit.point }); + objectHooked = hit.collider.gameObject; + + SpringJoint spring = GetComponent(); + spring.connectedAnchor = hit.point; + spring.spring = springForce; + spring.damper = largeDamper; + spring.maxDistance = Vector3.Distance(rb.position, hit.point); + + hookPosition = hit.point; + hookLength = Vector3.Distance(rb.position, hit.point); } else { @@ -418,6 +480,62 @@ public class PlayerMovement : MonoBehaviour jumpDirection = movement.x; canDash = false; } + + //Ult + if (Input.GetKeyDown(UltKey)) + { + Vector3 direction = NormaliseMovement(Input.GetAxis(Horizontal), Input.GetAxis(Vertical)); + + if (energy < 1) + { + //Boop + } + else if(energy < 3) + { + //Large projectile + energy -= 1; + + GameObject proj = Instantiate(largeProjectile, rb.position + direction * 4, Quaternion.identity); + proj.name = "LargeProjectile"; + proj.GetComponent().velocity = new Vector3(direction.x * lProjSpeed, direction.y * lProjSpeed, 0); + proj.GetComponent().sender = this; + } + else if(energy == 3) + { + //Swap projectile + energy -= 3; + GameObject proj = Instantiate(swapProjectile, rb.position + direction, Quaternion.identity); + proj.name = "SwapProjectile"; + proj.GetComponent().velocity = new Vector3(direction.x * SwapProjSpeed, direction.y * SwapProjSpeed, 0); + proj.GetComponent().sender = this; + } + } + } + + //Cancel hook on small projectile, if not, the rigidbody crash + private IEnumerator CancelHook() + { + yield return new WaitForSeconds(0.7f); + Destroy(hook); + SpringJoint spring = GetComponent(); + if (spring != null) + { + spring.connectedAnchor = new Vector3(0, 0, 0); + spring.connectedBody = null; + spring.spring = 0; + spring.damper = 0; + spring.maxDistance = 0; + } + hookType = HookType.None; + hookPosition = Vector3.zero; + hookLength = 0; + } + + //Cancel channeling after 0.5 seconds + private IEnumerator CancelChanneling() + { + yield return new WaitForSeconds(0.5f); + channeling = false; } Vector3 NormaliseMovement(float x, float y) @@ -433,13 +551,11 @@ public class PlayerMovement : MonoBehaviour public void Hooked(Vector3 direction, Vector3 attackPosition) { - float force = Vector3.Distance(rb.position, attackPosition) * -1; - - rb.velocity = direction * playerHookSpeed * force; - velocity = direction.x * playerHookSpeed * force; + rb.velocity = direction * playerHookSpeed; + velocity = direction.x * playerHookSpeed; } - public void SmallProjectileHit(PlayerMovement victim) + public void ProjectileHit(PlayerMovement victim) { canDash = true; } diff --git a/Assets/Script/Projectile.cs b/Assets/Script/Projectile.cs new file mode 100644 index 0000000..864ff59 --- /dev/null +++ b/Assets/Script/Projectile.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +public class Projectile : MonoBehaviour +{ + [HideInInspector] public PlayerMovement sender; + [SerializeField] private float pushForce = 1; + [SerializeField] private float defaultForce = 10; + [SerializeField] private bool swapLocation = false; + + + private void OnCollisionEnter(Collision collision) + { + if(collision.gameObject.tag == "Player") + { + Rigidbody rb = GetComponent(); + PlayerMovement pMovement = collision.gameObject.GetComponent(); + + pMovement.velocity = rb.velocity.x * pushForce + rb.velocity.normalized.x * defaultForce; + collision.gameObject.GetComponent().velocity = rb.velocity * pushForce + rb.velocity.normalized * defaultForce; + + if(swapLocation) + { + Vector3 colPosition = pMovement.transform.position; + pMovement.transform.position = sender.transform.position; + sender.transform.position = colPosition; + } + + sender.ProjectileHit(pMovement); + } + + Destroy(gameObject); + } +} diff --git a/Assets/Script/SmallProjectile.cs.meta b/Assets/Script/Projectile.cs.meta similarity index 100% rename from Assets/Script/SmallProjectile.cs.meta rename to Assets/Script/Projectile.cs.meta diff --git a/Assets/Script/SmallProjectile.cs b/Assets/Script/SmallProjectile.cs deleted file mode 100644 index 2a9051f..0000000 --- a/Assets/Script/SmallProjectile.cs +++ /dev/null @@ -1,24 +0,0 @@ -using UnityEngine; - -public class SmallProjectile : MonoBehaviour -{ - [HideInInspector] public PlayerMovement sender; - [SerializeField] private float pushForce = 1; - - - private void OnCollisionEnter(Collision collision) - { - if(collision.gameObject.tag == "Player") - { - Rigidbody rb = GetComponent(); - PlayerMovement pMovement = collision.gameObject.GetComponent(); - - pMovement.velocity = rb.velocity.x * pushForce; - collision.gameObject.GetComponent().velocity = rb.velocity * pushForce; - - sender.SmallProjectileHit(pMovement); - } - - Destroy(gameObject); - } -} diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 74d7b53..9e432d1 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -35,6 +35,8 @@ GraphicsSettings: - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index bc44a09..497f417 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -6,6 +6,7 @@ TagManager: tags: - DeathZone - SmallProjectile + - LargeProjectile layers: - Default - TransparentFX