public void HurtByDamagePerSec(int damagePerSec, DamageFrom attacker)
 {
     _hurtPerSecTimer += Time.deltaTime;
     if (_hurtPerSecTimer > 1f)
     {
         _hurtPerSecTimer -= 1f;
         Hurt(damagePerSec, attacker);
     }
 }
 public void Die(DamageFrom attacker)
 {
     playerInfo.isDead = true;
     //死亡过程硬编码
     _rigidbody.constraints = RigidbodyConstraints.None;                                                                  //取消限制 自由倒地
     _rigidbody.AddForce(Vector3.up * (-1f) + Vector3.right * (-2f), ForceMode.Impulse);                                  //推一把
     this.enabled = false;
     Instantiate(ParticleSystem_Death, _transform.position + Vector3.up * 0.2f, ParticleSystem_Death.transform.rotation); // 例子效果 黑暗之门
     if (OnPlayerDie != null)
     {
         OnPlayerDie(attacker);
     }
     LevelManager.singleton.PlayerDie();
 }
    public void Hurt(int damage, DamageFrom attacker)
    {
        if (playerInfo.isDead)
        {
            return;
        }

        playerInfo.hp -= damage;
        if (playerInfo.hp <= 0)
        {
            playerInfo.hp = 0;
            Die(attacker);
        }
    }
    void _OnPlayerDie(DamageFrom attacker)
    {
        switch (attacker)
        {
        case DamageFrom.Cold:
            wordsOfDeath.text = wordsDieOfCold;
            break;

        case DamageFrom.Enemy:
            wordsOfDeath.text = wordsDieOfEnemy;
            break;

        case DamageFrom.Fire:
            wordsOfDeath.text = wordsDieOfFire;
            break;
        }
    }