Exemplo n.º 1
0
 /// <summary>
 /// Stops previous match and creates a new one depending on <see cref="AppController.GameMode"/>
 /// </summary>
 public void StartMatch()
 {
     if (Singleton <AppController> .Instance.GameMode == GameMode.SingleMatch)
     {
         InitMatch(m_singleMatchSettings);
     }
     else
     {
         InitMatch(MatchSettings.CreateInfiniteRandomMatchConfig());
     }
     StartCoroutine(runMatch());
 }
Exemplo n.º 2
0
 /// <summary>
 /// Create the player controllers and initializes the <see cref="MatchManager"/>
 /// </summary>
 /// <param name="matchSettings">The settings to use to set up the match</param>
 public void InitMatch(MatchSettings matchSettings)
 {
     StopAllCoroutines();
     CurrentTurn = 0;
     ScriptedPlayerControllers = new List <ScriptedPlayerController>();
     m_matchManager.CreateMatch(matchSettings);
     playerControllers = new List <PlayerController>();
     foreach (var faction in m_matchManager.Factions)
     {
         var controllerGO = createPlayerControllerForFaction(faction, matchSettings.PlayerConfigs[faction.FactionIndex].AIType);
         var controller   = controllerGO.GetComponent <PlayerController>();
         controller.Initialize(m_matchManager, faction);
         playerControllers.Add(controller);
     }
     CurrentTurnNumber = 0;
     m_uiController?.Initialize(humanPlayer);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Boots the MatchManager given a specific <see cref="MatchSettings"/>
        /// </summary>
        /// <param name="matchConfig"></param>
        public void CreateMatch(MatchSettings matchConfig)
        {
            MapManager.Initialize(matchConfig.MapSize.x, matchConfig.MapSize.y);

            if (Factions != null)
            {
                foreach (var faction in Factions)
                {
                    faction.Clean();
                }
            }

            Factions    = new List <FactionManager>();
            BotFactions = new List <FactionManager>();

            int factionIndex = 0;

            foreach (var playerConfig in matchConfig.PlayerConfigs)
            {
                var factionManager = new FactionManager(factionIndex, playerConfig.PlayerType);
                if (playerConfig.PlayerType == PlayerType.Human)
                {
                    HumanFaction = factionManager;
                }
                else
                {
                    BotFactions.Add(factionManager);
                }
                foreach (var unitConfig in playerConfig.Units)
                {
                    var unit = m_unitFactory.CreateUnit(unitConfig.UnitType, factionIndex, unitConfig.SpawnPosition);
                    MapManager.PlaceUnit(unitConfig.SpawnPosition, unit);
                    factionManager.AddUnit(unit);
                    unit.transform.parent = MapManager.transform;
                }
                Factions.Add(factionManager);
                factionIndex++;
            }
        }