Example #1
0
        private void Start()
        {
            healthBar.Setup(hs);
            hs.Damage(35);
            Debug.Log(hs.GetHealth());
            hs.Heal(35);
            Debug.Log(hs.GetHealth());
            hs.Damage(10);
            Debug.Log(hs.GetHealthPercentage());



            // healthBar.SetSize(.4f);
            // healthBar.SetColor(Color.green);
            // float health = 1f;
            // //function that is executed on a timer
            // FunctionPeriodic.Create(() => {
            //     if (health > .01f) {
            //         health -= .01f;
            //         healthBar.SetSize(health);
            //
            //         //create flashing annimation
            //         if (health < .3f) {
            //             if (Random.Range(1f, 10f) > 4f) {
            //                 healthBar.SetColor(Color.white);
            //             } else {
            //                 healthBar.SetColor(Color.red);
            //             }
            //         }
            //     }
            // }, .03f);
        }
Example #2
0
 public void HitPlayer(int damageAmount)
 {
     _healthSystem.Damage(damageAmount);
     HealthSystemUI.Instance.TakeDamage(damageAmount);
     if (_healthSystem.GetHealth() <= 0)
     {
         _gameManager.GameOver();
     }
 }
Example #3
0
 private void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.TryGetComponent <Projectile>(out var projectile))
     {
         _healthSystem.Damage(projectile.MagicInfo.Damage);
     }
     if (_healthSystem.GetHealth() <= 0)
     {
         var obj = Instantiate(vfxObject, transform.position, Quaternion.identity);
         pathfindingMovement.speed = 0;
         animator.SetTrigger(Death);
         Destroy(gameObject, 2.7f);
         Destroy(obj, 4f);
     }
 }