From 3fd587505b3b93a341383d63fa2961a6e5b7e2e2 Mon Sep 17 00:00:00 2001 From: Tristan Roux Date: Sat, 1 Dec 2018 18:13:42 +0100 Subject: [PATCH] Adding other personalities. --- Assets/Script/PlayerMovement.cs | 39 +++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Assets/Script/PlayerMovement.cs b/Assets/Script/PlayerMovement.cs index 835b222..545bf64 100644 --- a/Assets/Script/PlayerMovement.cs +++ b/Assets/Script/PlayerMovement.cs @@ -30,6 +30,11 @@ public class PlayerMovement : MonoBehaviour public LineRenderer hookRenderer; public bool hooked = false; + [Space] + [Header("Slow Projectile")] + public GameObject SlowProjectile; + public float projSpeed = 1.2f; + [Space] [Space] [Header("SwitchMenu")] @@ -43,8 +48,8 @@ public class PlayerMovement : MonoBehaviour public GameObject hook; private Personalty switchingTo; - [Space] - public Personalty personalty; + private Personalty personalty; + private int HealPoint = 5; private bool isJumping = false; private int flip = 1; private bool switching = false; @@ -230,6 +235,19 @@ public class PlayerMovement : MonoBehaviour { CalculateHook(); } + + //Heal + if (personalty == Personalty.Heal && Input.GetButtonDown("Action")) + { + StartHealing(); + } + + //Slow Projectiles + if(personalty == Personalty.SlowProj && Input.GetButtonDown("Action")) + { + GameObject proj = Instantiate(SlowProjectile); + proj.GetComponent().velocity = GetDirection() * projSpeed; + } } private async void CalculateHook() @@ -287,10 +305,27 @@ public class PlayerMovement : MonoBehaviour } } + private async void StartHealing() + { + await Task.Delay(3000); + if(personalty == Personalty.Heal) + HealPoint += 2; + } + private void OnCollisionEnter2D(Collision2D collision) { if(IsGrounded) hasDoubleJump = true; + + if (collision.gameObject.tag == "Enemy") + HealPoint--; + if (HealPoint <= 0) + Death(); + } + + private void Death() + { + //ON VERA APRES } private Vector3 GetDirection(bool useAimCorrection = true)