fixed powerbar colours,darkening, position. Moved lerping into Graphics.Util
This commit is contained in:
@@ -236,12 +236,23 @@ namespace OpenRa.Game
|
|||||||
//draw bar
|
//draw bar
|
||||||
float2 powerTop = new float2(bottom.X, bottom.Y + (top.Y - bottom.Y) * (Game.LocalPlayer.PowerProvided / (float)scale));
|
float2 powerTop = new float2(bottom.X, bottom.Y + (top.Y - bottom.Y) * (Game.LocalPlayer.PowerProvided / (float)scale));
|
||||||
|
|
||||||
for(int i = 7; i < 11; i++)
|
var color = Color.LimeGreen;
|
||||||
lineRenderer.DrawLine(bottom + new float2(i, 0), powerTop + new float2(i, 0), Color.LimeGreen, Color.LimeGreen);
|
if (Game.LocalPlayer.GetPowerState() == PowerState.Low)
|
||||||
|
color = Color.Orange;
|
||||||
|
if (Game.LocalPlayer.GetPowerState() == PowerState.Critical)
|
||||||
|
color = Color.Red;
|
||||||
|
|
||||||
|
var color2 = Graphics.Util.Lerp(0.25f, color, Color.Black);
|
||||||
|
|
||||||
|
for(int i = 11; i < 13; i++)
|
||||||
|
lineRenderer.DrawLine(bottom + new float2(i, 0), powerTop + new float2(i, 0), color, color);
|
||||||
|
for (int i = 13; i < 15; i++)
|
||||||
|
lineRenderer.DrawLine(bottom + new float2(i, 0), powerTop + new float2(i, 0), color2, color2);
|
||||||
|
|
||||||
lineRenderer.Flush();
|
lineRenderer.Flush();
|
||||||
|
|
||||||
//draw indicator
|
//draw indicator
|
||||||
float2 drainedPosition = new float2(bottom.X , bottom.Y + (top.Y - bottom.Y)*(Game.LocalPlayer.PowerDrained/(float) scale));
|
float2 drainedPosition = new float2(bottom.X + 2 , bottom.Y + (top.Y - bottom.Y)*(Game.LocalPlayer.PowerDrained/(float) scale) + 2);
|
||||||
|
|
||||||
buildPaletteRenderer.DrawSprite(powerIndicatorSprite, drainedPosition, PaletteType.Chrome);
|
buildPaletteRenderer.DrawSprite(powerIndicatorSprite, drainedPosition, PaletteType.Chrome);
|
||||||
buildPaletteRenderer.Flush();
|
buildPaletteRenderer.Flush();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
namespace OpenRa.Game.Graphics
|
namespace OpenRa.Game.Graphics
|
||||||
{
|
{
|
||||||
@@ -111,5 +112,19 @@ namespace OpenRa.Game.Graphics
|
|||||||
bitmap.UnlockBits(bits);
|
bitmap.UnlockBits(bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color Lerp(float t, Color a, Color b)
|
||||||
|
{
|
||||||
|
return Color.FromArgb(
|
||||||
|
LerpChannel(t, a.A, b.A),
|
||||||
|
LerpChannel(t, a.R, b.R),
|
||||||
|
LerpChannel(t, a.G, b.G),
|
||||||
|
LerpChannel(t, a.B, b.B));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int LerpChannel(float t, int a, int b)
|
||||||
|
{
|
||||||
|
return (int)((1 - t) * a + t * b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,22 +33,8 @@ namespace OpenRa.Game.Traits
|
|||||||
var orig = b.GetPixel(x, y);
|
var orig = b.GetPixel(x, y);
|
||||||
var lum = (int)(255 * orig.GetBrightness());
|
var lum = (int)(255 * orig.GetBrightness());
|
||||||
var desat = Color.FromArgb(orig.A, lum, lum, lum);
|
var desat = Color.FromArgb(orig.A, lum, lum, lum);
|
||||||
b.SetPixel(x, y, Lerp(frac, orig, desat));
|
b.SetPixel(x, y, Graphics.Util.Lerp(frac, orig, desat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color Lerp(float t, Color a, Color b)
|
|
||||||
{
|
|
||||||
return Color.FromArgb(
|
|
||||||
LerpChannel(t, a.A, b.A),
|
|
||||||
LerpChannel(t, a.R, b.R),
|
|
||||||
LerpChannel(t, a.G, b.G),
|
|
||||||
LerpChannel(t, a.B, b.B));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int LerpChannel(float t, int a, int b)
|
|
||||||
{
|
|
||||||
return (int)((1 - t) * a + t * b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user