harvesters show colors for each resource type

This commit is contained in:
Chris Forbes
2010-12-05 12:10:52 +13:00
parent 94715a1561
commit 3f47715c36
5 changed files with 23 additions and 13 deletions

View File

@@ -24,6 +24,8 @@ namespace OpenRA.Traits
public Sprite[][] Sprites;
public int PaletteIndex;
public PipType PipColor = PipType.Yellow;
public object Create(ActorInitializer init) { return new ResourceType(this); }
}

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Move;
using OpenRA.Mods.RA.Orders;
@@ -23,7 +22,6 @@ namespace OpenRA.Mods.RA
{
public readonly int Capacity = 28;
public readonly int PipCount = 7;
public readonly PipType PipColor = PipType.Yellow;
public readonly string[] Resources = { };
public readonly decimal FullyLoadedSpeed = .85m;
@@ -168,20 +166,27 @@ namespace OpenRA.Mods.RA
return;
ChooseNewProc(self, proc);
}
PipType GetPipAt(int i)
{
var n = i * Info.Capacity / Info.PipCount;
foreach (var rt in contents)
if (n < rt.Value)
return rt.Key.PipColor;
else
n -= rt.Value;
return PipType.Transparent;
}
public IEnumerable<PipType> GetPips(Actor self)
{
int numPips = Info.PipCount;
int n = contents.Values.Sum();
for (int i = 0; i < numPips; i++)
{
if (n * 1.0f / Info.Capacity > i * 1.0f / numPips)
yield return Info.PipColor;
else
yield return PipType.Transparent;
}
int numPips = Info.PipCount;
for (int i = 0; i < numPips; i++)
yield return GetPipAt(i);
}
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)

View File

@@ -137,6 +137,7 @@ World:
SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
ValuePerUnit: 30
Name: Tiberium
PipColor: Green
ResourceType@blue-tib:
ResourceType: 2
Palette: terrain
@@ -144,6 +145,7 @@ World:
SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12
ValuePerUnit: 60
Name: Blue Tiberium
PipColor: Red # todo: add a blue pip.
SmudgeLayer@SCORCH:
Type:Scorch
Types:sc1,sc2,sc3,sc4,sc5,sc6

View File

@@ -49,7 +49,6 @@ HARV:
Harvester:
Resources: Tiberium, Blue Tiberium
PipCount: 5
PipColor: Green
Capacity: 28
Mobile:
Speed: 6

View File

@@ -201,12 +201,14 @@ World:
SpriteNames: gold01,gold02,gold03,gold04
ValuePerUnit: 25
Name: Ore
PipColor: Yellow
ResourceType@gem:
ResourceType: 2
Palette: terrain
SpriteNames: gem01,gem02,gem03,gem04
ValuePerUnit: 50
Name: Gems
PipColor: Red
SmudgeLayer@SCORCH:
Type:Scorch
Types:sc1,sc2,sc3,sc4,sc5,sc6