Esempio n. 1
0
    // 当玩家被攻击时,激活hit动画,生命扣除,检测是否生命值为0从而结束游戏
    public void loseFood(AttackInfo attackInfo, Enemy enemy)
    {
        animator.SetTrigger("PlayerHit");
        Debug.Log("player lose hp, current hp: " + playerAttributes.hp + ", damage: " + attackInfo.damage);
        foodText.text = "-" + attackInfo.damage + ", Food: " + playerAttributes.hp;
        if (playerAttributes.hp < 0)
        {
            Debug.Log("GameOver");
            SoundManager.instance.PlaySingle(gameOverSound);
            SoundManager.instance.musicSource.Stop();
            GameController.instance.GameOver();
        }

        // 创建并显示伤害值UI
        Debug.Log(transform.position);


        DamagePopup.show(popupDamage, enemy.transform.position, transform.position, attackInfo);
    }