Пример #1
0
    // 受伤方法
    public void GetDamage(float damage)
    {
        if (healthyPoint <= 0)
        {
            return;
        }
        isHurt = true;
        anim.SetTrigger("hurt");
        healthyPoint -= damage;
        FlashColor();
        // 增加流血效果(试验,并不好看)
        //bloodEffect.transform.position = new Vector3(transform.position.x, transform.position.y + 1, -5);
        //Instantiate(bloodEffect);

        // 攻击时摄影机抖动效果(试验,效果并不好)
        //CameraShakeController.cameraShake.shake();

        if (healthyPoint <= 0)
        {
            if (enemyDropItemConfig != null)
            {
                Item item = DropItemUtil.RandomItem(enemyDropItemConfig.items);
                if (item != null)
                {
                    item.transform.position = new Vector3(transform.position.x, transform.position.y + 1, item.transform.position.z);
                    Instantiate(item);
                }
            }
            anim.SetTrigger("dead");
            //Destroy(gameObject);
        }
    }
Пример #2
0
    // 受伤方法
    public void GetDamage(float damage, string type)
    {
        FlashColor();
        if (type == "gun")
        {
            if (!canGunHurt)
            {
                return;
            }
            else
            {
                canGunHurt = false;
                StartCoroutine(NoHurtCountDown());
            }
        }
        AileHpManager.currentHp -= damage;

        if (AileHpManager.currentHp <= 0)
        {
            if (enemyDropItemConfig != null)
            {
                Item item = DropItemUtil.RandomItem(enemyDropItemConfig.items);
                if (item != null)
                {
                    item.transform.position = new Vector3(transform.position.x, transform.position.y + 1, item.transform.position.z);
                    Instantiate(item);
                }
            }
        }
    }