fixed #26 etc
This commit is contained in:
@@ -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<A, B, C> New<A, B, C>(A a, B b, C c)
|
||||
{
|
||||
return new Tuple<A, B, C>(a, b, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ namespace OpenRa.FileFormats
|
||||
{
|
||||
public class PaletteRemap
|
||||
{
|
||||
int offset;
|
||||
List<Color> remapColors = new List<Color>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace OpenRa.Game
|
||||
interface IEffect
|
||||
{
|
||||
void Tick();
|
||||
IEnumerable<Pair<Sprite, float2>> Render();
|
||||
IEnumerable<Tuple<Sprite, float2, int>> Render();
|
||||
Player Owner { get; }
|
||||
}
|
||||
|
||||
@@ -96,14 +96,30 @@ namespace OpenRa.Game
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<Sprite, float2>> Render()
|
||||
const float height = .1f;
|
||||
|
||||
public IEnumerable<Tuple<Sprite, float2, int>> 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()
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace OpenRa.Game
|
||||
|
||||
public void Tick() { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Pair<Sprite, float2>> Render()
|
||||
public IEnumerable<Tuple<Sprite, float2, int>> 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; } }
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -55,6 +55,24 @@ namespace OpenRa.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSpriteList(RectangleF rect,
|
||||
IEnumerable<Tuple<Sprite, float2, int>> 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()
|
||||
{
|
||||
terrainRenderer.Draw( Game.viewport );
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user