Crates: Part 2
This commit is contained in:
46
OpenRa.Mods.RA/Crate Actions/SpeedUpgrade.cs
Normal file
46
OpenRa.Mods.RA/Crate Actions/SpeedUpgrade.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class SpeedUpgradeCrateActionInfo : ITraitInfo
|
||||
{
|
||||
public float Multiplier = 1.7f;
|
||||
public int SelectionShares = 10;
|
||||
public object Create(Actor self) { return new SpeedUpgradeCrateAction(self); }
|
||||
}
|
||||
class SpeedUpgradeCrateAction : ICrateAction
|
||||
{
|
||||
Actor self;
|
||||
public SpeedUpgradeCrateAction(Actor self)
|
||||
{
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public int SelectionShares
|
||||
{
|
||||
get { return self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().SelectionShares; }
|
||||
}
|
||||
|
||||
public void Activate(Actor collector)
|
||||
{
|
||||
Sound.PlayToPlayer(collector.Owner, "unitspd1.aud");
|
||||
collector.World.AddFrameEndTask(w =>
|
||||
{
|
||||
float multiplier = self.Info.Traits.Get<SpeedUpgradeCrateActionInfo>().Multiplier;
|
||||
collector.traits.Add(new SpeedUpgrade(multiplier));
|
||||
w.Add(new CrateEffectSpeedUpgrade(collector));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class SpeedUpgrade : ISpeedModifier
|
||||
{
|
||||
float multiplier;
|
||||
public SpeedUpgrade(float multiplier) { this.multiplier = multiplier; }
|
||||
public float GetSpeedModifier() { return multiplier; }
|
||||
}
|
||||
}
|
||||
32
OpenRa.Mods.RA/Effects/CrateEffectSpeedUpgrade.cs
Normal file
32
OpenRa.Mods.RA/Effects/CrateEffectSpeedUpgrade.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Graphics;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Effects;
|
||||
|
||||
namespace OpenRa.Mods.RA.Effects
|
||||
{
|
||||
class CrateEffectSpeedUpgrade : IEffect
|
||||
{
|
||||
Actor a;
|
||||
Animation anim = new Animation("crate-effects");
|
||||
float2 doorOffset = new float2(-4,0);
|
||||
|
||||
public CrateEffectSpeedUpgrade(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
anim.PlayThen("speed",
|
||||
() => a.World.AddFrameEndTask(w => w.Remove(this)));
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
anim.Tick();
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size + doorOffset, PaletteType.Gold);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@
|
||||
<Compile Include="Activities\LayMine.cs" />
|
||||
<Compile Include="Activities\Steal.cs" />
|
||||
<Compile Include="C4Demolition.cs" />
|
||||
<Compile Include="Effects\CrateEffectSpeedUpgrade.cs" />
|
||||
<Compile Include="EngineerCapture.cs" />
|
||||
<Compile Include="InfiltrateForSonarPulse.cs" />
|
||||
<Compile Include="RequiresPower.cs" />
|
||||
@@ -61,6 +62,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RenderSpy.cs" />
|
||||
<Compile Include="RepairableNear.cs" />
|
||||
<Compile Include="Crate Actions\SpeedUpgrade.cs" />
|
||||
<Compile Include="Spy.cs" />
|
||||
<Compile Include="Thief.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user