//被玩家子弹攻击 受到伤害血量计算 特效 音效等 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); } }
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(); }
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); } }
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); } }