Buildings now aware of what race they are owned by

git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1134 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
beedee
2007-07-07 07:57:07 +00:00
parent a8ea8d624a
commit 3f052e425f
3 changed files with 27 additions and 1 deletions

View File

@@ -7,6 +7,13 @@ using System.IO;
namespace OpenRa.TechTreeTest
{
[Flags]
public enum BuildingRace
{
Allies = 1,
Soviet = 2
}
class Building
{
readonly string friendlyName;
@@ -38,6 +45,14 @@ namespace OpenRa.TechTreeTest
set { techLevel = value; }
}
BuildingRace owner;
public BuildingRace Owner
{
get { return owner; }
set { owner = value; }
}
public Building(string tag, string friendlyName)
{
this.friendlyName = friendlyName;

View File

@@ -28,7 +28,7 @@ namespace OpenRa.TechTreeTest
box.SizeMode = PictureBoxSizeMode.AutoSize;
box.Image = b.Icon;
toolTip1.SetToolTip(box, b.Tag);
toolTip1.SetToolTip(box, b.Tag + "\n" + b.Owner.ToString());
buildableItems.Controls.Add(box);

View File

@@ -31,6 +31,17 @@ namespace OpenRa.TechTreeTest
string s = section.GetValue("Prerequisite", "").ToUpper();
b.Prerequisites = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
b.TechLevel = int.Parse(section.GetValue("TechLevel", "-1"));
s = section.GetValue("Owner", "allies");
if (string.IsNullOrEmpty(s)) continue;
string[] frags = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (frags.Length > 1)
{
b.Owner = BuildingRace.Allies | BuildingRace.Soviet;
}
else
{
b.Owner = (BuildingRace)Enum.Parse(typeof(BuildingRace), frags[0], true);
}
}
}