Example #1
0
 //离开战场
 public void LeaveBattleField()
 {
     if (battleField != null)
     {
         for (int i = 0; i < battleUnits.Count; i++)
         {
             battleUnits[i].LeaveBattleField();
         }
         battleField = null;
     }
 }
        //战场连接
        public void OnConnect(BattleField field)
        {
            battleField = field;
            //加载战场
            RefreshBattleMapGrids();
            //加载战斗单位
            RefreshBattleUnits();

            EventManager.Instance.Register(EGameConstL.EVENT_BATTLE_UNIT_USE_ITEM,
                                           this.gameObject.RequestorSTR(),
                                           OnBattleUnitUseItem);
        }
Example #3
0
        public void RunManualTest()
        {
            //创建战斗(数据)
            singleBattle = BattleFieldCreator.Instance.Create(
                mapSize.x, mapSize.y,
                obstacleCount, obstacleGap, buffCount, itemCount,
                teamA, teamB);

            //重置相机和尺寸
            ResetBattleCamera();

            singleBattle.ConnectRenderer(BattleFieldRenderer.Instance);

            singleBattle.Run();
        }
Example #4
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();

                //创建背包
                if (package == null)
                {
                    package = BattleUnitPackage.CreateInstance(this, 2);
                }

                package.Clear();

                //进入战场
                BattleUnitEnterBattleFieldAction enterBattleFieldAction = BattleUnitActionEvent.CreateEvent <BattleUnitEnterBattleFieldAction>(BattleUnitActionType.EnterBattleField, this);
                enterBattleFieldAction.battleField             = battleField;
                enterBattleFieldAction.bornGrid                = bornGrid;
                enterBattleFieldAction.attribute               = new BattleUnitSyncAttribute();
                enterBattleFieldAction.attribute.hpChanged     = 0;
                enterBattleFieldAction.attribute.currentHP     = battleUnitAttribute.hp;
                enterBattleFieldAction.attribute.energyChanged = 0;
                enterBattleFieldAction.attribute.currentEnergy = 0;
                battleField.AppendBattleAction(enterBattleFieldAction);

                //进入格子
                EnterGrid(bornGrid);

                //初始化战斗行为系统
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.Init(this, battleField);
                }

                //重置bbsys
                if (battleBehaviourSystem != null)
                {
                    battleBehaviourSystem.ResetSystem();
                }
            }
        }
Example #5
0
        private IEnumerator RunTest()
        {
            //创建战斗(数据)
            singleBattle = BattleFieldCreator.Instance.Create(
                mapSize.x, mapSize.y,
                obstacleCount, obstacleGap, buffCount, itemCount,
                teamA, teamB);

            ResetBattleCamera();

            singleBattle.ConnectRenderer(BattleFieldRenderer.Instance);

            for (int i = 0; i < battleTestCount; ++i)
            {
#if UNITY_EDITOR
                UnityEditor.EditorUtility.DisplayProgressBar("战斗计算", string.Format("战斗场次计算进度 {0}/{1}", i + 1, battleTestCount), (i + 1) * 1f / battleTestCount);
#endif

                singleBattle.ResetBattle();

                singleBattle.Run();

                //如果运算出现问题,播放一下有问题的场
                if (singleBattle.battleState == BattleState.Exception)
                {
                    singleBattle.ConnectRenderer(BattleFieldRenderer.Instance);
                    BattleFieldRenderer.Instance.PlayBattle(null);
                    yield return(EGameConstL.WaitForTouchScreen);
                }

                yield return(null);
            }
#if UNITY_EDITOR
            UnityEditor.EditorUtility.ClearProgressBar();
#endif
        }