Crates: Part 2
This commit is contained in:
@@ -3,6 +3,26 @@ using System.Linq;
|
||||
using OpenRa.Effects;
|
||||
using OpenRa.Traits;
|
||||
|
||||
/*
|
||||
* Crates left to implement:
|
||||
Armor=10,ARMOR,2.0 ; armor of nearby objects increased (armor multiplier)
|
||||
Cloak=0,STEALTH2 ; enable cloaking on nearby objects
|
||||
Darkness=1,EMPULSE ; cloak entire radar map
|
||||
Explosion=5,NONE,500 ; high explosive baddie (damage per explosion)
|
||||
Firepower=10,FPOWER,2.0 ; firepower of nearby objects increased (firepower multiplier)
|
||||
HealBase=1,INVUN ; all buildings to full strength
|
||||
ICBM=1,MISSILE2 ; nuke missile one time shot
|
||||
Money=50,DOLLAR,2000 ; a chunk o' cash (maximum cash)
|
||||
Napalm=5,NONE,600 ; fire explosion baddie (damage)
|
||||
ParaBomb=3,PARABOX ; para-bomb raid one time shot
|
||||
Reveal=1,EARTH ; reveal entire radar map
|
||||
Sonar=3,SONARBOX ; one time sonar pulse
|
||||
Squad=20,NONE ; squad of random infantry
|
||||
Unit=20,NONE ; vehicle
|
||||
Invulnerability=3,INVULBOX,1.0 ; invulnerability (duration in minutes)
|
||||
TimeQuake=3,TQUAKE ; time quake
|
||||
*/
|
||||
|
||||
namespace OpenRa.Traits
|
||||
{
|
||||
class CrateInfo : ITraitInfo
|
||||
@@ -23,9 +43,8 @@ namespace OpenRa.Traits
|
||||
|
||||
public void OnCrush(Actor crusher)
|
||||
{
|
||||
// TODO: Do Stuff
|
||||
|
||||
|
||||
// TODO: Pick one randomly
|
||||
self.traits.WithInterface<ICrateAction>().First().Activate(crusher);
|
||||
self.World.AddFrameEndTask(w => w.Remove(self));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,13 @@ namespace OpenRa.Traits
|
||||
bool IsCrushableBy(UnitMovementType umt, Player player);
|
||||
bool IsPathableCrush(UnitMovementType umt, Player player);
|
||||
}
|
||||
|
||||
public interface ICrateAction
|
||||
{
|
||||
int SelectionShares { get; }
|
||||
void Activate(Actor collector);
|
||||
}
|
||||
|
||||
public struct Renderable
|
||||
{
|
||||
public readonly Sprite Sprite;
|
||||
|
||||
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>
|
||||
|
||||
@@ -135,6 +135,7 @@ DOME:
|
||||
|
||||
CRATE:
|
||||
Crate:
|
||||
SpeedUpgradeCrateAction:
|
||||
Unit:
|
||||
HP: 1
|
||||
RenderUnit:
|
||||
|
||||
@@ -424,6 +424,7 @@ DOME:
|
||||
|
||||
CRATE:
|
||||
Crate:
|
||||
SpeedUpgradeCrateAction:
|
||||
Unit:
|
||||
HP: 1
|
||||
RenderUnit:
|
||||
|
||||
@@ -1044,4 +1044,7 @@
|
||||
<unit name="crate">
|
||||
<sequence name="idle" start="0" length="16" src="wcrate" />
|
||||
</unit>
|
||||
<unit name="crate-effects">
|
||||
<sequence name="speed" start="0" length="*" src="speed" />
|
||||
</unit>
|
||||
</sequences>
|
||||
Reference in New Issue
Block a user