Exemplo n.º 1
0
        //自动
        private HeroActionState AutoAction(BattleUnitAction battleUnitAction)
        {
            BattleBehaviourSystem.BattleDecision decision = battleBehaviourSystem.Think();

            if (decision == null)
            {
                battleUnitAction.warningAction            = BattleUnitWarningAction.Get();
                battleUnitAction.warningAction.logWarning = "No target:" + ID;
                return(HeroActionState.Normal);
            }

            //判断是否切换目标
            if (decision.targetBattleUnit != null && !decision.targetBattleUnit.Equals(targetBattleUnit))
            {
                battleUnitAction.changeTargetAction = BattleUnitChangeTargetAction.Get();
                battleUnitAction.changeTargetAction.lastTargetUnit = targetBattleUnit;
                battleUnitAction.changeTargetAction.newTargetUnit  = decision.targetBattleUnit;
                targetBattleUnit = decision.targetBattleUnit;
            }

            //需要移动
            if (decision.movePath != null && decision.movePath.Length > 0)
            {
                MoveToTargetGrid(battleUnitAction, targetBattleUnit, decision.movePath[decision.movePath.Length - 1], decision.movePath);
            }

            //自动搓招儿
            AutoUseSkill(battleUnitAction, decision);

            return(HeroActionState.Normal);
        }
Exemplo n.º 2
0
        //自动
        private HeroActionState AutoAction()
        {
            BattleBehaviourSystem.BattleDecision decision = battleBehaviourSystem.Think();

            if (decision == null)
            {
                BattleUnitWarningAction warningAction = BattleUnitActionEvent.CreateEvent <BattleUnitWarningAction>(BattleUnitActionType.Warning, this);
                battleField.AppendBattleAction(warningAction);
                warningAction.warningLog = "No target:" + ID;
                return(HeroActionState.Normal);
            }

            //判断是否切换目标
            if (decision.targetBattleUnit != null && !decision.targetBattleUnit.Equals(targetBattleUnit))
            {
                BattleUnitChangeTargetAction action = BattleUnitActionEvent.CreateEvent <BattleUnitChangeTargetAction>(BattleUnitActionType.ChangeTarget, this);
                action.lastTargetUnit = targetBattleUnit;
                action.newTargetUnit  = decision.targetBattleUnit;
                battleField.AppendBattleAction(action);

                targetBattleUnit = decision.targetBattleUnit;
            }

            //需要移动
            if (decision.movePath != null && decision.movePath.Length > 0)
            {
                MoveToTargetGrid(targetBattleUnit, decision.movePath[decision.movePath.Length - 1], decision.movePath);
            }

            //自动搓招儿
            AutoUseSkill(decision);

            return(HeroActionState.Normal);
        }
Exemplo n.º 3
0
        //切换目标
        private IEnumerator PlayChangeTargetAction(BattleUnitChangeTargetAction action)
        {
            if (action == null)
            {
                UtilityHelper.LogError("Error BattleHeroChangeTargetAction");
                yield break;
            }

            UpdateRenderState(BattleUnitRenderState.Action);
            action.newTargetUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Selected);

            yield return(EGameConstL.WaitForHalfSecond);

            UpdateRenderState(BattleUnitRenderState.Normal);
            action.newTargetUnit.battleUnitRenderer.UpdateRenderState(BattleUnitRenderState.Normal);
        }
Exemplo n.º 4
0
        //自动选择目标
        private void AutoSelectTarget(BattleUnitAction battleUnitAction)
        {
            int stopDistance = SkillStopDistance;
            //从仇恨列表中确定目标
            BattleUnit hatredUnit = null;

            //按照仇恨列表获取目标
            for (int i = 0; i < hatredRecorder.HatredCount; ++i)
            {
                hatredUnit = hatredRecorder.GetHatredByIdx(i, i == 0);
                if (!hatredUnit.CanAction)
                {
                    //已经排序过了,找到不能行动的单位,就表示没有单位可以行动了
                    hatredUnit = null;
                    break;
                }

                //判断这个单位是否可以到达
                bool catched = false;
                //如果这个单位就在身边
                if (mapGrid.Distance(hatredUnit.mapGrid) <= stopDistance)
                {
                    toTargetPath.Clear();
                    catched = true;
                }
                else
                {
                    catched = MapNavigator.Instance.Navigate(
                        battleField.battleMap,
                        mapGrid,
                        hatredUnit.mapGrid,
                        toTargetPath,
                        null,
                        battleUnitAttribute.mobility,
                        stopDistance
                        );
                }

                //寻路不可达
                if (!catched)
                {
                    hatredUnit = null;
                    continue;
                }
                //找到了
                else
                {
                    break;
                }
            }

            //没有目标
            if (hatredUnit == null)
            {
                targetBattleUnit = null;
                return;
            }

            //判断是否切换目标
            if (battleUnitAction != null && !hatredUnit.Equals(targetBattleUnit))
            {
                battleUnitAction.changeTargetAction = BattleUnitChangeTargetAction.Get();
                battleUnitAction.changeTargetAction.lastTargetUnit = targetBattleUnit;
                battleUnitAction.changeTargetAction.newTargetUnit  = hatredUnit;
                targetBattleUnit = hatredUnit;
            }
        }