Exemplo n.º 1
0
 public void ChangeHitPoint(int damage)
 {
     _player.SetHitPoint(_player.GetHitPoint() - damage);
     _healthBar.SetHealthBar(_player.GetHitPoint());
     if (_player.GetHitPoint() <= 0)
     {
         Die();
     }
 }
Exemplo n.º 2
0
    /*IEnumerator StartSound()
     * {
     *  audioSource.Play();
     *  for (float i = 0; i < 0.2f; i += Time.deltaTime)
     *  {
     *      audioSource.volume = 5 * i;
     *      if (rig.velocity == Vector2.zero) { break; }
     *      yield return null;
     *  }
     *  audioSource.volume = 1;
     * }*/

    /*IEnumerator StopSoundDelay()
     * {
     *  float time = 0;
     *  while(rig.velocity == Vector2.zero && time<0.1f)
     *  {
     *      time += Time.deltaTime;
     *      yield return null;
     *  }
     *  if(rig.velocity == Vector2.zero)
     *  {
     *      for (float i = 0; i < 0.2f; i+=Time.deltaTime)
     *      {
     *          audioSource.volume = 1 - 5 * i;
     *          if(rig.velocity != Vector2.zero) { break; }
     *          yield return null;
     *      }
     *      if(rig.velocity==Vector2.zero)
     *      {
     *          audioSource.Stop();
     *      }
     *  }
     *  stoppingSound = false;
     * }*/

    public void LifeLoss(float damage, int ID)
    {
        if (life > 0)
        {
            comboBreaked = true;
            float actualDamage = Random.Range(damage * 0.75f, damage * 1.25f);
            life            -= actualDamage;
            damageTaken[ID] += actualDamage + Mathf.Min(0, life);
            healthBarCont.SetHealthBar(life / defaultLife);
            if (life <= 0)
            {
                Die(false);
            }
        }
    }
Exemplo n.º 3
0
 //set health bar
 private void SetHealthBar()
 {
     healthBarController.SetHealthBar(health / 100);
 }