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(); }
public void UpdateProduction() { production.Reset(); ResetTooltips(); // Collect resources foreach (Resource r in GetResources()) { production.Add(r.TotalValues); AddSource(r); } UpdateUI(); UpdateTooltips(); }
//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!"); } }
public void UpgradeValues(ResourceValues addedValues) { bonusValues.Add(addedValues); UpdateTooltip(); }