// Update is called once per frame void Update() { if (playerController.state == PlayerController.PlayerStates.Unresponsive) { animator.speed = 0.0f; return; } animator.SetFloat("horizontal_input", rb.velocity.x); animator.SetFloat("vertical_input", rb.velocity.y); animator.SetBool("A_pressed", Input.GetButtonDown("Fire1")); animator.SetInteger("Direction", (int)movement.GetDirection()); if (Input.GetButtonDown("Menu")) { GameController.LoadMenu(); } if (Input.GetAxisRaw("Horizontal") == 0 && Input.GetAxisRaw("Vertical") == 0 && !Input.GetButtonDown("Fire1")) { animator.speed = 0.0f; //animator.SetLayerWeight(1, 0); } else { animator.speed = 1.0f; //animator.SetLayerWeight(1, 1); } }
// Update is called once per frame void Update() { animator.SetInteger("Direction", (int)movement.GetDirection()); //if(ThrowingSword.instance.throwing) //{ // animator.speed = 0.0f; //} //else //{ // animator.speed = 1.0f; //} }
void addForce(float magnitude, GameController.Direction direction) { if (direction == GameController.Direction.None) { direction = movement.GetDirection(); } if (direction == GameController.Direction.Down) { rb.AddForce(new Vector3(0, -magnitude, 0)); } else if (direction == GameController.Direction.Up) { rb.AddForce(new Vector3(0, magnitude, 0)); } else if (direction == GameController.Direction.Right) { rb.AddForce(new Vector3(magnitude, 0, 0)); } else if (direction == GameController.Direction.Left) { rb.AddForce(new Vector3(-magnitude, 0, 0)); } }
// Update is called once per frame void Update() { //TODO: add throw mechanic when player with full health if (playerController.state == PlayerController.PlayerStates.Idle && GameController.instance.gameState == GameController.GameStates.Play) { if (Input.GetButtonDown("Switch")) { // Debug.Log("Switching Weapon."); for (int i = 1; i < 5; i++) { int newWeaponIndex = ((int)weaponSpecies + i) % 4; if (obtainBWeapon[newWeaponIndex]) { Debug.Log(newWeaponIndex); weaponSpecies = (WeaponSpecies)newWeaponIndex; break; } } } if (Input.GetButtonDown("Fire1")) { GameController.Direction direction = movement.GetDirection(); if (!SwordThrowing && playerController.hp == playerController.maxHp) { //Throw sword //Debug.Log("Sword throwing!"); SwordThrowing = true; //ThrowingSword.instance.Attack(direction); StartCoroutine(animatorInput.AnimateSwordAttack(true, direction)); } else if (!SwordAttacking) { //Attack sword //Debug.Log("Sword attacking!"); Sword.instance.Attack(direction); StartCoroutine(animatorInput.AnimateSwordAttack(false, direction)); } } else if (!BWeaponAttacking && Input.GetButtonDown("Fire2")) { GameController.Direction direction = movement.GetDirection(); switch (weaponSpecies) { case WeaponSpecies.Bow: if (inventory.GetRupees() <= 0 && !inventory.isGodMode) { return; } BWeaponAttacking = true; if (!inventory.isGodMode) { inventory.AddRupees(-1); } //Debug.Log("Arrow attacking!"); AudioSource.PlayClipAtPoint(bow_sound_clip, Camera.main.transform.position); StartCoroutine(animatorInput.AnimateBWeaponAttack(direction, WeaponSpecies.Bow)); break; case WeaponSpecies.Boomerang: //Debug.Log("Boomerang attacking!"); BWeaponAttacking = true; AudioSource.PlayClipAtPoint(bow_sound_clip, Camera.main.transform.position); StartCoroutine(animatorInput.AnimateBWeaponAttack(direction, WeaponSpecies.Boomerang)); break; // Mark case WeaponSpecies.PortalGun: if (!portalGunAcquired) { return; } BWeaponAttacking = true; StartCoroutine(animatorInput.AnimateBWeaponAttack(direction, WeaponSpecies.PortalGun)); break; } } else if (!BombAttacking && Input.GetButtonDown("Fire3")) { if (inventory.GetBombs() <= 0 && !inventory.isGodMode) { return; } BombAttacking = true; if (!inventory.isGodMode) { inventory.AddBombs(-1); } GameController.Direction direction = movement.GetDirection(); StartCoroutine(animatorInput.AnimateBombAttack(direction)); } } }