// Start is called before the first frame update void Start() { obtainBWeapon = new bool[4] { true, true, true, true }; weaponSpecies = WeaponSpecies.Boomerang; animator = GetComponent <Animator>(); movement = GetComponent <ArrowKeyMovement>(); animatorInput = GetComponent <InputToAnimator>(); playerController = GetComponent <PlayerController>(); inventory = GetComponent <Inventory>(); }
// 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)); } } }
public void collectWeapon(WeaponSpecies weapon) { }