//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); } }
//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); } }
private void OnTriggerEnter(Collider collider) { GameObject objectCollided = collider.gameObject; if (pickupCooldownTimer < Time.time) { if (objectCollided.CompareTag("Player")) { pickupCooldownTimer = Time.time + pickupCooldown; print("object collected"); if (whichGain == false) { global_damagable stamina_globalInstance = objectCollided.GetComponent <global_damagable>(); stamina_globalInstance.HealthPickupMethod(); } if (whichGain == true) { global_stamina stamina_globalInstance = objectCollided.GetComponent <global_stamina>(); stamina_globalInstance.StaminaPickupMethod(); } } } }
//translates position of object according to object's "dodgeDistance" while rotating object towards direction of movement //"nextDodge = Time.time + dodgeCooldown;" calculates the cooldown as specified with "dodgeCooldown" from "stats_global" in seconds //stamina_global stamina_globalInstance = GetComponent<stamina_global>(); + stamina_globalInstance.DodgeStamina(); runs the stamina script on this character. void DodgeControls() { if (currentStaminaPoints > dodgeStamina) { if (Time.time > nextDodge) { if (Input.GetKey(dodge)) { //if player class !=tank animator.SetBool("isDodging", true); //setting the cooldown before the next dodge can be activated nextDodge = Time.time + dodgeCooldown; //runs the method from "global_stamina" to use an amount of stamina points global_stamina stamina_globalInstance = GetComponent <global_stamina>(); stamina_globalInstance.DodgeStamina(); //changing whether or not this character blocks damage when using their "dodge" ability damageBlocker = gameObject.GetComponent <global_stats>().damageBlocker; } else { animator.SetBool("isDodging", false); // help Vector3 left || Vector3 right = new Vector3(-baseDodgeDistance * dodgeDistance, 0, 0); damageBlocker = false; } } else { damageBlocker = false; } } else { damageBlocker = false; } }
void Awake() { Instance = this; }