示例#1
0
        public override void Damage(float amount)
        {
            if (!vulnerable)
            {
                return;
            }
            base.Damage(amount);
            //score decrease
            actualScore  = Mathf.Clamp(actualScore - 5, 0, 999999);
            CurrentScore = Mathf.RoundToInt(actualScore);
            //yeet
            Message <ScoreMultiplierChanged> .Raise(new ScoreMultiplierChanged(1.0f, 1f - scoreMultiplier));

            scoreMultiplier = 1.0f;
            gotDamage       = true;

            var dmg = new PlayerDamaged
            {
                newHealth = currentHealth,
                damage    = amount
            };

            Message <PlayerDamaged> .Raise(dmg);

            GameManager.PlaySFX(hitSound);
            StartCoroutine(DoInvulnerab());
            IEnumerator DoInvulnerab()
            {
                vulnerable = false;
                yield return(new WaitForSeconds(invulTime));

                vulnerable = true;
            }
        }
示例#2
0
 void OnPlayerDamaged(PlayerDamaged dmg)
 {
     if (dmg.newHealth > 0)
     {
         if (dmg.damage >= dmgShakeThreshold)
         {
             StopAllCoroutines();
             offset = Vector3.zero;
             StartCoroutine(DoShake());
         }
     }
 }
示例#3
0
 void UpdateSlider(PlayerDamaged dmg)
 {
     healthSlider.value = dmg.newHealth;
     //print("update slider:" + dmg.newHealth);
 }