Exemple #1
0
        //进入战场
        public void EnterBattleField(BattleField battleField, GridUnit bornGrid)
        {
            if (battleField != null && bornGrid != null)
            {
                this.battleField = battleField;

                //设置敌方队伍
                enemyTeam = battleField.GetBattleTeam(this, false);

                //重置属性
                battleUnitAttribute.RandomAttributes();
                battleUnitAttribute.Reset();
                //重置bbsys
                battleBehaviourSystem.ResetSystem();

                EnterGrid(bornGrid);

                BattleUnitAction battleUnitAction = BattleUnitAction.Create(this);
                battleUnitAction.enterBattleFieldAction                         = BattleUnitEnterBattleFieldAction.Get();
                battleUnitAction.enterBattleFieldAction.bornGrid                = bornGrid;
                battleUnitAction.enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                battleUnitAction.enterBattleFieldAction.attribute.hpChanged     = 0;
                battleUnitAction.enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                battleUnitAction.enterBattleFieldAction.attribute.energyChanged = 0;
                battleUnitAction.enterBattleFieldAction.attribute.currentEnergy = 0;

                //创建进入战场的消息
                battleField.AppendBattleAction(battleUnitAction);

                //初始化战斗行为系统
                battleBehaviourSystem.Init(this, battleField);
            }
        }
Exemple #2
0
        //手动选择移动目标
        private void ManualMoveTo(GridUnit grid, GridUnit[] path)
        {
            //添加一个行动
            BattleUnitAction battleUnitAction = BattleUnitAction.Create(manualOperatingBattleUnitRenderer.battleUnit);

            //为行动添加移动数据
            manualOperatingBattleUnitRenderer.battleUnit.MoveToTargetGrid(battleUnitAction, null, grid, path);
            fieldRenderer.battleField.AppendBattleAction(battleUnitAction);
            fieldRenderer.PlayBattle(AfterManualMove);
        }
Exemple #3
0
        //手动释放技能(对具体的目标)
        private void ManualSkill(BattleUnit targetBattleUnit)
        {
            if (targetBattleUnit == null)
            {
                return;
            }

            //添加一个行动
            BattleUnitAction battleUnitAction = BattleUnitAction.Create(manualOperatingBattleUnitRenderer.battleUnit);

            //为行动添加技能释放数据
            manualOperatingBattleUnitRenderer.battleUnit.UseSkill(battleUnitAction, usedManualReleaseAnalysisor.battleSkill, targetBattleUnit);
            fieldRenderer.battleField.AppendBattleAction(battleUnitAction);

            //行动结束
            ManualOperationComplete();
        }
Exemple #4
0
        //手动释放技能(对具体的地块)
        private void ManualSkill(GridUnit targetGrid)
        {
            if (targetGrid == null)
            {
                return;
            }

            //添加一个行动
            BattleUnitAction battleUnitAction = BattleUnitAction.Create(manualOperatingBattleUnitRenderer.battleUnit);

            manualOperatingBattleUnitRenderer.battleUnit.UseSkill(battleUnitAction, usedManualReleaseAnalysisor.battleSkill, null, targetGrid);
            fieldRenderer.battleField.AppendBattleAction(battleUnitAction);

            //取消范围高亮显示
            SetCircularRangeRenderStateActive(false, GridRenderType.SkillReleaseRange);
            SetCircularRangeRenderStateActive(false, GridRenderType.SkillEffectRange);

            //行动结束
            ManualOperationComplete();
        }
Exemple #5
0
        /// <summary>
        /// 战斗单位动作的顺序是,移动->攻击
        /// </summary>
        /// <param name="heroActions"></param>
        /// <returns></returns>
        public HeroActionState BattleAction()
        {
            BattleUnitAction battleUnitAction = BattleUnitAction.Create(this);

            battleField.AppendBattleAction(battleUnitAction);

            //恢复能量
            RecoverEnergy(battleUnitAction);
            //冷静
            battleBehaviourSystem.RageLevelCooldown();

            //手动
            if (battleUnitAttribute.manualOperation)
            {
                return(ManualAction(battleUnitAction));
            }
            //自动
            else
            {
                return(AutoAction(battleUnitAction));
            }
        }
Exemple #6
0
        //开始战斗
        private void Fight()
        {
            battleState = BattleState.Fighting;

            BattleUnit actionUnit = null;

            do
            {
                //连接渲染器,则一步一更新
                //没有连接渲染器,则一直计算直到结束
                actionUnit = actionQueue.Dequeue();

                if (actionUnit == null)
                {
                    battleState = BattleState.End;
                    break;
                }

                if (actionUnit.CanAction)
                {
                    BattleUnitAction battleUnitAction = BattleUnitAction.Create(actionUnit);

                    HeroActionState state = actionUnit.BattleAction();

                    switch (state)
                    {
                    case HeroActionState.Normal:
                        battleState = BattleState.Fighting;
                        break;

                    case HeroActionState.WaitForPlayerChoose:
                        battleState = BattleState.WaitForPlayer;
                        break;

                    case HeroActionState.Error:
                        battleState = BattleState.Exception;
                        break;

                    case HeroActionState.Warn:
                        battleState = BattleState.Exception;
                        UtilityHelper.LogWarning(string.Format("Warning: battle action state warning -> {0}", actionUnit.ToString()));
                        break;

                    default:
                        break;
                    }
                }

                //考虑是否在放回队列
                CalculateNextAction(actionUnit);

                if (battleActions.Count > EGameConstL.BattleFieldMaxActions)
                {
                    UtilityHelper.LogError("Battle actions overflow max limit.");
                    battleState = BattleState.Exception;
                }
                else
                {
                    //只在这种情况下做战斗结束的判断
                    if (!actionUnit.CanAction ||
                        actionUnit.targetBattleUnit == null ||
                        !actionUnit.targetBattleUnit.CanAction)
                    {
                        CheckBattleEnd();
                    }
                }
            } while (battleFieldRenderer == null &&
                     battleState != BattleState.End &&
                     battleState != BattleState.Exception);

            //连接了渲染器,一步一表现
            if (battleFieldRenderer != null)
            {
                if (battleState == BattleState.WaitForPlayer)
                {
                    battleFieldRenderer.PlayBattle(null);
                }

                else
                {
                    battleFieldRenderer.PlayBattle(Run);
                }
            }
            else
            {
                Run();
            }
        }