示例#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());
        }
示例#3
0
        public List <BattleHeroController> GetIdleBattleHeros(int campType)
        {
            BattleCamp camp = GetCamp(campType);
            List <BattleHeroController> result = new List <BattleHeroController>();

            camp.FillIdleBattleHeros(ref result);
            return(result);
        }
示例#4
0
        public Vector2Int CurrentTroops(int campType)
        {
            BattleCamp   camp   = GetCamp(campType);
            BattleFields fields = camp.BattleInfoController.Info;
            int          cur    = fields.GetIntData(Consts.FN_TROOPS);
            int          max    = fields.GetIntData(Consts.FN_TROOPS_MAX);

            return(new Vector2Int(cur, max));
        }
示例#5
0
        public Vector2 CurrentMorale(int campType)
        {
            BattleCamp   camp   = GetCamp(campType);
            BattleFields fields = camp.BattleInfoController.Info;
            float        cur    = fields.GetFloatData(Consts.FN_MORALE);
            float        max    = fields.GetFloatData(Consts.FN_MORALE_MAX);

            return(new Vector2(cur, max));
        }
示例#6
0
        /// <summary>
        /// 当前玩家情报
        /// </summary>
        /// <returns></returns>
        public Vector2 CurrentPlayerIntelligental()
        {
            BattleCamp   camp = GetCamp(Consts.CAMP_PLAYER);
            BattleFields info = camp.BattleInfoController.Info;
            float        cur  = info.GetFloatData(Consts.FN_INTELLIGENTIAL);
            float        max  = info.GetFloatData(Consts.FN_INTELLIGENTIAL_MAX);

            return(new Vector2(cur, max));
        }
示例#7
0
        private void OnPlayerBattleInfoEventHandler(INoticeBase <int> param)
        {
            switch (param.Name)
            {
            case Consts.N_INTELLIGENTAL_UPDATE:
                DataNotify(Consts.DN_PLAYER_INTELLIGENTAL_UPDATE);
                break;

            case Consts.N_INTELLIGENTAL_FINISHED:
                DataNotify(Consts.DN_PLAYER_INTELLIGENTAL_FINISHED);
                BattleCamp camp = GetCamp(Consts.CAMP_PLAYER);
                camp.BattleInfoController.ResetFinishCycleFlag();
                break;
            }
        }
示例#8
0
 public void SetCamp(BattleCamp camp)
 {
     Camp = camp;
 }