Mercurial > repos > IBDev-IBBoard.WarFoundry.API
comparison api/Objects/UnitType.cs @ 256:958ecd7b2844
Re #270: Add multiple categories to API
* Add Categories property
* Add method to add Category
* Tie up Categories with MainCategory for default behaviour
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 17 May 2010 20:03:05 +0000 |
parents | cdda78975be1 |
children | 435eb28b4549 |
comparison
equal
deleted
inserted
replaced
255:0db25d5d0992 | 256:958ecd7b2844 |
---|---|
32 private String notes = ""; | 32 private String notes = ""; |
33 private List<UnitType> containedTypes = new List<UnitType>(); | 33 private List<UnitType> containedTypes = new List<UnitType>(); |
34 private Dictionary<string, string> extraData = new Dictionary<string, string>(); | 34 private Dictionary<string, string> extraData = new Dictionary<string, string>(); |
35 private Dictionary<string, AbstractLimit> slotLimits = new Dictionary<string, AbstractLimit>(); | 35 private Dictionary<string, AbstractLimit> slotLimits = new Dictionary<string, AbstractLimit>(); |
36 private Dictionary<string, UnitMemberType> unitMemberTypes = new Dictionary<string, UnitMemberType>(); | 36 private Dictionary<string, UnitMemberType> unitMemberTypes = new Dictionary<string, UnitMemberType>(); |
37 private List<Category> cats = new List<Category>(); | |
38 | |
37 | 39 |
38 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) | 40 public UnitType(string id, string typeName, Race parentRace) : base(id, typeName) |
39 { | 41 { |
40 race = parentRace; | 42 race = parentRace; |
41 } | 43 } |
70 { | 72 { |
71 get { return race; } | 73 get { return race; } |
72 } | 74 } |
73 | 75 |
74 /// <value> | 76 /// <value> |
75 /// Gets or sets the <see cref=" Category"/> that this unit type is a member of. | 77 /// Gets or sets the default <see cref=" Category"/> that this unit type is a member of. |
78 /// If it is not already in the collection of categories then it will be added. | |
76 /// </value> | 79 /// </value> |
77 public virtual Category MainCategory | 80 public virtual Category MainCategory |
78 { | 81 { |
79 get | 82 get |
80 { | 83 { |
81 return mainCat; | 84 return mainCat; |
82 } | 85 } |
83 set | 86 set |
84 { | 87 { |
85 mainCat = value; | 88 mainCat = value; |
89 AddCategory(value); | |
90 } | |
91 } | |
92 /// <summary> | |
93 /// Gets the collection of <see cref="Category"/> objects that this UnitType can be a member of | |
94 /// </summary> | |
95 public Category[] Categories | |
96 { | |
97 get | |
98 { | |
99 return cats.ToArray(); | |
100 } | |
101 } | |
102 | |
103 /// <summary> | |
104 /// Adds a category to the set of categories that this unit can be taken from. The first category added will automatically become the MainCategory. | |
105 /// </summary> | |
106 /// <param name="cat"> | |
107 /// A <see cref="Category"/> that this unit can be taken from | |
108 /// </param> | |
109 public void AddCategory(Category cat) | |
110 { | |
111 if (!cats.Contains(cat)) | |
112 { | |
113 cats.Add(cat); | |
114 | |
115 if (cats.Count == 1) | |
116 { | |
117 MainCategory = cat; | |
118 } | |
86 } | 119 } |
87 } | 120 } |
88 | 121 |
89 /// <value> | 122 /// <value> |
90 /// Gets or sets the minimum size of each unit of this type. Note: This should be set AFTER MaxSize, otherwise an unintended default value may be set for the minimum | 123 /// Gets or sets the minimum size of each unit of this type. Note: This should be set AFTER MaxSize, otherwise an unintended default value may be set for the minimum |