Use CashTick on harv unloading.

This commit is contained in:
Paul Chote
2011-03-16 21:32:44 +13:00
parent ffac0221cf
commit 6d1defc53e
2 changed files with 22 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Effects
class CashTick : IEffect class CashTick : IEffect
{ {
string s; string s;
int lifetime = 50; int lifetime;
int remaining; int remaining;
int velocity; int velocity;
float2 pos; float2 pos;

View File

@@ -17,6 +17,7 @@ using OpenRA.Traits;
using OpenRA.Mods.RA.Render; using OpenRA.Mods.RA.Render;
using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Move;
using System.Drawing; using System.Drawing;
using OpenRA.Mods.RA.Effects;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -25,10 +26,11 @@ namespace OpenRA.Mods.RA
public readonly int PipCount = 0; public readonly int PipCount = 0;
public readonly PipType PipColor = PipType.Red; public readonly PipType PipColor = PipType.Red;
public readonly int2 DockOffset = new int2 (1, 2); public readonly int2 DockOffset = new int2 (1, 2);
public readonly int Capacity = 0;
public readonly int ProcessTick = 25; public readonly bool ShowTicks = true;
public readonly int ProcessAmount = 50; public readonly int TickLifetime = 30;
public readonly int LowPowerProcessTick = 50; public readonly int TickVelocity = 2;
public readonly int TickRate = 10;
public virtual object Create(ActorInitializer init) { return new OreRefinery(init.self, this); } public virtual object Create(ActorInitializer init) { return new OreRefinery(init.self, this); }
} }
@@ -39,6 +41,9 @@ namespace OpenRA.Mods.RA
readonly OreRefineryInfo Info; readonly OreRefineryInfo Info;
PlayerResources PlayerResources; PlayerResources PlayerResources;
int currentDisplayTick = 0;
int currentDisplayValue = 0;
[Sync] [Sync]
public int Ore = 0; public int Ore = 0;
@@ -74,6 +79,8 @@ namespace OpenRA.Mods.RA
public void GiveOre(int amount) public void GiveOre(int amount)
{ {
PlayerResources.GiveOre(amount); PlayerResources.GiveOre(amount);
if (Info.ShowTicks)
currentDisplayValue += amount;
} }
void CancelDock(Actor self) void CancelDock(Actor self)
@@ -93,6 +100,15 @@ namespace OpenRA.Mods.RA
self.Trait<RenderBuilding>().CancelCustomAnim(self); self.Trait<RenderBuilding>().CancelCustomAnim(self);
dockedHarv = null; dockedHarv = null;
} }
if (Info.ShowTicks && currentDisplayValue > 0 && --currentDisplayTick <= 0)
{
var temp = currentDisplayValue;
if (self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
self.World.AddFrameEndTask(w => w.Add(new CashTick(temp, Info.TickLifetime, Info.TickVelocity, self.CenterLocation, self.Owner.ColorRamp.GetColor(0))));
currentDisplayTick = Info.TickRate;
currentDisplayValue = 0;
}
} }
public void Damaged (Actor self, AttackInfo e) public void Damaged (Actor self, AttackInfo e)