protected override void OnDamage(Damage damage, InteractiveObj source) { base.OnDamage(damage, source); Role.PlayAction(Role.strDamageAnimName, 0.1f); if (!ForceTarget && !IsForceMove && source && source != WorldInteractObj.Instance) { CurrentTarget = source; OnFightBegin.Invoke(); ChaseTarget(); } }
protected virtual void OnUpdate(float deltaTime) { bool haveTarget = CurrentTarget; if (ForceTarget && ForceTarget.IsAlive && ForceTarget.transform.position.SqrDistanceWith(transform.position) <= fAttackMaxRange * fAttackMaxRange) { CurrentTarget = ForceTarget; } else if (IsFindNextEnemy()) { CurrentTarget = FindNextEnemy(); } if (CurrentSkill && CurrentSkill.IsWorking && CurrentSkill.IsForbidOtherSkills) { return; } for (int i = 0, length = listSkills.Count; i < length; ++i) { if (CanCastSkill(listSkills[i]) && listSkills[i].Execute(CurrentTarget) == SkillBase.CastResult.Success) { CurrentSkill = listSkills[i]; OnAttackTarget(); if (CurrentSkill.IsForbidOtherSkills) { break; } } } if (!haveTarget && CurrentTarget) { OnFightBegin.Invoke(); } else if (haveTarget && !CurrentTarget) { OnFightOver.Invoke(); } }