diff options
author | miakata <miakata@gmail.com> | 2019-04-27 18:08:27 +0200 |
---|---|---|
committer | miakata <miakata@gmail.com> | 2019-04-27 18:08:27 +0200 |
commit | a5df3253047945b54a5ec25c3661b2c4967460e7 (patch) | |
tree | c5b42f3f39c2a65aa644d8d51542ee983a60edfd /nGJ2019/Assets/Scripts/DragonMovement.cs | |
parent | 7568372af43405a0d2b1d1a3adb7f817527098db (diff) | |
parent | 53a8d342ee667d1b28c1dc1e173ad73338a930b9 (diff) |
Merge branch 'master' of https://github.com/marcinzelent/ngj2019
Diffstat (limited to 'nGJ2019/Assets/Scripts/DragonMovement.cs')
-rw-r--r-- | nGJ2019/Assets/Scripts/DragonMovement.cs | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/nGJ2019/Assets/Scripts/DragonMovement.cs b/nGJ2019/Assets/Scripts/DragonMovement.cs index 4ba179d..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,10 @@ public class DragonMovement : MonoBehaviour void Update() { + if(hurtCooldown < 0) + hurtCooldown -= Time.deltaTime; + + // keyboard scheme if(Input.GetKey("w")) moveUp(); if(Input.GetKey("a")) @@ -192,6 +198,32 @@ public class DragonMovement : MonoBehaviour turnSpread(); if(Input.GetKeyUp("k")) turnAntiSpread(); + + + // xbox scheme + if(Input.GetAxis("JoystickY") < -0.5f) + moveUp(); + if(Input.GetAxis("JoystickX") < -0.5f) + moveLeft(); + if(Input.GetAxis("JoystickY") > 0.5f) + moveDown(); + if(Input.GetAxis("JoystickX") > 0.5f) + moveRight(); + + if(Input.GetButtonDown("X")) + turnSwirl(); + if(Input.GetButtonUp("X")) + turnAntiSwirl(); + + if(Input.GetButtonDown("A")) + turnSlim(); + if(Input.GetButtonUp("A")) + turnAntiSlim(); + + if(Input.GetButtonDown("Y")) + turnSpread(); + if(Input.GetButtonUp("Y")) + turnAntiSpread(); } void OnDrawGizmosSelected() @@ -200,13 +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) { - Debug.Log(enemy.type == ObstacleType.alfa ? "alfa hit" : "beta hit"); - healthBar.health--; + getHurt(); } } |