/// <summary> /// Damage to be taken when attacked by the enemy /// </summary> /// <param name="dmgAmount"></param> amount of damage to be taken and removed from the health - parsed by the enimes DoDamage function public void TakeDamage(int dmgAmount) { currentHealth -= dmgAmount; m_hudSystem.UpdateHud(); if (currentHealth <= 0) { Death(); } }
public int upgradePoints; // used to set the players level number /// <summary> /// adds experience whenever this function is called, mostly on death from the enemy script /// </summary> /// <param name="xpAmount"></param> Amount of XP to gain parameter, This is based and set from the enemy death script public void AddExperience(int xpAmount) { experience += xpAmount; HUDSystem hud = FindObjectOfType <HUDSystem>(); hud.UpdateHud(); if (experience >= experienceToNextLevel) { level++; upgradePoints++; experience = experienceToNextLevel; IncreaseXPNeeded(0, 100 * level * Mathf.Pow(level, 0.5f)); } }
/// <summary> /// on trigger enter checks which item it is and call the appropriate function /// destroys the /// </summary> /// <param name="other"></param> private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Player")) { if (healthItem) { percent = (int)UnityEngine.Random.Range(20f, 50f); AddHealth(playerHealth.currentHealth); healthUpdate.UpdateHud(); } } if (dmgItem) { StartCoroutine(currentStats.DamageBoost()); Destroy(gameObject.GetComponent <Collider>()); Destroy(gameObject.GetComponent <MeshRenderer>()); Destroy(m_particles); Destroy(gameObject, 11f); } if (attkSpeedItem) { StartCoroutine(currentStats.AttackSpeedBoost()); Destroy(gameObject.GetComponent <Collider>()); Destroy(gameObject.GetComponent <MeshRenderer>()); Destroy(m_particles); Destroy(gameObject, 11f); } if (msItem) { StartCoroutine(currentStats.MoveSpeedBoost()); Destroy(gameObject.GetComponent <Collider>()); Destroy(gameObject.GetComponent <MeshRenderer>()); Destroy(m_particles); Destroy(gameObject, 11f); } }