public void MoveLeft() { ; horzMove = -1f; animator.Play("WalkLeft"); atkDir = AttkDirection.LEFT; }
public void IdleRight() { horzMove = 0f; animator.Play("IdleRight"); atkDir = AttkDirection.RIGHT; }
public void IdleLeft() { horzMove = 0f; animator.Play("IdleLeft"); atkDir = AttkDirection.LEFT; }
public void IdleDownward() { vertMove = 0f; animator.Play("Idle"); atkDir = AttkDirection.DOWN; }
public void IdleUpward() { vertMove = 0f; animator.Play("IdleUpward"); atkDir = AttkDirection.UP; }
public void MoveDown() { vertMove = -1f; animator.Play("WalkDown"); atkDir = AttkDirection.DOWN; // Set attack direction to down and call for animation }
public void MoveUp() { vertMove = 1f; animator.Play("WalkUp"); atkDir = AttkDirection.UP; }
public void MoveRight() { horzMove = 1f; animator.Play("WalkRight"); atkDir = AttkDirection.RIGHT; }
void FixedUpdate() { // keyboard input // float horzMove = Input.GetAxisRaw ("Horizontal"); // float vertMove = Input.GetAxisRaw ("Vertical"); // horzMove = Input.GetAxisRaw ("Horizontal"); // vertMove = Input.GetAxisRaw ("Vertical"); if (rb.IsSleeping()) { rb.WakeUp(); } // #if UNITY_STANDALONE || UNITY_WEBPLAYER if (Input.GetKey("w") || Input.GetKey("s")) { horzMove = Input.GetAxisRaw("Horizontal"); vertMove = Input.GetAxisRaw("Vertical"); if (FlyRod_Running) { CancelCoroutinte(isFishing, StopFlyRod); } if (Input.GetKey("s")) { animator.Play("WalkDown"); atkDir = AttkDirection.DOWN; // Set attack direction to down and call for animation } if (Input.GetKey("w")) { animator.Play("WalkUp"); atkDir = AttkDirection.UP; } } else { horzMove = Input.GetAxisRaw("Horizontal"); vertMove = Input.GetAxisRaw("Vertical"); if (Input.GetKey("d")) { if (FlyRod_Running) { CancelCoroutinte(isFishing, StopFlyRod); } animator.Play("WalkRight"); atkDir = AttkDirection.RIGHT; } if (Input.GetKey("a")) { if (FlyRod_Running) { CancelCoroutinte(isFishing, StopFlyRod); } animator.Play("WalkLeft"); atkDir = AttkDirection.LEFT; } } if (Input.GetKeyUp("w") || Input.GetKeyUp("a") || Input.GetKeyUp("s") || Input.GetKeyUp("d")) { //animator.Play ("Idle"); float centerX = (float)Math.Round(Convert.ToDouble(transform.position.x)); float centerY = (float)Math.Round(Convert.ToDouble(transform.position.y)); transform.position = new Vector2(centerX, centerY); // atkDir = AttkDirection.DOWN; if (Input.GetKeyUp("w")) { animator.Play("IdleUpward"); atkDir = AttkDirection.UP; } if (Input.GetKeyUp("a")) { animator.Play("IdleLeft"); atkDir = AttkDirection.LEFT; } if (Input.GetKeyUp("s")) { animator.Play("Idle"); atkDir = AttkDirection.DOWN; } if (Input.GetKeyUp("d")) { animator.Play("IdleRight"); atkDir = AttkDirection.RIGHT; } } if (Input.GetKeyDown(KeyCode.Return) && !isAttackInCooldown) { PlayerAttack(); // food -= 15; // foodText.text = "Food: " + food; } //remove after testing if (Input.GetKeyDown(KeyCode.Equals)) { PlayerFish(); } // #endif if (controllerInputs == false) { rb.velocity = new Vector2(0, 0); } else { rb.velocity = new Vector2(horzMove * speed, vertMove * speed); } if (carbs == 0 && fats == 0) { GameIsOver(); } playerScore.NutrientScore = (carbs + protein) - fats; }