added 'give cash' crate

This commit is contained in:
Chris Forbes
2010-02-11 15:15:53 +13:00
parent 703c0a26af
commit 540ea15f07
3 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
using OpenRa.Mods.RA.Effects;
using OpenRa.Traits;
namespace OpenRa.Mods.RA
{
class GiveCashCrateActionInfo : ITraitInfo
{
public int Amount = 2000;
public int SelectionShares = 10;
public object Create(Actor self) { return new GiveCashCrateAction(self); }
}
class GiveCashCrateAction : ICrateAction
{
Actor self;
public GiveCashCrateAction(Actor self)
{
this.self = self;
}
public int SelectionShares
{
get { return self.Info.Traits.Get<GiveCashCrateActionInfo>().SelectionShares; }
}
public void Activate(Actor collector)
{
collector.World.AddFrameEndTask(w =>
{
var amount = self.Info.Traits.Get<GiveCashCrateActionInfo>().Amount;
collector.Owner.GiveCash(amount);
w.Add(new CrateEffect(collector, "dollar"));
});
}
}
}

View File

@@ -9,6 +9,7 @@ namespace OpenRa.Mods.RA
public int SelectionShares = 10;
public object Create(Actor self) { return new SpeedUpgradeCrateAction(self); }
}
class SpeedUpgradeCrateAction : ICrateAction
{
Actor self;

View File

@@ -52,6 +52,7 @@
<Compile Include="Activities\LayMine.cs" />
<Compile Include="Activities\Steal.cs" />
<Compile Include="C4Demolition.cs" />
<Compile Include="Crate Actions\GiveCashCrateAction.cs" />
<Compile Include="Effects\CrateEffect.cs" />
<Compile Include="Effects\GpsSatellite.cs" />
<Compile Include="Effects\InvulnEffect.cs" />
@@ -71,7 +72,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RenderSpy.cs" />
<Compile Include="RepairableNear.cs" />
<Compile Include="Crate Actions\SpeedUpgrade.cs" />
<Compile Include="Crate Actions\SpeedUpgradeCrateAction.cs" />
<Compile Include="SonarPulsePower.cs" />
<Compile Include="Spy.cs" />
<Compile Include="SpyPlanePower.cs" />