Esempio n. 1
0
        public void Init(SCBattlePveStartMsg battleStartMsg)
        {
            
            var service = BattleTemplateModelLocator.Instance;
            var battleSourceCreator = new BattleSourceTemplateCreater(service);
            var battleSource = battleSourceCreator.createPVESource(battleStartMsg);
            battleSource.Uuid = battleStartMsg.Uuid;

            // level manager setup, including levels and monsters controll.
            LevelManager = new LevelManager
            {
                MonsterList = battleSource.getSideFighters(BattleSideEnum.SIDEB_RIGHT),
                MonsterGroupList = battleSource.MonsterGroup
            };
            if (LevelManager.MonsterList == null)
            {
                Debug.Log("MonsterList == null");
            }
            if (LevelManager.MonsterGroupList == null)
            {
                Debug.Log("MonsterGroupList == null");
            }

            // Important, will do level manager input data validation.
            LevelManager.Validate();

            if (PersistenceHandler.Instance.Mode == PersistenceHandler.PersistenceMode.ReStartBattleWithPersistence)
            {
                LevelManager.RestorePersistent(PersistenceHandler.Instance.PersistentInfor);
            }
            LevelManager.InitLevel();

            BattleType = battleStartMsg.BattleType;
            RaidID = battleStartMsg.RaidID;
            Uuid = battleStartMsg.Uuid;
            Source = battleSource;

            var factory = battleSource.BattleType.Factory;
            MainBattle = factory.createBattle(Source, templateModel);
            MainBattle.start();

            // hero setup.
            HeroList = battleSource.getSideFighters(BattleSideEnum.SIDE_LEFT);
        }