hack in rank overlay; fix last rank; add an extra (elite) rank
This commit is contained in:
@@ -23,23 +23,25 @@ using System.Linq;
|
|||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
public class GainsExperienceInfo : ITraitInfo, ITraitPrerequisite<ValuedInfo>
|
public class GainsExperienceInfo : ITraitInfo, ITraitPrerequisite<ValuedInfo>
|
||||||
{
|
{
|
||||||
public readonly float[] CostThreshold = { 2, 4, 8 };
|
public readonly float[] CostThreshold = { 2, 4, 8, 16 };
|
||||||
public readonly float[] FirepowerModifier = { 1.2f, 1.5f, 2 };
|
public readonly float[] FirepowerModifier = { 1.1f, 1.2f, 1.3f, 2f };
|
||||||
public readonly float[] ArmorModifier = { 1.2f, 1.5f, 2 };
|
public readonly float[] ArmorModifier = { 1.1f, 1.2f, 1.3f, 2f };
|
||||||
public readonly float[] SpeedModifier = { 1.2f, 1.5f, 2 };
|
public readonly float[] SpeedModifier = { 1.1f, 1.2f, 1.3f, 2f };
|
||||||
public object Create(Actor self) { return new GainsExperience(self, this); }
|
public object Create(Actor self) { return new GainsExperience(self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GainsExperience : IFirepowerModifier, ISpeedModifier, IDamageModifier
|
public class GainsExperience : IFirepowerModifier, ISpeedModifier, IDamageModifier, IRenderModifier
|
||||||
{
|
{
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly int[] Levels;
|
readonly int[] Levels;
|
||||||
readonly GainsExperienceInfo Info;
|
readonly GainsExperienceInfo Info;
|
||||||
|
readonly Animation RankAnim;
|
||||||
|
|
||||||
public GainsExperience(Actor self, GainsExperienceInfo info)
|
public GainsExperience(Actor self, GainsExperienceInfo info)
|
||||||
{
|
{
|
||||||
@@ -47,6 +49,8 @@ namespace OpenRA.Mods.RA
|
|||||||
this.Info = info;
|
this.Info = info;
|
||||||
var cost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
var cost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||||
Levels = Info.CostThreshold.Select(t => (int)(t * cost)).ToArray();
|
Levels = Info.CostThreshold.Select(t => (int)(t * cost)).ToArray();
|
||||||
|
RankAnim = new Animation("rank");
|
||||||
|
RankAnim.PlayFetchIndex("rank", () => Level - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Sync]
|
[Sync]
|
||||||
@@ -58,7 +62,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
Experience += amount;
|
Experience += amount;
|
||||||
|
|
||||||
while (Level < Levels.Count() - 1 && Experience >= Levels[Level])
|
while (Level < Levels.Count() && Experience >= Levels[Level])
|
||||||
{
|
{
|
||||||
Level++;
|
Level++;
|
||||||
|
|
||||||
@@ -83,5 +87,19 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
return Level > 0 ? Info.SpeedModifier[Level - 1] : 1;
|
return Level > 0 ? Info.SpeedModifier[Level - 1] : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
||||||
|
{
|
||||||
|
foreach (var r in rs)
|
||||||
|
yield return r;
|
||||||
|
|
||||||
|
if (self.Owner == Game.world.LocalPlayer && Level > 0)
|
||||||
|
{
|
||||||
|
RankAnim.Tick(); // hack
|
||||||
|
var bounds = self.GetBounds(true);
|
||||||
|
yield return new Renderable(RankAnim.Image,
|
||||||
|
new float2(bounds.Right - 6, bounds.Bottom - 8), "effect");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
mods/ra/rank.shp
Normal file
BIN
mods/ra/rank.shp
Normal file
Binary file not shown.
@@ -931,4 +931,7 @@
|
|||||||
<sequence name="3" start="0" length="15" src="fire3" />
|
<sequence name="3" start="0" length="15" src="fire3" />
|
||||||
<sequence name="4" start="0" length="15" src="fire4" />
|
<sequence name="4" start="0" length="15" src="fire4" />
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit name="rank">
|
||||||
|
<sequence name="rank" start="0" length="4" />
|
||||||
|
</unit>
|
||||||
</sequences>
|
</sequences>
|
||||||
Reference in New Issue
Block a user