Esempio n. 1
0
    //被玩家子弹攻击 受到伤害血量计算 特效 音效等 TODO
    public void BeingAttack(GameObject bullet)
    {
        if (BeAttackBullet.Contains(bullet))
        {
            return;
        }
        BeAttackBullet.Add(bullet);
        if (!Active)
        {
            AudioManager.Instance.PlaySound("HitWall");
            if (Active = AttackToActive)
            {
                StartCoroutine(GetComponent <EnemyAI>().StartActive());
            }
            return;
        }
        PlayerManager.Instance.ComboAdd();
        EffectManager.Instance.CameraShake(0.2f, 0.3f);
        AudioManager.Instance.PlaySound("HitEnemy");
        //if (health < 0) return;
        health -= bullet.GetComponent <PlayerBullet>().damage;
        Vector3 shootin = bullet.GetComponent <Rigidbody2D>().velocity;

        shootin.z = 0;
        GetComponent <Move>().AddForceSpeed(shootin.normalized * HitForce, 0, ForceDecline);
        if (health <= 0)
        {
            GoDie();
        }
        else
        {
            Statics.AnimatorPlay(this, animator, Statics.AnimatorType.Attack);
        }
    }
Esempio n. 2
0
 public void Hurt()
 {
     Statics.AnimatorPlay(this, EdgeAnimator, Statics.AnimatorType.Attack);
     Statics.AnimatorPlay(this, HeartAnimator, Statics.AnimatorType.Attack);
     EffectManager.Instance.CameraShake(0.5f, 0.5f);
     UIManager.Instance.BloodFlash();
 }
Esempio n. 3
0
 public void GoDie()
 {
     if (GoastAfterDie && !isGoast)
     {
         health = maxHealth;
         BecomeGoast();
     }
     else
     {
         health             = -1;
         m_collider.enabled = false;
         AudioManager.Instance.PlaySound("EnemyDie");
         Statics.AnimatorPlay(this, animator, Statics.AnimatorType.Die);
         Destroy(gameObject, dietime);
     }
 }
Esempio n. 4
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     Debug.Log(collision.collider.gameObject.tag);
     if (collision.collider.gameObject.tag == "PlayerHeart" && health > 0)
     {
         AttackHeart();
     }
     if (collision.collider.gameObject.tag == "PlayerEdge" && health > 0)
     {
         AttackPlayer();
     }
     if (collision.collider.gameObject.tag == "Wall" && health > 0 && HitWallDie)
     {
         Statics.AnimatorPlay(this, animator, Statics.AnimatorType.Die);
         health             = -1;
         m_collider.enabled = false;
         Destroy(gameObject, dietime);
     }
 }