low power slowdown

This commit is contained in:
Chris Forbes
2009-12-08 20:56:15 +13:00
parent bcea1f01b0
commit 0dbf1bf027
5 changed files with 24 additions and 3 deletions

View File

@@ -121,5 +121,6 @@ namespace OpenRa.Game.GameRules
/* OpenRA-specific */
public readonly float OreChance; /* chance of spreading to a
* particular eligible cell */
public readonly int LowPowerSlowdown; /* build time multiplier */
}
}

View File

@@ -6,6 +6,8 @@ using OpenRa.Game.Traits;
namespace OpenRa.Game
{
enum PowerState { Normal, Low, Critical };
class Player
{
public int Palette;
@@ -65,6 +67,13 @@ namespace OpenRa.Game
return (float)Ore / GetOreCapacity();
}
public PowerState GetPowerState()
{
if (powerProvided >= powerDrained) return PowerState.Normal;
if (powerProvided > powerDrained / 2) return PowerState.Low;
return PowerState.Critical;
}
public int GetOreCapacity()
{
return Game.world.Actors

View File

@@ -14,6 +14,8 @@ namespace OpenRa.Game
public bool Paused = false, Done = false;
public Action OnComplete;
int slowdown = 0;
public ProductionItem(string item, int time, int cost, Action onComplete)
{
Item = item;
@@ -32,6 +34,14 @@ namespace OpenRa.Game
if (Paused) return;
if (player.GetPowerState() != PowerState.Normal)
{
if (--slowdown <= 0)
slowdown = Rules.General.LowPowerSlowdown;
else
return;
}
var costThisFrame = RemainingCost / RemainingTime;
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;

View File

@@ -56,8 +56,8 @@ namespace OpenRa.Game
string group = Rules.UnitCategory[ order.TargetString ];
var ui = Rules.UnitInfo[ order.TargetString ];
var time = ui.Cost
* .8f /* Game.BuildSpeed */ /* todo: country-specific build speed bonus */
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
/ 1000;
time = .08f * time; /* temporary hax so we can build stuff fast for test */

View File

@@ -574,6 +574,7 @@ WaterImpactSound=splash9
[General]
OreChance=.02
LowPowerSlowdown=3
[VoiceTypes]
GenericVoice