// Use this for initialization void Start() { mc = this.GetComponent <monsterControl>(); ms = this.GetComponent <MonsterStatus>(); ms.onMonsterHurtHandler += angryAttacker; if (!ms.isBoss) { mc.onMonsterHitBlockHandler += cancelAngry; } this.Invoke("doWalk", 3f); }
public void angryAttacker(GameObject tar) { if (!GameObject.ReferenceEquals(tar, target)) { mc = this.GetComponent <monsterControl>(); ms = this.GetComponent <MonsterStatus>(); this.target = tar; this.angry = true; this.mc.stopWalking(); this.mc.follow(tar); // add Cancel Angry to onPlayerDieHandler PlayerStatus.Instance.onPlayerDieHandler += this.cancelAngry; ms.onMonsterDieHandler += () => { this.CancelInvoke("doWalk"); PlayerStatus.Instance.onPlayerDieHandler -= this.cancelAngry; };// add Cancel Angry to onMonsterDieHandler } this.CancelInvoke("doWalk"); }