public override void Update() { Actor.Cmd cmd = Owner.CurrentCmd; if (cmd != null) { switch (cmd.m_type) { case Actor.ENCmdType.enMove: { if (ActionMoveTo(cmd.m_moveTargetPos, true, false, cmd.IsSyncPosValidate, cmd.m_syncPos)) { Owner.CurrentCmd = null; } } break; case Actor.ENCmdType.enSkill: { Owner.CurrentTarget = ActorManager.Singleton.Lookup(cmd.m_targetID); //ActionForwardTo(cmd.m_targetID); if (ActionTryAttack(cmd.m_skillID, Owner.CurrentTarget, cmd.IsSyncPosValidate, cmd.m_syncPos)) { Owner.CurrentCmd = null; } else { ActionForwardTo(cmd.m_targetID); } } break; case Actor.ENCmdType.enRoll: { RollAction rollAction = Owner.ActionControl.AddAction(ActorAction.ENType.enRollAction) as RollAction; if (rollAction != null) { rollAction.Init(Owner.CurrentCmd.m_syncPos, cmd.m_moveTargetPos); Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enActorEnter: { Player player = Owner as Player; if (player != null) { if (player.SwitchActorEnter(cmd.m_syncPos, cmd.m_forward)) { Owner.CurrentCmd = null; } } else { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enActorExit: { Owner.IsActorExit = true; ActorExitAction actorExitAction = Owner.ActionControl.AddAction(ActorAction.ENType.enActorExitAction) as ActorExitAction; if (actorExitAction != null) { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enInteruptAction: { Owner.ActionControl.InterruptAction((ActorAction.ENType)cmd.m_interruptedActionType); Owner.CurrentCmd = null; break; } case Actor.ENCmdType.enBeHitAction: { BeAttackAction beAttackAction = Owner.ActionControl.AddAction(ActorAction.ENType.enBeAttackAction) as BeAttackAction; if (beAttackAction != null) { Actor srcActor = ActorManager.Singleton.Lookup(cmd.m_srcActorID); beAttackAction.Init(srcActor, cmd.m_isBack, cmd.m_isFly); Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enJumpInAction: { Owner.CurrentTarget = ActorManager.Singleton.Lookup(cmd.m_targetID); JumpinAction jumpInAction = Owner.ActionControl.AddAction(ActorAction.ENType.enJumpinAction) as JumpinAction; if (jumpInAction != null) { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enJumpOutAction: { JumpoutAction jumpOutAction = Owner.ActionControl.AddAction(ActorAction.ENType.enJumpoutAction) as JumpoutAction; if (jumpOutAction != null) { Owner.CurrentCmd = null; } break; } case Actor.ENCmdType.enAttackingMoveAction: { AttackingMoveAction action = Owner.ActionControl.AddAction(ActorAction.ENType.enAttackingMoveAction) as AttackingMoveAction; if (action != null) { action.InitImpl(Owner.CurrentCmd.m_skillID, Owner.CurrentCmd.m_targetID, cmd.IsSyncPosValidate, cmd.m_syncPos); Owner.CurrentCmd = null; } } break; } } }
public override void Update() { base.Update(); if (Self.IsActorExit) { return; //当前角色离场 } //TimeToRelive(); ReliveUI(); #region Unlock if (!Self.CurrentTargetIsDead) {//判断距离 清除目标 float distance = ActorTargetManager.GetTargetDistance(Self.MainPos, Self.CurrentTarget.MainPos); if (distance > Self.CurrentTableInfo.UnlockRange) { Self.CurrentTarget = null; Self.DamageSource = null; } } #endregion CheckAllSkill(); //检测可释放技能 if (Self.CurrentCmd == null) { //当前没有命令 MoveAction action = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if ((action == null || action.IsStopMove) && !Self.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction) && !Self.ActionControl.IsActionRunning(ActorAction.ENType.enRollAction)) { //不在移动、攻击、翻滚等位移动作中 if (!Self.CurrentTargetIsDead) { //当前目标没死 float distance = ActorTargetManager.GetTargetDistance(Self.RealPos, Self.CurrentTarget.RealPos); if (Self.CurrentTableInfo.AutoAttackRange > distance) {//当前目标在自动攻击范围内 //Self.FireNormalSkill(); return; } } else { if (m_isAutoAttack) { m_autoAttackInterval -= Time.deltaTime; if (m_autoAttackInterval < 0) { GetRangeTargetList(ENTargetType.enEnemy, Self.CurrentTableInfo.AutoAttackRange); if (m_targetIDList.Count > 0) { Self.TargetManager.CurrentTarget = m_minActor; Self.CurrentCmd = new Player.Cmd(Player.ENCmdType.enLoopNormalAttack); Self.CurrentCmd.m_skillID = Self.NormalSkillList[0]; return; } } } } //自动反击 if (m_lastActionTime == 0) { m_lastActionTime = Time.time; } if (!m_isCounterattack && Time.time - m_lastActionTime > GameSettings.Singleton.m_autoCounterattack) {//距离最后一次位移动作 已超过3秒 可以反击 m_isCounterattack = false; } } if (m_isCounterattack) {//可以反击 if (Self.DamageTime > m_lastActionTime + GameSettings.Singleton.m_autoCounterattack) { if (Self.DamageSource != null && !Self.DamageSource.IsDead && ActorTargetManager.IsEnemy(Self, Self.DamageSource)) { if (m_counterSkillRange == 0) { SkillInfo info = GameTable.SkillTableAsset.Lookup(Self.NormalSkillList[0]); m_counterSkillRange = info.AttackDistance; } Vector3 distance = Owner.RealPos - Self.DamageSource.RealPos; distance.y = 0; if (distance.magnitude > m_counterSkillRange) {//不在攻击范围内 //向技能目标移动 ActionMoveTo(Self.DamageSource.RealPos); } else {//在攻击范围内 //释放技能 if (ActionTryAttack(Self.NormalSkillList[0], Self.DamageSource)) { m_curTargetID = Self.DamageSource.ID; Self.CurrentTarget = ActorManager.Singleton.Lookup(m_curTargetID); m_lastActionTime = 0; m_isCounterattack = false; return; } } } } } } else { MainPlayer.Cmd cmd = Self.CurrentCmd; if (cmd.m_type != Player.ENCmdType.enSkill && cmd.m_type != Player.ENCmdType.enLoopNormalAttack) {//取消自动攻击 m_isAutoAttack = false; } //最后一次动作的时间 m_lastActionTime = 0; //清除自动反击 m_isCounterattack = false; if (cmd.m_type != Player.ENCmdType.enSkill) {//取消技能高亮 DelSkillHighlight(); } m_autoAttackInterval = GameSettings.Singleton.m_autoAttackInterval; if (!IsCmdExecute()) {//命令不允许执行 Self.CurrentCmd = null; return; } m_curTargetID = 0; if (!Self.CurrentTargetIsDead) { m_curTargetID = Self.CurrentTarget.ID; } switch (cmd.m_type) { case Player.ENCmdType.enMove: { // [8/3/2015 tgame] if (cmd.m_isMoveByNoAStar) { if (ActionMoveToNotAStar(cmd.m_moveTargetPos)) { //点击地面特效 Self.IsMoveAfterSwitch = false; Self.CurrentCmd = null; } } else { if (ActionMoveTo(cmd.m_moveTargetPos)) { //点击地面特效 Self.IsMoveAfterSwitch = false; Self.CurrentCmd = null; } } } break; case Player.ENCmdType.enStopMove: { MoveAction ac = Self.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (ac != null) { Self.ActionControl.RemoveAction(ActorAction.ENType.enMoveAction); } } break; case Player.ENCmdType.enRoll: { RollAction rollAction = Self.ActionControl.AddAction(ActorAction.ENType.enRollAction) as RollAction; if (rollAction != null) { rollAction.Init(cmd.m_moveTargetPos); Self.CurrentCmd = null; } } break; case Player.ENCmdType.enSwitchActor: { if (!m_isAttacking) { if (Self.ActionControl.IsActionRunning(ActorAction.ENType.enAttackAction)) { if (ActorManager.Singleton.m_switchCDTotal > 0) { //cd中,继续攻击 Self.FireNormalSkill(); return; } m_isAttacking = true; } } if (ActorManager.Singleton.SwitchMainActor(false, m_isAttacking)) { Self.CurrentCmd = null; m_isAttacking = false; } } break; case Player.ENCmdType.enSkill: { int skillID = cmd.m_skillID; Actor.ActorSkillInfo info = Self.SkillBag.Find(item => item.SkillTableInfo.ID == skillID); if (IsFireSkill(skillID)) { GetRangeTargetList((ENTargetType)info.SkillTableInfo.TargetType, Self.CurrentTableInfo.AttackRange, Self.m_firstTargetType); if (ActionTryFireSkill(skillID)) { m_isAutoAttack = false; m_lastSkillID = skillID; DelSkillHighlight(); Actor target = ActorManager.Singleton.Lookup(m_curTargetID); if (target != null && ActorTargetManager.IsEnemy(Self, target)) { //只对仇人进行循环普攻 Self.CurrentTarget = target; Self.CurrentCmd.m_skillID = Self.NormalSkillList[0]; Self.CurrentCmd.m_type = Player.ENCmdType.enStop; //enLoopNormalAttack; } else { Self.CurrentCmd = null; } } else { if (m_targetIDList.Count == 0) { DelSkillHighlight(); Self.CurrentCmd = null; } } } else { GetRangeTargetList((ENTargetType)info.SkillTableInfo.TargetType, Self.CurrentTableInfo.AttackRange); if (m_targetIDList.Count != 0 && skillID != m_highlightSkillID) { //技能高亮的通知 AddSkillHighlight(); m_highlightSkillID = skillID; } } } break; case Player.ENCmdType.enLoopNormalAttack: { int skillID = Self.CurrentCmd.m_skillID; if (Self.CurrentTargetIsDead) { //循环攻击时 必须要有目标 目标不能死亡 Self.CurrentCmd = null; return; } if (IsFireSkill(skillID)) { if (ActionTryFireSkill(skillID)) { m_lastSkillID = skillID; } } } break; default: break; } } }