Rank moved to new trait.
This commit is contained in:
@@ -26,9 +26,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"Value is a list of the upgrade types to grant")]
|
||||
public readonly Dictionary<int, string[]> Upgrades = null;
|
||||
|
||||
[Desc("Palette for the chevron glyph rendered in the selection box.")]
|
||||
public readonly string ChevronPalette = "effect";
|
||||
|
||||
[Desc("Palette for the level up sprite.")]
|
||||
public readonly string LevelUpPalette = "effect";
|
||||
|
||||
@@ -42,10 +39,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
return new Dictionary<int, string[]>()
|
||||
{
|
||||
{ 200, new[] { "firepower", "damage", "speed", "reload", "inaccuracy" } },
|
||||
{ 400, new[] { "firepower", "damage", "speed", "reload", "inaccuracy" } },
|
||||
{ 800, new[] { "firepower", "damage", "speed", "reload", "inaccuracy" } },
|
||||
{ 1600, new[] { "firepower", "damage", "speed", "reload", "inaccuracy", "eliteweapon", "selfheal" } }
|
||||
{ 200, new[] { "firepower", "damage", "speed", "reload", "inaccuracy", "rank" } },
|
||||
{ 400, new[] { "firepower", "damage", "speed", "reload", "inaccuracy", "rank" } },
|
||||
{ 800, new[] { "firepower", "damage", "speed", "reload", "inaccuracy", "rank" } },
|
||||
{ 1600, new[] { "firepower", "damage", "speed", "reload", "inaccuracy", "rank", "eliteweapon", "selfheal" } }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,15 +105,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Sounds", "LevelUp", self.Owner.Country.Race);
|
||||
self.World.AddFrameEndTask(w => w.Add(new CrateEffect(self, "levelup", info.LevelUpPalette)));
|
||||
|
||||
if (Level == 1)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (!self.IsDead)
|
||||
w.Add(new Rank(self, info.ChevronPalette));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,18 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Flags]
|
||||
public enum ReferencePoints
|
||||
{
|
||||
Top = 0,
|
||||
VCenter = 1,
|
||||
Bottom = 2,
|
||||
|
||||
Left = 0 << 2,
|
||||
HCenter = 1 << 2,
|
||||
Right = 2 << 2,
|
||||
}
|
||||
|
||||
[Desc("Displays a custom animation if conditions are satisfied.")]
|
||||
public class WithDecorationInfo : UpgradableTraitInfo, ITraitInfo
|
||||
{
|
||||
@@ -27,7 +39,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Palette to render the sprite in. Reference the world actor's PaletteFrom* traits.")]
|
||||
public readonly string Palette = "chrome";
|
||||
|
||||
[Desc("Pixel offset relative to the top-left point of the actor's bounds.")]
|
||||
[Desc("Point in the actor's bounding box used as reference for offsetting the decoration image." +
|
||||
"Possible values are any combination of Top, VCenter, Bottom and Left, HCenter, Right separated by a comma.")]
|
||||
public readonly ReferencePoints ReferencePoint = ReferencePoints.Top | ReferencePoints.Left;
|
||||
|
||||
[Desc("Pixel offset relative to the actor's bounding box' reference point.")]
|
||||
public readonly int2 Offset = int2.Zero;
|
||||
|
||||
[Desc("The Z offset to apply when rendering this decoration.")]
|
||||
@@ -61,6 +77,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
anim.PlayRepeating(info.Sequence);
|
||||
}
|
||||
|
||||
public void PlaySingleFrame(int frame)
|
||||
{
|
||||
anim.PlayFetchIndex(info.Sequence, () => frame);
|
||||
}
|
||||
|
||||
public virtual bool ShouldRender(Actor self) { return true; }
|
||||
|
||||
public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
|
||||
@@ -91,11 +112,35 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var pxPos = wr.ScreenPxPosition(self.CenterPosition);
|
||||
var actorBounds = self.Bounds;
|
||||
actorBounds.Offset(pxPos.X, pxPos.Y);
|
||||
pxPos = new int2(actorBounds.Left, actorBounds.Top);
|
||||
|
||||
var img = anim.Image;
|
||||
var imgSize = img.Size.ToInt2();
|
||||
pxPos = pxPos.WithX(pxPos.X + imgSize.X / 2).WithY(pxPos.Y + imgSize.Y / 2);
|
||||
|
||||
switch (info.ReferencePoint & (ReferencePoints)3)
|
||||
{
|
||||
case ReferencePoints.Top:
|
||||
pxPos = pxPos.WithY(actorBounds.Top + imgSize.Y / 2);
|
||||
break;
|
||||
case ReferencePoints.VCenter:
|
||||
pxPos = pxPos.WithY((actorBounds.Top + actorBounds.Bottom) / 2);
|
||||
break;
|
||||
case ReferencePoints.Bottom:
|
||||
pxPos = pxPos.WithY(actorBounds.Bottom - imgSize.Y / 2);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (info.ReferencePoint & (ReferencePoints)(3 << 2))
|
||||
{
|
||||
case ReferencePoints.Left:
|
||||
pxPos = pxPos.WithX(actorBounds.Left + imgSize.X / 2);
|
||||
break;
|
||||
case ReferencePoints.HCenter:
|
||||
pxPos = pxPos.WithX((actorBounds.Left + actorBounds.Right) / 2);
|
||||
break;
|
||||
case ReferencePoints.Right:
|
||||
pxPos = pxPos.WithX(actorBounds.Right - imgSize.X / 2);
|
||||
break;
|
||||
}
|
||||
|
||||
pxPos += info.Offset;
|
||||
var renderPos = wr.Position(pxPos);
|
||||
|
||||
27
OpenRA.Mods.Common/Traits/Render/WithRankDecoration.cs
Normal file
27
OpenRA.Mods.Common/Traits/Render/WithRankDecoration.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
public class WithRankDecorationInfo : WithDecorationInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new WithRankDecoration(init.Self, this); }
|
||||
}
|
||||
|
||||
public class WithRankDecoration : WithDecoration
|
||||
{
|
||||
public WithRankDecoration(Actor self, WithRankDecorationInfo info) : base(self, info) { }
|
||||
|
||||
protected override void UpgradeLevelChanged(Actor self, int oldLevel, int newLevel)
|
||||
{
|
||||
PlaySingleFrame(newLevel - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user