unitinfo.InitialFacing etc

This commit is contained in:
Chris Forbes
2009-11-29 14:56:09 +13:00
parent cc2ef432b4
commit 9860b35030
9 changed files with 63 additions and 48 deletions

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace OpenRa.Game
@@ -47,8 +46,7 @@ namespace OpenRa.Game
public void GiveCash( int num )
{
// TODO: increase cash
Cash += num; // TODO: slowly
Cash += num;
}
public bool TakeCash( int num )
@@ -97,45 +95,4 @@ namespace OpenRa.Game
production[ group ] = item;
}
}
class ProductionItem
{
public readonly string Item;
public readonly int TotalTime;
public readonly int TotalCost;
public int RemainingTime { get; private set; }
public int RemainingCost { get; private set; }
public bool Paused = false, Done = false;
public Action OnComplete;
public ProductionItem( string item, int time, int cost, Action onComplete )
{
Item = item;
RemainingTime = TotalTime = time;
RemainingCost = TotalCost = cost;
OnComplete = onComplete;
}
public void Tick( Player player )
{
if (Done)
{
if (OnComplete != null) OnComplete();
return;
}
if( Paused ) return;
var costThisFrame = RemainingCost / RemainingTime;
if( costThisFrame != 0 && !player.TakeCash( costThisFrame ) ) return;
RemainingCost -= costThisFrame;
RemainingTime -= 1;
if( RemainingTime > 0 ) return;
Done = true;
}
}
}