public Direction DirectionTo(Unit u) { if (u.GetType() == typeof(Mage)) { Mage m = (Mage)u; if (m.XPos < XPos) { return(Direction.North); } else if (m.YPos > YPos) { return(Direction.East); } else if (m.XPos > XPos) { return(Direction.South); } else { return(Direction.West); } } else { return(Direction.North); } }
private int DistanceTo(Unit u) { if (u.GetType() == typeof(Mage)) { Mage m = (Mage)m; int d = Math.Abs(XPos - r.XPos) + Math.Abs(YPos - r.YPos); return(d); } else { return(0); } }
//numUnits = total num of units in the map public Map(int maxX, int maxY, int numUnits) { units = new Unit[numUnits]; for(int i = 0; i < numUnits/2; i++) { MeleeUnit m = new MeleeUnit(R.Next(0, maxX), R.Next(0, maxY), 100, 10, 1, 1, i % 2, "M"); Units[i] = m; } for (int j = numUnits/2; j < numUnits; j++) { RangedUnit r = new RangedUnit(R.Next(0, maxX), R.Next(0, maxY), 100, 10, 1, 1, j % 2, "R"); Units[j] = r; } for (int k = numUnits / 2; k < numUnits; k++) { Mage A = new Mage(R.Next(0, maxX), R.Next(0, maxY), 100, 10, 1, 1, k % 2, "A"); Units{k] = A; } } }
public override bool inRange(Unit u) { if (u.GetType() == typeof(Mage)) { Mage m = (Mage)u; if (DistanceTo(u) <= Range) { return(true); } else { return(false); } } else { return(false); } }