Пример #1
0
        public void StartBattle()
        {
            mCamps[Consts.CAMP_PLAYER] = new BattleCamp();
            mCamps[Consts.CAMP_ENEMY]  = new BattleCamp();

            //初始化玩家阵营
            BattleCamp           camp       = mCamps[Consts.CAMP_PLAYER];
            BattleInfoController controller = camp.BattleInfoController;
            BattleFields         info       = controller.Info;

            InitPlayerTeam(ref camp);

            controller.AddListener(Consts.N_INTELLIGENTAL_UPDATE, OnPlayerBattleInfoEventHandler);
            controller.AddListener(Consts.N_INTELLIGENTAL_FINISHED, OnPlayerBattleInfoEventHandler);
            controller.Dispatch(Consts.N_START_COLLECT_INTELLIGENTAL);

            //初始化敌军阵营
            camp       = mCamps[Consts.CAMP_ENEMY];
            controller = camp.BattleInfoController;
            info       = controller.Info;

            BattleHeroController heroContorller;
            int max = Consts.CAMP_HERO_MAX;

            for (int i = 0; i < max; i++)
            {
                heroContorller = new BattleHeroController(new HeroFields());
                //heroContorller.Info.SetIntData(Consts.FN_ID, id);
                camp.SetCampHero(i, heroContorller);
            }

            controller.AddListener(Consts.N_INTELLIGENTAL_UPDATE, OnEnemyBattleInfoEventHandler);
            controller.AddListener(Consts.N_INTELLIGENTAL_FINISHED, OnEnemyBattleInfoEventHandler);
            controller.Dispatch(Consts.N_START_COLLECT_INTELLIGENTAL);
        }
Пример #2
0
        private void InitPlayerTeam(ref BattleCamp camp)
        {
            PlayerData        playerData  = Consts.D_PLAYER.GetData <PlayerData>();
            List <HeroFields> playerHeros = playerData.Heros.GetTeamHeros();

            int n   = playerHeros.Count;
            int max = Consts.CAMP_HERO_MAX;

            for (int i = 0; i < max; i++)
            {
                HeroFields copy = new HeroFields();
                if (i < n)
                {
                    HeroFields hero = playerHeros[i];
                    hero.CopyToFields(ref copy);

                    BattleHeroController heroContorller = new BattleHeroController(copy);
                    camp.SetCampHero(i, heroContorller);
                }
                else
                {
                }
            }

            BattleFields battleFields = camp.BattleInfoController.Info;
            int          troops       = battleFields.GetIntData(Consts.FN_TROOPS);
            int          troopsMax    = battleFields.GetIntData(Consts.FN_TROOPS_MAX);

            "log:Player troops is {0}/{1}".Log(troops.ToString(), troopsMax.ToString());
            "log:Player intelligential is {0}".Log(battleFields.GetFloatData(Consts.FN_INTELLIGENTIAL).ToString());
            "log:Player intelligential delta is {0}".Log(battleFields.GetFloatData(Consts.FN_INTELLIGENTIAL_DELTA).ToString());
        }