diff --git a/OpenRa.DataStructures/Tuple.cs b/OpenRa.DataStructures/Tuple.cs index ebd08dedf8..f5260fcfbb 100644 --- a/OpenRa.DataStructures/Tuple.cs +++ b/OpenRa.DataStructures/Tuple.cs @@ -37,4 +37,12 @@ namespace OpenRa public Tuple(A a, B b, C c, D d) { this.a = a; this.b = b; this.c = c; this.d = d; } } + + public static class Tuple + { + public static Tuple New(A a, B b, C c) + { + return new Tuple(a, b, c); + } + } } diff --git a/OpenRa.FileFormats/PaletteRemap.cs b/OpenRa.FileFormats/PaletteRemap.cs index f4d3b57c41..92fda46b50 100644 --- a/OpenRa.FileFormats/PaletteRemap.cs +++ b/OpenRa.FileFormats/PaletteRemap.cs @@ -8,7 +8,9 @@ namespace OpenRa.FileFormats { public class PaletteRemap { + int offset; List remapColors = new List(); + Color shadowColor; public PaletteRemap(Stream s) { @@ -23,14 +25,26 @@ namespace OpenRa.FileFormats remapColors.Add(Color.FromArgb(r, g, b)); } } + + offset = 80; + } + + public PaletteRemap( Color shadowColor ) + { + this.shadowColor = shadowColor; } public Color GetRemappedColor(Color original, int index) { - if (index < 80 || index >= 96) - return original; + if (remapColors.Count > 0) + { + if (index < offset || index >= offset + remapColors.Count) + return original; - return remapColors[index - 80]; + return remapColors[index - offset]; + } + + return original.A > 0 ? shadowColor : original; } } } diff --git a/OpenRa.Game/Bullet.cs b/OpenRa.Game/Bullet.cs index 6c3e05d445..38d15a4c78 100644 --- a/OpenRa.Game/Bullet.cs +++ b/OpenRa.Game/Bullet.cs @@ -11,7 +11,7 @@ namespace OpenRa.Game interface IEffect { void Tick(); - IEnumerable> Render(); + IEnumerable> Render(); Player Owner { get; } } @@ -94,16 +94,32 @@ namespace OpenRa.Game foreach (var victim in hitActors) victim.InflictDamage(FiredBy, this, (int)GetDamageToInflict(victim)); } - } + } + + const float height = .1f; - public IEnumerable> Render() + public IEnumerable> Render() { if (anim != null) - yield return Pair.New(anim.Image, - float2.Lerp( + { + var pos = float2.Lerp( Src.ToFloat2(), VisualDest.ToFloat2(), - (float)t / TotalTime()) - 0.5f * anim.Image.size); + (float)t / TotalTime()) - 0.5f * anim.Image.size; + + if (Projectile.High || Projectile.Arcing) + { + if (Projectile.Shadow) + yield return Tuple.New(anim.Image, pos, 8); /* todo: shadow pal */ + + var at = (float)t / TotalTime(); + var highPos = pos - new float2(0, (VisualDest - Src).Length * height * 4 * at * (1 - at)); + + yield return Tuple.New(anim.Image, highPos, Owner.Palette); + } + else + yield return Tuple.New(anim.Image, pos, Owner.Palette); + } } float GetMaximumSpread() diff --git a/OpenRa.Game/Explosion.cs b/OpenRa.Game/Explosion.cs index 3e8fe08c78..1180031d3f 100644 --- a/OpenRa.Game/Explosion.cs +++ b/OpenRa.Game/Explosion.cs @@ -24,9 +24,9 @@ namespace OpenRa.Game public void Tick() { anim.Tick(); } - public IEnumerable> Render() + public IEnumerable> Render() { - yield return Pair.New(anim.Image, pos.ToFloat2() - 0.5f * anim.Image.size); + yield return Tuple.New(anim.Image, pos.ToFloat2() - 0.5f * anim.Image.size, 0); } public Player Owner { get { return null; } } diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 9f371fdb52..35af6590be 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -46,7 +46,8 @@ namespace OpenRa.Game Rules.LoadRules(mapName); for (int i = 0; i < 8; i++) - players.Add(i, new Player(i, i, string.Format("Multi{0}", i), Race.Allies)); + players.Add(i, new Player(i, i, string.Format("Multi{0}", i), + Race.Allies)); localPlayerIndex = localPlayer; diff --git a/OpenRa.Game/Graphics/HardwarePalette.cs b/OpenRa.Game/Graphics/HardwarePalette.cs index d76e423a0f..3f8fd32791 100644 --- a/OpenRa.Game/Graphics/HardwarePalette.cs +++ b/OpenRa.Game/Graphics/HardwarePalette.cs @@ -10,7 +10,7 @@ namespace OpenRa.Game.Graphics { class HardwarePalette : Sheet { - const int maxEntries = 8; + const int maxEntries = 16; int allocated = 0; public HardwarePalette(Renderer renderer, Map map, int rotate) @@ -22,6 +22,8 @@ namespace OpenRa.Game.Graphics foreach (string remap in new string[] { "blue", "red", "orange", "teal", "salmon", "green", "gray" }) AddPalette(new Palette(pal, new PaletteRemap(FileSystem.Open(remap + ".rem")))); + AddPalette(new Palette(pal, new PaletteRemap(Color.FromArgb(178, 0, 0, 0)))); + using (var bitmapCopy = new Bitmap(bitmap)) for (int j = 0; j < maxEntries; j++) for (int i = 0; i < 7; i++) diff --git a/OpenRa.Game/Graphics/Util.cs b/OpenRa.Game/Graphics/Util.cs index 2f3f11f181..d4d7ab60c7 100644 --- a/OpenRa.Game/Graphics/Util.cs +++ b/OpenRa.Game/Graphics/Util.cs @@ -58,7 +58,7 @@ namespace OpenRa.Game.Graphics public static void FastCreateQuad(Vertex[] vertices, ushort[] indices, float2 o, Sprite r, int palette, int nv, int ni) { - float2 attrib = new float2(palette / 8.0f, channelSelect[(int)r.channel]); + float2 attrib = new float2(palette / 16.0f, channelSelect[(int)r.channel]); vertices[nv] = new Vertex(KLerp(o, r.size, 0), r.FastMapTextureCoords(0), attrib); vertices[nv + 1] = new Vertex(KLerp(o, r.size, 1), r.FastMapTextureCoords(1), attrib); diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index 41bcfebd4e..3e440623bd 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -53,6 +53,24 @@ namespace OpenRa.Game.Graphics spriteRenderer.DrawSprite(image.First, loc, (owner != null) ? owner.Palette : 0); } + } + + void DrawSpriteList(RectangleF rect, + IEnumerable> images) + { + foreach (var image in images) + { + var loc = image.b; + + if (loc.X > rect.Right || loc.X < rect.Left + - image.a.bounds.Width) + continue; + if (loc.Y > rect.Bottom || loc.Y < rect.Top + - image.a.bounds.Height) + continue; + + spriteRenderer.DrawSprite(image.a, loc, image.c); + } } public void Draw() @@ -71,7 +89,7 @@ namespace OpenRa.Game.Graphics DrawSpriteList(a.self.Owner, rect, a.RenderRoof(a.self)); /* RUDE HACK */ foreach (IEffect e in Game.world.Effects) - DrawSpriteList(e.Owner, rect, e.Render()); + DrawSpriteList(rect, e.Render()); uiOverlay.Draw(); diff --git a/OpenRa.Game/MainWindow.cs b/OpenRa.Game/MainWindow.cs index a759587ef0..2c2262d17b 100755 --- a/OpenRa.Game/MainWindow.cs +++ b/OpenRa.Game/MainWindow.cs @@ -61,10 +61,12 @@ namespace OpenRa.Game Game.world.Add( new Actor( "mcv", Game.map.Offset + new int2( 5, 5 ), Game.players[ 1 ]) ); Game.world.Add( new Actor( "mcv", Game.map.Offset + new int2( 7, 5 ), Game.players[ 2 ] ) ); Game.world.Add( new Actor( "mcv", Game.map.Offset + new int2( 9, 5 ), Game.players[ 0 ] ) ); - Game.world.Add( new Actor( "jeep", Game.map.Offset + new int2( 9, 15 ), Game.players[ 1 ] ) ); + Game.world.Add( new Actor( "jeep", Game.map.Offset + new int2( 9, 14 ), Game.players[ 1 ] ) ); Game.world.Add( new Actor( "3tnk", Game.map.Offset + new int2( 12, 7 ), Game.players[ 1 ] ) ); Game.world.Add(new Actor("ca", Game.map.Offset + new int2(40, 7), Game.players[1])); Game.world.Add(new Actor("e1", Game.map.Offset + new int2(9, 13), Game.players[1])); + Game.world.Add(new Actor("arty", Game.map.Offset + new int2(10, 13), Game.players[1])); + Game.world.Add(new Actor("v2rl", Game.map.Offset + new int2(11, 12), Game.players[1])); renderer.BuildPalette(Game.map); sidebar = new Sidebar(renderer, Game.LocalPlayer);