Add total earned/spent tracking

This commit is contained in:
Scott_NZ
2012-11-24 18:11:34 +13:00
parent 2a0b9a8596
commit 30a374b9e9
3 changed files with 43 additions and 5 deletions

View File

@@ -87,9 +87,13 @@ namespace OpenRA.Traits
public int DisplayOre;
public int IncomePerMin;
public double IncomeChange;
int incomeCounter;
public double IncomeChange;
public int TotalEarned;
public int TotalSpent;
public bool CanGiveOre(int amount)
{
return Ore + amount <= OreCapacity;
@@ -98,20 +102,25 @@ namespace OpenRA.Traits
public void GiveOre(int num)
{
Ore += num;
incomeCounter += num;
TotalEarned += num;
if (Ore > OreCapacity)
{
nextSiloAdviceTime = 0;
incomeCounter -= Ore - OreCapacity;
TotalEarned -= Ore - OreCapacity;
Ore = OreCapacity;
}
incomeCounter += num;
}
public bool TakeOre(int num)
{
if (Ore < num) return false;
Ore -= num;
TotalSpent += num;
return true;
}
@@ -120,6 +129,7 @@ namespace OpenRA.Traits
{
Cash += num;
incomeCounter += num;
TotalEarned += num;
}
public bool TakeCash(int num)
@@ -128,6 +138,7 @@ namespace OpenRA.Traits
// Spend ore before cash
Ore -= num;
TotalSpent += num;
if (Ore < 0)
{
Cash += Ore;