diff --git a/playable/Assets/Lachlan_jump_work.unity b/playable/Assets/Lachlan_jump_work.unity index c967cc9..76dd1df 100644 Binary files a/playable/Assets/Lachlan_jump_work.unity and b/playable/Assets/Lachlan_jump_work.unity differ diff --git a/playable/Assets/Menu.cs b/playable/Assets/Menu.cs index 256e9ca..07e216a 100644 --- a/playable/Assets/Menu.cs +++ b/playable/Assets/Menu.cs @@ -34,6 +34,10 @@ public class Menu : MonoBehaviour { start = !start; menu = false; } + if (start || menu) + Time.timeScale = 0; + else + Time.timeScale = 1; } void OnGUI () diff --git a/playable/Assets/Scripts/playerController.cs b/playable/Assets/Scripts/playerController.cs index 2a4b8d0..2341710 100644 --- a/playable/Assets/Scripts/playerController.cs +++ b/playable/Assets/Scripts/playerController.cs @@ -7,6 +7,7 @@ public class playerController : MonoBehaviour { public string HorizontalBtn; //holds string for horizontal input public string VerticalBtn; //holds string for Vertical input public string StrongAttackBtn; + public string DashAttackBtn; public Animator animator; //Holds animator for Pinata public GameObject heart; //Health sprites @@ -24,6 +25,9 @@ public class playerController : MonoBehaviour { public float invulTime; public float attackWait; public bool isHit; + public float dashDistance; + public float dashTime; + public float dashWait; private float displayedHealth = 3; //currently displayed health private bool updateHealth = true; //if the health bar needs updating @@ -35,7 +39,10 @@ public class playerController : MonoBehaviour { private float lastHit; private float lastAttack; private int score; - + private bool isDashing =false; + private bool canDash = true; + private float lastDash; + private bool stopDash = false; void Start(){ if (transform.rotation.y == 180) @@ -59,6 +66,7 @@ public class playerController : MonoBehaviour { if (score >= 10) { gameOverDisplay.enabled = true; gameOverDisplay.text = ""+ gameObject.name + " Wins"; + Time.timeScale = 0; } @@ -86,6 +94,15 @@ public class playerController : MonoBehaviour { } } + if (Input.GetAxisRaw (DashAttackBtn) == 1) { + //Debug.Log ("dashbutton pressed"); + if(!isDashing && canDash && Time.time - lastDash > dashWait){ + lastDash = Time.time; + StartCoroutine (dashAttack (dashDistance,dashTime)); + } + + } + rigidbody2D.velocity = velocity; //apply inputs @@ -184,6 +201,49 @@ public class playerController : MonoBehaviour { stick.isAttacking = false; } + IEnumerator dashAttack (float dashDistance,float dashTime) { + float endPosition; + int dashDirection; + + isDashing = true; + canDash = false; + stick.isAttacking = true; + Debug.Log ("" + gameObject.name + "Dashing"); + rigidbody2D.gravityScale = 0; + + + + + Vector3 startPosition = transform.position; + Debug.Log ("rotation Y: " + transform.eulerAngles.y); + if (transform.eulerAngles.y >= 150) + dashDirection = -1; + else + dashDirection = 1; + + endPosition = startPosition.x + (dashDirection * dashDistance); + Debug.Log ("Dash start: " + startPosition.x); + Debug.Log ("Dash Direction: " + (dashDirection )); + Debug.Log ("Dash end: " + endPosition); + + for (float i = 0; i < 1; i += Time.deltaTime/dashTime) { + transform.position = new Vector3(dashDirection * Mathf.Lerp((dashDirection)*startPosition.x, (dashDirection)* endPosition, i), startPosition.y, startPosition.z); + + if (stopDash) + break; + + yield return null; + } + + + stopDash = false; + isDashing = false; + canDash = true; + stick.isAttacking = false; + Debug.Log ("" + gameObject.name + " finished Dashing"); + rigidbody2D.gravityScale = 4; + } + @@ -197,6 +257,11 @@ public class playerController : MonoBehaviour { canJump = true; canSpin = true; } + + if (col.collider.tag == "wall") { + stopDash = true; + + } } void OnTriggerEnter2D(Collider2D trig) diff --git a/playable/ProjectSettings/InputManager.asset b/playable/ProjectSettings/InputManager.asset index f4eccf8..ff1bc29 100644 Binary files a/playable/ProjectSettings/InputManager.asset and b/playable/ProjectSettings/InputManager.asset differ diff --git a/playable/ProjectSettings/TagManager.asset b/playable/ProjectSettings/TagManager.asset index 7bf66d9..aab6ff2 100644 Binary files a/playable/ProjectSettings/TagManager.asset and b/playable/ProjectSettings/TagManager.asset differ