Example #1
0
    void startGame()
    {
        ExecuteEvents.Execute<IPointerClickHandler>(this.GetComponent<keyListener>().menus[9].GetComponent<updateTileUI>().buttons[6].gameObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
        this.GetComponent<keyListener>().toggleMenu(0);

        List <GameObject> cities = getCities();
        List<IStatusEntity> cityEntities = new List<IStatusEntity>();
        foreach (GameObject item in cities)
        {
            CityStatusEntity cse = new CityStatusEntity();
            cse.population = item.GetComponent<cityHexManager>().population;
            cse.powerStatus = 0;
            cityEntities.Add(cse);
        }
        ResearchDevelopmentStatusEntity rdse = new ResearchDevelopmentStatusEntity();
        rdse.listOfPowerPlantUpgrades = new List<IStatusEntity>();
        for (int i = 0; i < 10; i++)
        {
            PowerPlantUpgradeStatusEntity ppuse = new PowerPlantUpgradeStatusEntity();
            if (gameInfoManager.GetComponent<gameInfoManager>().ownedPlants[i])
            {
                ppuse.researchState = 2;
            }
            else
            {
                ppuse.researchState = 0;
            }
            ppuse.listOfUpgrades = new List<IStatusEntity>();
            for (int j = 0; j < 5; j++)
            {
                ResearchDevelopmentUpgradeStatusEntity rduse = new ResearchDevelopmentUpgradeStatusEntity();
                rduse.researchState = 0;
                ppuse.listOfUpgrades.Add(rduse);
            }
            rdse.listOfPowerPlantUpgrades.Add(ppuse);
        }
        manager.GetComponent<GameManager>().StartGame(cityEntities, rdse);
    }
Example #2
0
    public void nextTurn()
    {
        /*environmentHealth -= .1f;
        modifyPolarCap();
        //moveInCoasts();
        alterBiomes();*/
        List<IStatusEntity> cityList = new List<IStatusEntity>();
        List<GameObject> cities = getCities();
        foreach (GameObject item in cities)
        {
            CityStatusEntity cse = new CityStatusEntity();
            cse.powerStatus = item.GetComponent<cityHexManager>().getPwrLvl();
            cityList.Add(cse);
        }

        ResearchDevelopmentStatusEntity rdse = new ResearchDevelopmentStatusEntity();
        for (int i = 0; i < 10; i++)
        {
            PowerPlantUpgradeStatusEntity ppuse = new PowerPlantUpgradeStatusEntity();
            if (gameInfoManager.GetComponent<gameInfoManager>().researchedPlants[i])
            {
                ppuse.researchStartTurn = gameInfoManager.GetComponent<gameInfoManager>().turnNum;
                ppuse.researchState = 2;
                gameInfoManager.GetComponent<gameInfoManager>().researchedPlants[i] = false;
            }
            for (int j = 0; j < 5; j++)
            {
                ResearchDevelopmentUpgradeStatusEntity rduse = new ResearchDevelopmentUpgradeStatusEntity();
                if (gameInfoManager.GetComponent<gameInfoManager>().researchedUpgrades[i].ups[j])
                {
                    rduse.researchStartTurn = gameInfoManager.GetComponent<gameInfoManager>().turnNum;
                    rduse.researchState = 2;
                    gameInfoManager.GetComponent<gameInfoManager>().researchedUpgrades[i].ups[j] = false;
                }
                ppuse.listOfUpgrades.Add(rduse);
            }
            rdse.listOfPowerPlantUpgrades.Add(ppuse);

        }

        LegislationStatusEntity legse = new LegislationStatusEntity();
        List<IStatusEntity> powerP = new List<IStatusEntity>();
        List<GameObject> powerPlants = getPPs();
        foreach (GameObject item in powerPlants)
        {
            PowerPlantStatusEntity ppse = new PowerPlantStatusEntity();
            ppse.resourceDrain = new ResourceDrainStatusEntity();
            ppse.resourceDrain.resourceType = item.GetComponent<ppHexManager>().getPowerConsumption();
            ppse.typeOfPowerPlant = (int)item.GetComponent<ppHexManager>().plant;
            ppse.powerCostPerTurn = item.GetComponent<ppHexManager>().powerPrice;
            ppse.powerOutput = item.GetComponent<ppHexManager>().getPowerOutput();
            ppse.buildStartTurn = item.GetComponent<ppHexManager>().buildStartTurn;
            //TODO: ppse.citiespowered
            powerP.Add(ppse);
        }

        manager.GetComponent<GameManager>().UpdateGameState(cityList, rdse, legse, powerP);
        List<List<IStatusEntity>> updateGameLists = manager.GetComponent<GameManager>().GetGameState();

        /*
         * UpdateGamelist[0]; list of citystatusentities, length can vary
         * UpdateGamelist[1]; List of environmentstatusentity, length of 1
         * UpdateGamelist[2]; List of financestatusentity, length of 1
         * UpdateGamelist[3]; List of legislationstatusentity, length of 1 DEATH
         * UpdateGamelist[4]; List of popularitystatusentity, length of 1
         * UpdateGamelist[5]; List of powerplantstatusentity, length can vary
         * UpdateGamelist[6]; List of researchdevelopmentstatusentity, length of 1
         * UpdateGamelist[7]; List of resourcestatusentity, length of 1
        */

        EnvironmentStatusEntity tempEn = (EnvironmentStatusEntity)updateGameLists[1][0];
        gameInfoManager.GetComponent<gameInfoManager>().environmentHealth = tempEn.environmentHealth;
        FinanceStatusEntity tempFi = (FinanceStatusEntity)updateGameLists[2][0];
        gameInfoManager.GetComponent<gameInfoManager>().playerWealth = tempFi.playerWealth;
        PopularityStatusEntity tempPo = (PopularityStatusEntity)updateGameLists[4][0];
        gameInfoManager.GetComponent<gameInfoManager>().percentHappiness = tempPo.percentHappiness;
        List<PowerPlantStatusEntity> tempPP = new List<PowerPlantStatusEntity>();
        foreach (IStatusEntity item in updateGameLists[5])
        {
            tempPP.Add((PowerPlantStatusEntity)item);
        }
        for (int i = 0; i < tempPP.Count; i++)
        {
            powerPlants[i].GetComponent<ppHexManager>().built = tempPP[i].built;
        }
        ResearchDevelopmentStatusEntity tempRDSE = (ResearchDevelopmentStatusEntity)updateGameLists[6][0];
        for (int i = 0; i < 10; i++)
        {
            PowerPlantUpgradeStatusEntity ppuse = (PowerPlantUpgradeStatusEntity)tempRDSE.listOfPowerPlantUpgrades[i];
            if(ppuse.turnsToResearch == 0 && ppuse.researchState == 2)
            {
                gameInfoManager.GetComponent<gameInfoManager>().ownedPlants[i] = true;
            }
            for (int j = 0; j < 5; j++)
            {
                ResearchDevelopmentUpgradeStatusEntity rduse = (ResearchDevelopmentUpgradeStatusEntity)ppuse.listOfUpgrades[j];
                if (rduse.turnsToResearch == 0 && rduse.researchState == 2)
                {
                    gameInfoManager.GetComponent<gameInfoManager>().ownedUpgrades[i].ups[j] = true;
                }
            }
        }
        ResourceStatusEntity tempResource = (ResourceStatusEntity)updateGameLists[7][0];
        gameInfoManager.GetComponent<gameInfoManager>().coal = tempResource.coal;
        gameInfoManager.GetComponent<gameInfoManager>().gas = tempResource.gas;

        gameInfoManager.GetComponent<gameInfoManager>().turnNum++;
    }