//攻击目标 bool AttackTarget() { if (Self.ActionControl.IsActionRunning(AttackAction.SGetActionType())) { return(false); } if (!Self.CurrentTargetIsDead) { m_curTargetID = Self.CurrentTarget.ID; if (!m_targetIDList.Contains(m_curTargetID)) { m_targetIDList.Add(m_curTargetID); } if (FireFinalSkill()) {//释放终结技 ; } else if (FireConnectOrSpecialSkill()) {//释放连接技或特殊技 ; } else {//释放普攻 FireNormalSkill(); } return(true); } return(false); }
public bool ActionTryFireSkill(int skillID) { if (skillID == 0) { //自动查找技能 if (Owner.ActionControl.IsActionRunning(AttackAction.SGetActionType())) { //正在攻击,暂时返回 return(false); } } int skillIDForTarget = 0; Actor skillTarget = null; if (!LookupSkill(skillID, out skillIDForTarget, out skillTarget)) { //Debug.LogWarning("LookupSkill failed! id is " + skillIDForTarget.ToString() + " self id is "+Owner.ID.ToString()); return(false); } Actor.ActorSkillInfo info = Owner.SkillBag.Find(item => item.SkillTableInfo.ID == skillIDForTarget); if (info == null) { Debug.LogWarning("skill id is not exist! id is " + skillIDForTarget.ToString() + " self id is " + Owner.ID.ToString()); return(false); } if (skillID == 0 && Owner.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction)) {//攻击中并且不是技能命令, 不释放 return(false); } if (skillTarget == null) {//无目标技能 //释放技能 return(ActionTryAttack(skillIDForTarget, skillTarget)); } else { Vector3 distance = Owner.RealPos - skillTarget.RealPos; distance.y = 0; if (distance.magnitude > info.SkillTableInfo.AttackDistance) {//不在攻击范围内 //向技能目标移动 ActionMoveTo(skillTarget.RealPos); } else {//在攻击范围内 //释放技能 if (ActionTryAttack(skillIDForTarget, skillTarget)) { m_curTargetID = skillTarget.ID; return(true); } } } return(false); }
//攻击中,开始旋转 //void StartRotate(AnimationEvent animEvent) //{ // ActorProp selfProp = transform.parent.GetComponent<ActorProp>(); // if (null == selfProp) // { // Debug.LogWarning("StopAction return, actorProp get failed"); // return; // } // Actor self = selfProp.ActorLogicObj; // if (null != self && !self.IsDead) // { // AttackAction action = self.ActionControl.LookupAction(AttackAction.SGetActionType()) as AttackAction; // if (action != null) // { // action.StartRotate(animEvent.floatParameter); // } // } //} //立即结束攻击动作 void TerminateAttackAction(AnimationEvent animEvent) { ActorProp selfProp = transform.parent.GetComponent <ActorProp>(); if (null == selfProp) { Debug.LogWarning("StopAction return, actorProp get failed"); return; } Actor self = selfProp.ActorLogicObj; if (null != self && !self.IsDead) { AttackAction action = self.ActionControl.LookupAction(AttackAction.SGetActionType()) as AttackAction; if (action != null) { action.IsFinished = true; } } }