Crates: Part 2

This commit is contained in:
Paul Chote
2010-01-27 20:55:11 +13:00
parent abe1b3c1ea
commit cc4c137038
8 changed files with 114 additions and 3 deletions

View 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; }
}
}