Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 3
0
        public override void Execute()
        {
            int index = Utils.UnityRangeRandom(0, Heros.Count);

            Hero   = Heros[index];
            HeroID = Hero.Info.GetIntData(Consts.FN_ID);

            "log:AI chooset player card from {0} heros, selected index is {1}, id is {2}".Log(Heros.Count.ToString(), index.ToString(), HeroID.ToString());
        }
Esempio n. 4
0
        private void OnPlayerCardGenerateListener(INoticeBase <int> param)
        {
            Debug.Log("OnPlayerCardGenerateListener 1");
            CardNotice           notice         = param as CardNotice;
            BattleHeroController heroController = notice.heroControllerFrom;

            //heroController.
            //TODO 根据将领能力生成手牌

            notice.ToPool();
        }
        public void CountTotalFields(ref BattleHeroController heroController)
        {
            int troops = Info.GetIntData(Consts.FN_TROOPS);

            troops += heroController.Info.GetIntData(Consts.FN_TROOPS);

            Info.SetIntData(Consts.FN_TROOPS, troops);
            Info.SetIntData(Consts.FN_TROOPS_MAX, troops);

            float intelligential = Info.GetFloatData(Consts.FN_INTELLIGENTIAL);

            intelligential += heroController.Info.GetFloatData(Consts.FN_INTELLECT);

            Info.SetFloatData(Consts.FN_INTELLIGENTIAL, intelligential);
            Info.SetFloatData(Consts.FN_INTELLIGENTIAL_MAX, intelligential);
            Info.SetFloatData(Consts.FN_INTELLIGENTIAL_DELTA, intelligential * 0.002f);
            Info.SetFloatData(Consts.FN_MORALE, 50f);
            Info.SetFloatData(Consts.FN_MORALE_MAX, 100f);
        }
Esempio n. 6
0
 public void SetCampHero(int heroPos, BattleHeroController heroController)
 {
     mBattleHeros[heroPos] = heroController;
     heroController.SetCamp(this);
     BattleInfoController.CountTotalFields(ref heroController);
 }
Esempio n. 7
0
        public override void ToPool()
        {
            base.ToPool();

            heroController = default;
        }