// Update is called once per frame void Update() { if (Input.GetButtonDown("Restart")) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } if (!dead) { if (Input.GetButtonDown("Pip Stab") && enemy.knockedOut && myCollider.bounds.Intersects(enemy.GetComponent <BoxCollider2D> ().bounds)) { myAudio.PlayOneShot(slash); animator.Play("Attack"); enemy.Die(); } transform.gameObject.tag = "Pip"; if (body.velocity.y == 0 && Input.GetButtonDown("Pip Jump")) { animator.Play("Rising"); body.velocity += new Vector2(0, 5); } if (IsCurrentAnim("Rising") && body.velocity.y < 0) { animator.Play("Transition"); } else if (IsCurrentAnim("Transition") && body.velocity.y == 0) { animator.Play("Landing"); } if (Input.GetAxis("Pip Move") == -1) { body.velocity = new Vector2(-2, body.velocity.y); if (IsCurrentAnim("Idle")) { animator.Play("Run"); } transform.localScale = new Vector2(-3, transform.localScale.y); } else if (Input.GetAxis("Pip Move") == 1) { body.velocity = new Vector2(2, body.velocity.y); if (IsCurrentAnim("Idle")) { animator.Play("Run"); } transform.localScale = new Vector2(3, transform.localScale.y); } else { if (IsCurrentAnim("Run")) { animator.Play("Idle"); } } if (Input.GetButtonDown("Pip Switch")) { if (lever != null) { if (myCollider.bounds.Intersects(lever.GetComponent <BoxCollider2D>().bounds)) { lever.Toggle(); } } if (lever2 != null) { if (myCollider.bounds.Intersects(lever2.GetComponent <BoxCollider2D>().bounds)) { lever2.Toggle(); } } if (lever3 != null) { if (myCollider.bounds.Intersects(lever3.GetComponent <BoxCollider2D>().bounds)) { lever3.Toggle(); } } if (lever4 != null) { if (myCollider.bounds.Intersects(lever4.GetComponent <BoxCollider2D>().bounds)) { lever4.Toggle(); } } } if (wulfric.pipHeld) { animator.Play("Hanging"); } else if (IsCurrentAnim("Hanging")) { animator.Play("Rising"); } } if (timer == true) { targetTime -= Time.deltaTime; } if (targetTime <= 0) { upperino = true; } if (upperino == true) { myAudio.PlayOneShot(death); upperino = false; timer = false; targetTime = 3f; } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.P)) { Application.Quit(); } if (Input.GetButtonDown("Restart")) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } if (body.velocity.y == 0 && Input.GetButtonDown("Wulfric Jump")) { body.velocity += new Vector2(0, 5); animator.Play("Rising"); } if (IsCurrentAnim("Rising") && body.velocity.y < 0) { animator.Play("Transition"); } else if (IsCurrentAnim("Transition") && body.velocity.y == 0) { myAudio.PlayOneShot(land); animator.Play("Land"); } if (Input.GetAxis("Wulfric Move") == -1) { if (IsCurrentAnim("Idle")) { animator.Play("Walk"); } body.velocity = new Vector2(-2, body.velocity.y); transform.localScale = new Vector2(3, transform.localScale.y); } else if (Input.GetAxis("Wulfric Move") == 1) { if (IsCurrentAnim("Idle")) { animator.Play("Walk"); } body.velocity = new Vector2(2, body.velocity.y); transform.localScale = new Vector2(-3, transform.localScale.y); } else { if (IsCurrentAnim("Walk")) { animator.Play("Idle"); } } if (Input.GetButtonDown("Wulfric Throw")) { if (holding == null) { if (body.velocity.y == 0) { animator.Play("Pick Up"); } if (myCollider.bounds.Intersects(box.GetComponent <BoxCollider2D> ().bounds)) { holding = box; } else if (myCollider.bounds.Intersects(pip.GetComponent <BoxCollider2D> ().bounds)) { holding = pip; pipHeld = true; } } else { if (Input.GetAxis("Wulfric Move") == -1) { animator.Play("Throw Side"); StartCoroutine(throwHeld(-10, 4, 0.5f)); } else if (Input.GetAxis("Wulfric Move") == 1) { animator.Play("Throw Side"); StartCoroutine(throwHeld(10, 4, 0.5f)); } else { animator.Play("Throw"); StartCoroutine(throwHeld(0, 10, 0.9f)); } } } if (Input.GetButtonDown("Wulfric Switch")) { if (lever != null) { if (myCollider.bounds.Intersects(lever.GetComponent <BoxCollider2D>().bounds)) { lever.Toggle(); } } if (lever2 != null) { if (myCollider.bounds.Intersects(lever2.GetComponent <BoxCollider2D>().bounds)) { lever2.Toggle(); } } if (lever3 != null) { if (myCollider.bounds.Intersects(lever3.GetComponent <BoxCollider2D>().bounds)) { lever3.Toggle(); } } if (lever4 != null) { if (myCollider.bounds.Intersects(lever.GetComponent <BoxCollider2D>().bounds)) { lever4.Toggle(); } } } if (holding != null) { holding.GetComponent <Rigidbody2D>().MovePosition(Vector3.MoveTowards(holding.transform.position, new Vector3(transform.position.x, transform.position.y - 0.6f), 0.1f)); } }