/// <summary> /// Spawns the starting units of this player. /// </summary> public void SpawnStartUnits() { if (Game1.GetInstance().IsMultiplayerGame() && Game1.CURRENT_PLAYER != this) return; if (!Game1.GetInstance().IsMultiplayerGame()) { int unitCount = 25; CustomArrayList<Unit> temp_units = new CustomArrayList<Unit>(); // +1 to compensate for the engineer for (int i = 0; i < unitCount + 1; i++) { // Fill the list with dummy units Unit u = null; temp_units.AddLast(u); } UnitSelection selection = new UnitSelection(temp_units); UnitGroupPattern pattern = new CirclePattern(startLocation, selection, 90, 0); CustomArrayList<Point> points = pattern.ApplyPattern(); for (int i = 0; i < unitCount; i++) { Point p = points.ElementAt(i); if (i % 2 == 0) { //temp_units.AddLast(fastStore.getUnit(Unit.Type.Fast, p.X, p.Y)); } else { temp_units.AddLast(rangedStore.getUnit(Unit.Type.Ranged, p.X, p.Y)); } // Point p = points.ElementAt(i); //temp_units.AddLast(meleeStore.getUnit(Unit.Type.Melee, p.X, p.Y)); } } meleeStore.getUnit(Unit.Type.Engineer, startLocation.X, startLocation.Y); }
public UnitSelection GetSelectedUnits() { UnitSelection selection = new UnitSelection(); for (int i = 0; i < this.units.Count(); i++) { Unit unit = this.units.ElementAt(i); Console.WriteLine("Unit added"); if (unit.selected) selection.units.AddLast(unit); } return selection; }
public UnitSelection GetUnits() { UnitSelection selection = new UnitSelection(new CustomArrayList<Unit>()); for (int i = 0; i < this.units.Count(); i++) { Unit unit = this.units.ElementAt(i); if (this.selectBox.GetRectangle().Intersects(unit.GetDrawRectangle())) { selection.units.AddLast(unit); } } return selection; }
/// <summary> /// Spawns the starting units of this player. /// </summary> /// <param name="location">The location to spawn them at.</param> public void SpawnStartUnits(Point location) { LinkedList<Unit> temp_units = new LinkedList<Unit>(); for (int i = 0; i < 25; i++) { if( i % 2 == 0 ) temp_units.AddLast(new Engineer(this, 0, 0)); else temp_units.AddLast(new Bowman(this, 0, 0)); } UnitSelection selection = new UnitSelection(temp_units); UnitGroupPattern pattern = new CirclePattern(location, selection, 90, 0); LinkedList<Point> points = pattern.ApplyPattern(); for (int i = 0; i < temp_units.Count; i++) { temp_units.ElementAt(i).x = points.ElementAt(i).X; temp_units.ElementAt(i).y = points.ElementAt(i).Y; } }
public UnitSelection GetUnits() { UnitSelection selection = new UnitSelection(new LinkedList<Unit>()); foreach (Unit unit in units) { if (this.selectBox.GetRectangle().Contains((int)unit.x, (int)unit.y)) { selection.units.AddLast(unit); } } return selection; }
public UnitSelection GetSelectedUnits() { UnitSelection selection = new UnitSelection(); foreach (Unit unit in this.units) { if (unit.selected) selection.units.AddLast(unit); } return selection; }
/// <summary> /// Sets a unit selection at the given index. Valid ranges are 0 .. 9. /// Giving a parameter outside this, will result in IndexOutOfRangeException. /// </summary> /// <param name="index">The index, 0 .. 9</param> public void SetUnitSelectionAt(int index, UnitSelection units) { selections[index] = units; }
private UnitControlManager() { selections = new UnitSelection[10]; }