diff --git a/Assets/Scripts/Player/PlayerAnimationHandler.cs b/Assets/Scripts/Player/PlayerAnimationHandler.cs index ef54b41..13a8fa5 100644 --- a/Assets/Scripts/Player/PlayerAnimationHandler.cs +++ b/Assets/Scripts/Player/PlayerAnimationHandler.cs @@ -5,28 +5,10 @@ using UnityEngine; public class PlayerAnimationHandler : MonoBehaviour { Animator animator; - SpriteRenderer sp; - - Vector3 prevPos; void Start() { animator = GetComponentInChildren(); - sp = GetComponentInChildren(); - } - - private void Update() - { - if ((transform.position - prevPos).x > 0.1f) - { - sp.flipX = false; - } - else if ((transform.position - prevPos).x < -0.1f) - { - sp.flipX = true; - } - - prevPos = transform.position; } public void Idle() diff --git a/Assets/Scripts/Player/PlayerInput.cs b/Assets/Scripts/Player/PlayerInput.cs index 3497fea..7721fc9 100644 --- a/Assets/Scripts/Player/PlayerInput.cs +++ b/Assets/Scripts/Player/PlayerInput.cs @@ -17,6 +17,8 @@ public class PlayerInput : MonoBehaviour public event Action ropeLengthShrinken; public event Action ropeLengthExtend; + public bool useArrowKeys = false; + public int PlayerNum => playerNumber; private void Start() @@ -45,11 +47,19 @@ public class PlayerInput : MonoBehaviour } else { - movement.x = Input.GetAxisRaw("Horizontal"); - movement.y = Input.GetAxisRaw("Vertical"); + if (!useArrowKeys) + { + movement.x = Input.GetAxisRaw("bruh"); + movement.y = Input.GetAxisRaw("bruh_v"); + } + else + { + movement.x = Input.GetAxisRaw("bruh2"); + movement.y = Input.GetAxisRaw("bruh2_v"); + } whipAttack = Input.GetKey(KeyCode.B); + //Debug.Log($"player {playerNumber}: move {movement}"); } - //Debug.Log($"player {playerNumber}: move {movement}"); } } diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index ff91a14..621fc97 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -7,6 +7,7 @@ using System.Linq; [RequireComponent(typeof(PlayerInput))] public class PlayerMovement : MonoBehaviour { + public PlayerAnimationHandler animationHandler; public float moveSpeed = 5f; private Rigidbody2D rb; @@ -35,6 +36,11 @@ public class PlayerMovement : MonoBehaviour rb = GetComponent(); playerInput = GetComponent(); + if (gameObject.name == "Player2") + { + playerInput.useArrowKeys = true; + } + StartCoroutine(ToggleWithDelay()); } @@ -43,7 +49,7 @@ public class PlayerMovement : MonoBehaviour if (playerInput.movement != Vector2.zero) { RumbleWalk(); - GetComponent().Run(); + animationHandler.Run(); } } private void FixedUpdate() diff --git a/Assets/Scripts/Player/SpriteMovementFlipper.cs b/Assets/Scripts/Player/SpriteMovementFlipper.cs new file mode 100644 index 0000000..cf33f64 --- /dev/null +++ b/Assets/Scripts/Player/SpriteMovementFlipper.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +public class SpriteMovementFlipper : MonoBehaviour +{ + SpriteRenderer sp; + + Vector3 prevPos; + + void Start() + { + sp = GetComponentInChildren(); + } + + private void Update() + { + if ((transform.position - prevPos).x > 0.1f) + { + sp.flipX = false; + } + else if ((transform.position - prevPos).x < -0.1f) + { + sp.flipX = true; + } + + prevPos = transform.position; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Player/SpriteMovementFlipper.cs.meta b/Assets/Scripts/Player/SpriteMovementFlipper.cs.meta new file mode 100644 index 0000000..c555aef --- /dev/null +++ b/Assets/Scripts/Player/SpriteMovementFlipper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c66441ada081b6c4c841000e83cc2b7a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Rope/RopeSimulator.cs b/Assets/Scripts/Rope/RopeSimulator.cs index 01a8948..a1a38d9 100644 --- a/Assets/Scripts/Rope/RopeSimulator.cs +++ b/Assets/Scripts/Rope/RopeSimulator.cs @@ -263,7 +263,10 @@ public class RopeSimulator : MonoBehaviour // Handle squeze kills foreach (var collider in colliderToSquezeForce) { - ISquezeDamageReceiver squezeDamageReceiver = collider.Key.GetComponent(); + ISquezeDamageReceiver squezeDamageReceiver = collider.Key.transform.root.GetComponent(); + if (squezeDamageReceiver == null) + squezeDamageReceiver = collider.Key.GetComponent(); + if (squezeDamageReceiver == null) continue; squezeDamageReceiver.TakeSquezeDamage(collider.Value * squezeDamage); diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index a020a0d..63fa704 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -11,4 +11,5 @@ EditorBuildSettings: - enabled: 1 path: Assets/Scenes/GameScene.unity guid: 0400e5e5779425c40ba3164b1e0b5b59 - m_configObjects: {} + m_configObjects: + com.unity.input.settings: {fileID: 11400000, guid: de04e34f85a966e4da851d9b3d804fa1, type: 2} diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset index b16147e..8d07924 100644 --- a/ProjectSettings/InputManager.asset +++ b/ProjectSettings/InputManager.asset @@ -150,11 +150,11 @@ InputManager: axis: 2 joyNum: 0 - serializedVersion: 3 - m_Name: Horizontal + m_Name: bruh descriptiveName: descriptiveNegativeName: - negativeButton: - positiveButton: + negativeButton: a + positiveButton: d altNegativeButton: altPositiveButton: gravity: 0 @@ -162,11 +162,11 @@ InputManager: sensitivity: 1 snap: 0 invert: 0 - type: 2 - axis: 0 - joyNum: 0 + type: 0 + axis: 15 + joyNum: 6 - serializedVersion: 3 - m_Name: Vertical + m_Name: bruh_v descriptiveName: descriptiveNegativeName: negativeButton: @@ -178,9 +178,9 @@ InputManager: sensitivity: 1 snap: 0 invert: 1 - type: 2 - axis: 1 - joyNum: 0 + type: 0 + axis: 15 + joyNum: 8 - serializedVersion: 3 m_Name: Fire1 descriptiveName: @@ -485,3 +485,36 @@ InputManager: type: 2 axis: 5 joyNum: 0 + - serializedVersion: 3 + m_Name: bruh2 + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 27 + joyNum: 10 + - serializedVersion: 3 + m_Name: bruh2_v + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 5 + joyNum: 8 + m_UsePhysicalKeys: 1