|
@ -29,6 +29,7 @@ public class playerController : MonoBehaviour { |
|
|
private bool updateHealth = true; //if the health bar needs updating
|
|
|
private bool updateHealth = true; //if the health bar needs updating
|
|
|
private float curDirection = -1; //direction player is pointing
|
|
|
private float curDirection = -1; //direction player is pointing
|
|
|
private bool canJump = true; // if player can jump
|
|
|
private bool canJump = true; // if player can jump
|
|
|
|
|
|
private bool canSpin = true; // if player can spin
|
|
|
private List<GameObject> hearts = new List<GameObject> (); //list which holds health sprites;
|
|
|
private List<GameObject> hearts = new List<GameObject> (); //list which holds health sprites;
|
|
|
private bool isSpinning = false; //checks if player is spin attacking
|
|
|
private bool isSpinning = false; //checks if player is spin attacking
|
|
|
private float lastHit; |
|
|
private float lastHit; |
|
@ -78,7 +79,8 @@ public class playerController : MonoBehaviour { |
|
|
}//end if
|
|
|
}//end if
|
|
|
|
|
|
|
|
|
if (Input.GetAxisRaw (StrongAttackBtn)==1) { |
|
|
if (Input.GetAxisRaw (StrongAttackBtn)==1) { |
|
|
if (!isSpinning && (lastAttack+attackWait) < Time.time){ |
|
|
|
|
|
|
|
|
if (!isSpinning && canSpin && Time.time - lastAttack > attackWait){ |
|
|
|
|
|
velocity.y = jumpHeight; |
|
|
lastAttack = Time.time; |
|
|
lastAttack = Time.time; |
|
|
StartCoroutine (spinAttack (Vector3.down * 360, 0.2f)); |
|
|
StartCoroutine (spinAttack (Vector3.down * 360, 0.2f)); |
|
|
} |
|
|
} |
|
@ -153,17 +155,18 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
|
private void damage (){ |
|
|
private void damage (){ |
|
|
if (isHit) { |
|
|
if (isHit) { |
|
|
gameObject.GetComponent<PolygonCollider2D> ().enabled = false; |
|
|
|
|
|
|
|
|
gameObject.GetComponentInChildren<PolygonCollider2D> ().enabled = false; |
|
|
isHit = false; |
|
|
isHit = false; |
|
|
lastHit = Time.time; |
|
|
lastHit = Time.time; |
|
|
} |
|
|
} |
|
|
if (lastHit+invulTime < Time.time) |
|
|
if (lastHit+invulTime < Time.time) |
|
|
gameObject.GetComponent<PolygonCollider2D> ().enabled = true; |
|
|
|
|
|
|
|
|
gameObject.GetComponentInChildren<PolygonCollider2D> ().enabled = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
IEnumerator spinAttack(Vector3 byAngles, float inTime) { |
|
|
IEnumerator spinAttack(Vector3 byAngles, float inTime) { |
|
|
isSpinning = true; |
|
|
isSpinning = true; |
|
|
|
|
|
canSpin = false; |
|
|
stick.isAttacking = true; |
|
|
stick.isAttacking = true; |
|
|
Debug.Log ("" + gameObject.name + "spinning"); |
|
|
Debug.Log ("" + gameObject.name + "spinning"); |
|
|
Quaternion startAngle = transform.rotation; |
|
|
Quaternion startAngle = transform.rotation; |
|
@ -186,10 +189,13 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OnCollisionEnter2D(Collision2D col){ |
|
|
void OnCollisionEnter2D(Collision2D col){ |
|
|
if (col.collider.tag == "ground") |
|
|
|
|
|
|
|
|
if (col.collider.tag == "ground") { |
|
|
canJump = true; |
|
|
canJump = true; |
|
|
|
|
|
canSpin = true; |
|
|
|
|
|
} |
|
|
else if (col.collider.tag == "Player") { |
|
|
else if (col.collider.tag == "Player") { |
|
|
canJump = true; |
|
|
canJump = true; |
|
|
|
|
|
canSpin = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|