Пример #1
0
    public void UpdateResourceCount(ResourceValues changes)
    {
        // The TurnController did put the production and the received trades in `changes`
        current.Add(changes);

        // Calculate subsequent food and energy loss based off population
        current.food   -= current.TotalPopulation;
        current.energy -= current.TotalPopulation;

        // Take the biggest discontent or 0 if none
        int popUnsatisfied = Math.Max(0, Math.Max(-current.food, -current.energy));

        // Cap population turning angry by the current happy population
        int popTurningAngry = Math.Min(current.population, popUnsatisfied);

        current.population      -= popTurningAngry;
        current.populationAngry += popTurningAngry;

        // Ensure we don't have any negative food or energy
        current.SetMin(0);

        // Clear trades from last turn
        trade.Reset();

        UpdateUI();
    }
Пример #2
0
    public ResourceValues AddPopulation(ResourceValues v)
    {
        population      += v.population;
        populationAngry += v.populationAngry;

        return(this);
    }
Пример #3
0
 public void UpgradeTypeWithValues(ResourceType type, ResourceValues addValues)
 {
     foreach (Resource r in GetResourcesWithType(type))
     {
         r.UpgradeValues(addValues);
     }
 }
Пример #4
0
 public bool LessEqual(ResourceValues v)
 {
     return(food <= v.food &&
            energy <= v.energy &&
            polution <= v.polution &&
            population <= v.population &&
            populationAngry <= v.populationAngry);
 }
Пример #5
0
    //only used for Policy requirements
    public ResourceValues Subtract(ResourceValues v)
    {
        food       -= v.food;
        energy     -= v.energy;
        population -= v.population;

        return(this);
    }
Пример #6
0
    public ResourceValues AddProduced(ResourceValues v)
    {
        food       += v.food;
        energy     += v.energy;
        population += v.population;
        //polution += v.polution;

        return(this);
    }
Пример #7
0
    public ResourceValues Add(ResourceValues v)
    {
        food            += v.food;
        energy          += v.energy;
        polution        += v.polution;
        population      += v.population;
        populationAngry += v.populationAngry;

        return(this);
    }
Пример #8
0
    //turn execution
    public void Clicked()
    {
        if ((currentTurn < turnLimit) && (gameOver == false))
        {
            currentTurn += 1;

            turnDisplay.text = "End turn " + currentTurn;

            //sea level calculations
            seaLevel.UpdateSeaLevel();

            /* Collect effective production after eventual flood */
            p1Production.UpdateProduction();
            p2Production.UpdateProduction();

            /* Apply delayed actions first */
            foreach (Action action in ActionsForTurn(currentTurn))
            {
                action();
            }

            ResourceValues playerOneResources = p2Resources.trade;
            ResourceValues playerTwoResources = p1Resources.trade;

            //collecting all the resources
            playerOneResources.Add(p1Production.production);
            playerTwoResources.Add(p2Production.production);

            //update game with new amount of resources from production on every turn but 1st
            p1Resources.UpdateResourceCount(playerOneResources);
            p2Resources.UpdateResourceCount(playerTwoResources);

            //draw a new hand of policies for each players
            p1Cards.DrawNewHand();
            p2Cards.DrawNewHand();
        }
        else if (currentTurn == turnLimit)
        {
            currentTurn += 1; // Increment so we don't restart the music each click
            musicController.PlayLevel(4);
            GameOver("You win!");
        }
    }
Пример #9
0
    private void AddSource(Resource resource)
    {
        ResourceValues v = resource.TotalValues;

        if (v.food != 0)
        {
            foodSources.Add(resource.title + ": " + v.food.ToString(SOURCE_FORMAT));
        }

        if (v.energy != 0)
        {
            energySources.Add(resource.title + ": " + v.energy.ToString(SOURCE_FORMAT));
        }

        if (v.population != 0)
        {
            popsSources.Add(resource.title + ": " + v.population.ToString(SOURCE_FORMAT));
        }

        if (v.populationAngry != 0)
        {
            popsAngrySources.Add(resource.title + ": " + v.populationAngry.ToString(SOURCE_FORMAT));
        }
    }
Пример #10
0
 public void UpgradeValues(ResourceValues addedValues)
 {
     bonusValues.Add(addedValues);
     UpdateTooltip();
 }