コード例 #1
0
    //button listeners
    private void EndturnListener()
    {
        if (turn < gamelength)
        {
            if (LoseCounter == 0)
            {
                LoseText.SetActive(true);
                turn = 50;
            }
            else if (data.WaterDistributionRate < data.WaterConsumptionRate)
            {
                LoseCounter--;
                LoseCounterText.text = "Lives: " + LoseCounter.ToString();
            }
            data.ExtractWaterSources();
            Debug.Log("Lake Reserve: " + data.WaterSources[0].GetReserve() + " Max Reserve: " + 100000);
            City.SetLakeCurrent(data.WaterSources[0].GetReserve());

            if (RainTurnCount == 0)
            {
                data.SetEvent(0, Random.Range(10, 20));
                RainTurnCount = RainInterval;
                City.SetRainEnabled(true);
            }
            else
            {
                City.SetRainEnabled(false);
                RainTurnCount--;
            }
            if (CurrentTempEventTurnCount != 0 && CurrentTempEvent < 2)
            {
                if (CurrentTempEvent == 0)
                {
                    data.SetEvent(1, Random.Range(5, 7));
                    CurrentTempEventTurnCount--;
                    WarmFront.SetActive(true);
                    ColdFront.SetActive(false);
                }
                else if (CurrentTempEvent == 1)
                {
                    data.SetEvent(2, Random.Range(5, 7));
                    CurrentTempEventTurnCount--;
                    WarmFront.SetActive(false);
                    ColdFront.SetActive(true);
                }
            }
            else
            {
                if (CurrentTempEventTurnCount > 0)
                {
                    CurrentTempEventTurnCount--;
                }
                if (data.Temperature < AverageTemperature)
                {
                    data.SetEvent(1, Random.Range(3, 5));
                }
                else
                {
                    data.SetEvent(2, Random.Range(3, 5));
                }
                WarmFront.SetActive(false);
                ColdFront.SetActive(false);
            }

            if (CurrentPopEventTurnCount != 0 && CurrentPopEvent < 2)
            {
                if (CurrentPopEvent == 0)
                {
                    data.SetEvent(3, Random.Range(1000, 5000));
                    CurrentPopEventTurnCount--;
                    MigrationIn.SetActive(true);
                    MigrationOut.SetActive(false);
                }
                else if (CurrentPopEvent == 1)
                {
                    data.SetEvent(4, Random.Range(1000, 5000));
                    CurrentPopEventTurnCount--;
                    MigrationIn.SetActive(false);
                    MigrationOut.SetActive(true);
                }
            }
            else
            {
                if (CurrentPopEventTurnCount > 0)
                {
                    CurrentPopEventTurnCount--;
                }
                MigrationIn.SetActive(false);
                MigrationOut.SetActive(false);
            }

            if (CurrentRainEventTurnCount != 0 && CurrentRainEvent < 2)
            {
                if (CurrentRainEvent == 0)
                {
                    Drought.SetActive(true);
                    Monsoon.SetActive(false);
                    CurrentRainEventTurnCount--;
                }
                else if (CurrentRainEvent == 1)
                {
                    Drought.SetActive(false);
                    Monsoon.SetActive(true);
                    CurrentRainEventTurnCount--;
                }
            }
            else
            {
                if (CurrentRainEventTurnCount > 0)
                {
                    CurrentRainEventTurnCount--;
                }
                Drought.SetActive(false);
                Monsoon.SetActive(false);
            }

            data.IncrementPopulation(10);
            data.CalculateWaterDistributionRate();
            data.IncrementFund();
            turn++;
            GenerateEvents();
            Debug.Log("Current Rain Event: " + CurrentRainEvent + ". Turn Count: " + CurrentRainEventTurnCount +
                      "| Current Pop Event: " + CurrentPopEvent + ". Turn Count: " + CurrentPopEventTurnCount +
                      "| Current Temp Event: " + CurrentTempEvent + ". Turn Count: " + CurrentTempEventTurnCount);
        }
        else if (turn == gamelength)
        {
            WinText.SetActive(true);
        }
    }
コード例 #2
0
    //button listeners
    private void EndturnListener()
    {
        if (turn < gamelength)
        {
            if (LoseCounter == 0)
            {
                LoseText.enabled = true;
                turn             = 50;
            }
            else if (data.WaterDistributionRate < data.WaterConsumptionRate)
            {
                LoseCounter--;
                LoseCounterText.text = "Lose Counter: " + LoseCounter.ToString();
            }
            data.ExtractWaterSources();

            if (RainTurnCount == 0)
            {
                data.SetEvent(0, Random.Range(5000, 10000));
                RainTurnCount = RainInterval;
                Rain.enabled  = true;
            }
            else
            {
                Rain.enabled = false;
                RainTurnCount--;
            }
            if (CurrentTempEvent == 0)
            {
                data.SetEvent(1, Random.Range(5, 7));
                CurrentTempEventTurnCount--;
                WarmFront.enabled = true;
                ColdFront.enabled = false;
            }
            else if (CurrentTempEvent == 1)
            {
                data.SetEvent(2, Random.Range(5, 7));
                CurrentTempEventTurnCount--;
                WarmFront.enabled = false;
                ColdFront.enabled = true;
            }
            else
            {
                WarmFront.enabled = false;
                ColdFront.enabled = false;
            }

            if (CurrentPopEvent == 0)
            {
                data.SetEvent(3, Random.Range(5000, 10000));
                CurrentPopEventTurnCount--;
                MigrationIn.enabled  = true;
                MigrationOut.enabled = false;
            }
            else if (CurrentPopEvent == 1)
            {
                data.SetEvent(4, Random.Range(5000, 10000));
                CurrentPopEventTurnCount--;
                MigrationIn.enabled  = false;
                MigrationOut.enabled = true;
            }
            else
            {
                MigrationIn.enabled  = false;
                MigrationOut.enabled = false;
            }

            if (CurrentRainEvent == 0)
            {
                Drought.enabled = true;
                Monsoon.enabled = false;
                CurrentRainEventTurnCount--;
            }
            else if (CurrentRainEvent == 1)
            {
                Drought.enabled = false;
                Monsoon.enabled = true;
                CurrentRainEventTurnCount--;
            }
            else
            {
                Drought.enabled = false;
                Monsoon.enabled = false;
            }

            data.IncrementPopulation(10);
            data.CalculateWaterDistributionRate();
            data.IncrementFund();
            turn++;
            GenerateEvents();
        }
        else if (turn == gamelength)
        {
            WinText.text = "You Win";
        }
    }