Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate API/Objects/ArmyCategory.cs @ 499:2fc99446f9c9 default tip
Add initial structure for categories of equipment
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 16 Oct 2016 20:26:44 +0100 |
parents | aac77204ae0e |
children |
rev | line source |
---|---|
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 // This file (ArmyCategory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 using System.Collections.Generic; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 namespace IBBoard.WarFoundry.API.Objects |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 /// <summary> |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 /// Summary description for ArmyCategory. |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 /// </summary> |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 public class ArmyCategory : WarFoundryObject, ICostedWarFoundryObject |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 private Category category; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 private Army parentArmy; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 private double pointsTotal; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 private List<Unit> units; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 private Dictionary<string, int> unitTypes; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 private DoubleValChangedDelegate PointsValueChangedMethod; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 public event ObjectAddDelegate UnitAdded; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 public event ObjectRemoveDelegate UnitRemoved; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 public event DoubleValChangedDelegate PointsValueChanged; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 public ArmyCategory(Army army, Category cat) : base() |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 parentArmy = army; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 category = cat; |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
29 cat.NameChanged += new StringValChangedDelegate(cat_NameChanged); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 PointsValueChangedMethod = new DoubleValChangedDelegate(PointsValueChangedHandler); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 units = new List<Unit>(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 unitTypes = new Dictionary<string,int>(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 public Category Category |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 get { return category; } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 public Army ParentArmy |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 get { return parentArmy; } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 public override string ID |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 get |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 return Category.ID; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 set |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 Category.ID = value; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 public override string Name |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 get { return category.Name; } |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
60 set |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 category.Name = value; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 internal void AddUnit(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 { |
367
1a70ca80ef41
Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
337
diff
changeset
|
68 //TODO: Put back a similar check |
1a70ca80ef41
Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
337
diff
changeset
|
69 //List<FailedUnitRequirement> failedReqs = ParentArmy.CanAddUnit(unit); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 units.Add(unit); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 unit.Category = this; |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
72 unit.PointsValueChanged += PointsValueChangedMethod; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 int unitTypeCount; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 unitTypes.TryGetValue(unit.UnitType.ID, out unitTypeCount); |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
75 unitTypes[unit.UnitType.ID] = unitTypeCount + 1; |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
76 TotalPoints += unit.Points; |
367
1a70ca80ef41
Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
337
diff
changeset
|
77 OnUnitAdded(unit); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 internal void RemoveUnit(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 { |
367
1a70ca80ef41
Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
337
diff
changeset
|
82 //TODO: Put back a similar check |
1a70ca80ef41
Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
337
diff
changeset
|
83 //List<FailedUnitRequirement> failedReqs = ParentArmy.CanRemoveUnit(unit); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 units.Remove(unit); |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
85 unitTypes[unit.UnitType.ID] = unitTypes[unit.UnitType.ID] - 1; |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
86 TotalPoints -= unit.Points; |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
87 unit.PointsValueChanged -= PointsValueChangedMethod; |
367
1a70ca80ef41
Re #27: Define unit requirements
IBBoard <dev@ibboard.co.uk>
parents:
337
diff
changeset
|
88 OnUnitRemoved(unit); |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 public int GetUnitTypeCount(UnitType unitType) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
93 return unitTypes.ContainsKey(unitType.ID) ? unitTypes[unitType.ID] : 0; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 public Unit[] GetUnits() |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 return units.ToArray(); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
101 public Unit[] GetUnits(UnitType unitType) |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
102 { |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
103 List<Unit> filteredUnits = new List<Unit>(); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
104 foreach (Unit unit in units) |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
105 { |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
106 if (unit.UnitType.Equals(unitType)) |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
107 { |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
108 filteredUnits.Add(unit); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
109 } |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
110 } |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
111 return filteredUnits.ToArray(); |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
112 } |
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
113 |
471
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
114 public Unit[] GetMainUnits() |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
115 { |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
116 List<Unit> mainUnits = new List<Unit>(); |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
117 |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
118 foreach (Unit unit in units) |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
119 { |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
120 if (unit.ParentUnit == null) |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
121 { |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
122 mainUnits.Add(unit); |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
123 } |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
124 } |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
125 |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
126 return mainUnits.ToArray(); |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
127 } |
0a2068897793
Re #359: Add "only contained" attribute to unit types
IBBoard <dev@ibboard.co.uk>
parents:
367
diff
changeset
|
128 |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
129 private double TotalPoints |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
130 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
131 get { return pointsTotal; } |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
132 set |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
133 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
134 double oldVal = pointsTotal; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
135 pointsTotal = value; |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
136 |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
137 if (oldVal != pointsTotal) |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
138 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
139 OnPointsValueChanged(oldVal, pointsTotal); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
140 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
141 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
142 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
143 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
144 public double Points |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
145 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
146 get { return TotalPoints; } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
147 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
148 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
149 private void PointsValueChangedHandler(WarFoundryObject obj, double oldVal, double newVal) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
150 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
151 if (obj is Unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
152 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
153 double diff = newVal - oldVal; |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
154 TotalPoints += diff; |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
155 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
156 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
157 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
158 protected void OnUnitAdded(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
159 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
160 if (UnitAdded != null) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
161 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
162 UnitAdded(unit); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
163 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
164 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
165 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
166 protected void OnUnitRemoved(Unit unit) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
167 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
168 if (UnitRemoved != null) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
169 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
170 UnitRemoved(unit); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
171 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
172 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
173 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
174 protected virtual void OnPointsValueChanged(double oldValue, double newValue) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
175 { |
489
aac77204ae0e
Re #410: Create "N units per M models in parent unit" requirement
IBBoard <dev@ibboard.co.uk>
parents:
471
diff
changeset
|
176 if (PointsValueChanged != null) |
337
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
177 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
178 PointsValueChanged(this, oldValue, newValue); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
179 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
180 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
181 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
182 protected void cat_NameChanged(WarFoundryObject obj, string oldValue, string newValue) |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
183 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
184 OnNameChanged(oldValue, newValue); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
185 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
186 |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
187 public int GetPointsPercentage() |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
188 { |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
189 return (int)Math.Round((Points / ParentArmy.MaxPoints) * 100, 0); |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
190 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
191 } |
3c4a6403a88c
* Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
192 } |