Exemple #1
0
        public bool StartGame()
        {
            gameCount++;
            tutorial = false;
            PrepareCampaignScenario();

            playerCount = players.Count;

            medailOwner = new Player[(int) Building.Count];
            for (int loop1 = 0; loop1 < players.Count; loop1++)
            {
                medailOwner[loop1] = null;
            }

            IComponentAI AI;
            int[][] setArray;
            for(int loop1 = 0; loop1 < players.Count; loop1++)
            {
                setArray = players[loop1].GetPersonality();
                players[loop1] = new Player(players[loop1].GetName(), players[loop1].GetColor(), players[loop1].GetComponentAI(), loop1, setArray, players[loop1].GetGen());
                AI = players[loop1].GetComponentAI();

                if (AI != null) // its computer then
                {
#if GENETIC
                    // GENETICS ALG
                    if (players[loop1].GetGen() &&
                        (gameCount - 1) % geneticFitnessRound == 0)
                    {
                        chromozone = genetic.GetChromozone();
                        setArray = chromozone;

                        // uncomment next line for finding your fitness
                        //players[loop1] = new Player(players[loop1].GetName(), players[loop1].GetColor(), null, loop1, setArray, players[loop1].GetGen());
                    }

                    if (!players[loop1].GetGen())
                    {
                        if (bosses == null)
                            setArray = genetic.GetBestOnePersonality(); // reference AI is the best AI in all population
                        else
                            setArray = bosses[(gameCount - 1) % geneticFitnessRound]; // reference AI is contant
                    }
                    // GENETICS 
#endif

                    AI.InitAIComponent(map.GetMapController(), setArray);
                }
            }

            state = EGameState.BeforeGame;
            PrepareCampaignMap();
            
            activePlayerIndex = 0;
            activePlayer = players.ElementAt(activePlayerIndex);
            targetPlayer = activePlayer;

            pausedNew = false;
            paused = false;
            winnerNew = false;

            hasAIThreadStarted = false;

            if(players[0].GetBuildingCount(Building.Town) == 0)
                state = EGameState.StateFirstTown;
            else
                state = EGameState.StateGame;

            fortState = EFortState.Normal;

            randomNumber = new System.Random();
            hasBuiltTown = false;
            turnNumber = 1;

            if (playerCount == 1)
            {
                Settings.banFortStealSources = true;
                Settings.banFortCaptureHexa = true;
            }
            if (Settings.pointsFortParade == 0)
                Settings.banFortParade = true;
            if (Settings.banChangeSources)
                Settings.banMarket = true;

            PromptWindow.Inst().Deactive();
            Message.Inst().ClearMessages();
            MarketComponent.Inst().SetIsActive(false);
            PathNode.SetIsValid(false);

            if(tutorial)
                Tutorial.Inst().TurnOn();
            StartTurn();
            return true;
        }
Exemple #2
0
 public void SetFortState(EFortState state) { fortState = state; }