//everything that enables the archer's arrow shooting, stamina usage and cooldown void ArcherAttack() { if (currentStaminaPoints > attackStamina && Time.time > nextAttack && Input.GetKeyDown(attack)) { animator.SetBool("isArcherAttacking", true); GameObject instArcherArrow = Instantiate(archerArrow, transform.position + offset, Quaternion.identity) as GameObject; Rigidbody instArcherArrowRigidbody = instArcherArrow.GetComponent <Rigidbody>(); instArcherArrowRigidbody.AddForce(transform.forward * arrowSpeed); //setting the cooldown before the next attack can be activated nextAttack = Time.time + attackCooldown; //runs the method from "global_stamina" to use an amount of stamina points global_stamina stamina_globalInstance = GetComponent <global_stamina>(); stamina_globalInstance.AttackStamina(); BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.ArcherAttack); } else { animator.SetBool("isArcherAttacking", false); } }
//everything that enables the tank's attack movement, stamina usage and cooldown void TankAttack() { if (currentStaminaPoints > attackStamina && Time.time > nextAttack && Input.GetKeyDown(attack)) { animator.SetBool("isTankAttacking", true); //start clockwise rotation of sword with a Coroutine; //StartCoroutine(RotateMe(Vector3.up * 90, 0.8f)); //setting time before second swing //setting the cooldown before the next attack can be activated nextAttack = Time.time + attackCooldown; //runs the method from "global_stamina" to use an amount of stamina points global_stamina stamina_globalInstance = GetComponent <global_stamina>(); stamina_globalInstance.AttackStamina(); BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.TankAttack); } else { animator.SetBool("isTankAttacking", false); } }
public void RespawnPlayer1() { if (playerOne == 1) { animatorPlayerOne = GameObject.Find("ArcherPlayer1(Clone)").GetComponent <Animator>(); animatorPlayerOne.SetBool("isRespawning", true); Instantiate(archerPlayer1, spawnPlayer1.transform); StartCoroutine(COStunPause(1.2f)); BG_CharacterAudio characterAudioInstance = player2.GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.RespawnScreaming); } if (playerOne == 2) { animatorPlayerOne = GameObject.Find("KnightPlayer1(Clone)").GetComponent <Animator>(); animatorPlayerOne.SetBool("isRespawning", true); Instantiate(knightPlayer1, spawnPlayer1.transform); StartCoroutine(COStunPause(1.2f)); BG_CharacterAudio characterAudioInstance = player2.GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.RespawnScreaming); } if (playerOne == 3) { animatorPlayerOne = GameObject.Find("TankPlayer1(Clone)").GetComponent <Animator>(); animatorPlayerOne.SetBool("isRespawning", true); Instantiate(tankPlayer1, spawnPlayer1.transform); StartCoroutine(COStunPause(1.2f)); BG_CharacterAudio characterAudioInstance = player2.GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.RespawnScreaming); } }
void CallDodging() { if (isDodging == true) { BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Dodging); } }
void CallFootsteps() { if (isWalking == true) { BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Walking); } }
private void OnTriggerEnter(Collider collider) { GameObject objectCollided = collider.gameObject; if (objectCollided.CompareTag("Attacker") && currentHP > 0) { attackDamage = objectCollided.GetComponentInParent <global_stats>().attackDamage; currentHP -= attackDamage; BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Flinching); } }
void DoDamage() { if (currentHP <= 0) { print("dead: " + gameObject); BG_CharacterAudio characterAudioInstance = GetComponent <BG_CharacterAudio>(); characterAudioInstance.PlayerSounds(BG_CharacterAudio.soundList.Death); if (playerNumber == 1) { global_kill_counter.Instance.ScoreCounterPlayer1(); global_respawn.Instance.RespawnPlayer1(); } if (playerNumber == 2) { global_kill_counter.Instance.ScoreCounterPlayer2(); global_respawn.Instance.RespawnPlayer2(); } Destroy(gameObject); } }
// Start is called before the first frame update void Start() { Instance = this; }