diff options
author | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-27 16:31:32 +0200 |
---|---|---|
committer | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-27 16:31:32 +0200 |
commit | 29ea8fd1b67042ced673a3e53c12823d8aee2783 (patch) | |
tree | 159185da39718f427710c973becd45389138ef69 /nGJ2019/Assets/Scripts | |
parent | 262be7cfa429a30bafec50efe8fb2154d73e2eeb (diff) |
xbox control scheme
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r-- | nGJ2019/Assets/Scripts/DragonMovement.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs index f2c1cb5..f3ae1d5 100644 --- a/nGJ2019/Assets/Scripts/DragonMovement.cs +++ b/nGJ2019/Assets/Scripts/DragonMovement.cs @@ -14,6 +14,8 @@ public class DragonMovement : MonoBehaviour public HealthBar healthBar; + private float hurtCooldown = 0; + private SwarmSystem swarm; private enum State {normal, swirl, slim, spread}; @@ -169,6 +171,9 @@ public class DragonMovement : MonoBehaviour void Update() { + if(hurtCooldown < 0) + hurtCooldown -= Time.deltaTime; + // keyboard scheme if(Input.GetKey("w")) moveUp(); @@ -196,11 +201,11 @@ public class DragonMovement : MonoBehaviour // xbox scheme - if(Input.GetAxis("JoystickY") > 0.5f) + if(Input.GetAxis("JoystickY") < -0.5f) moveUp(); if(Input.GetAxis("JoystickX") < -0.5f) moveLeft(); - if(Input.GetAxis("JoystickY") < -0.5f) + if(Input.GetAxis("JoystickY") > 0.5f) moveDown(); if(Input.GetAxis("JoystickX") > 0.5f) moveRight(); @@ -227,12 +232,21 @@ public class DragonMovement : MonoBehaviour Gizmos.DrawWireCube(Vector3.zero, new Vector3(2*horizontalBound, 2*verticalBound, 0)); } + private void getHurt() + { + if(hurtCooldown <= 0) + { + healthBar.health--; + hurtCooldown = 3; + } + } + void OnTriggerEnter(Collider other) { EnemyCollider enemy = other.gameObject.GetComponent<EnemyCollider>(); if(enemy != null) { - healthBar.health--; + getHurt(); } } |