public Worker(Point2D position, ref VirtualIntelligence Master, ref IMoveUnitStats WorkerStats) : base(position, ref Master, ref WorkerStats) { _goingToResource = true; _unitStats = (RTS.WorkerStats)WorkerStats; _target = _masterRef.TheMap.FindResource(_masterRef, position); NewPath(_target.Position); }
public Unit(Bitmap image, Point2D position, ref VirtualIntelligence VIMaster, int Health) : base(ref image, position) { _deathListeningUnits = new List <Aggressive> (); idle = false; _doomed = false; _health = Health; if (VIMaster != null) { Master = VIMaster; } }
public MoveUnit(Point2D position, ref VirtualIntelligence Master, ref IMoveUnitStats Stats) : base(Stats.Image, position, ref Master, Stats.MaxHealth) { _currentTimer = 1f; _currentMovePoint = position; _increaseRate = Stats.Speed / GameMain.CalculationsPerSecond; _stats = Stats; GameMain.DrawList.Add(this); GameMain.MoveUnitList.Add(this); GameMain.MoveUnitProcessList.Add(this); xChange = 0f; yChange = 0f; }
private Building CreateBuilding(ref BuildingStats stats, float x, float y) { Point2D location = new Point2D(); location.X = x; location.Y = y; VirtualIntelligence masterAI = null; Building NewBuilding = new Building(ref stats, location, ref masterAI); GameMain.DrawList.Add(NewBuilding); _grid.Add(location, NewBuilding); //_allUnits.Add (NewBuilding); return(NewBuilding); }
public Resource FindResource(VirtualIntelligence TeamAI, Point2D FromPos) { Resource [] ResourceArray = _allResources.ToArray(); Resource current = ResourceArray[0]; float currentDistance = getDistance(FromPos, current.Position); foreach (Resource R in ResourceArray) { float testDistance = getDistance(FromPos, R.Position); if (testDistance < currentDistance) { current = R; currentDistance = testDistance; } } return(current); }
public Unit findTarget(Point2D Position, VirtualIntelligence SearchersTeam) { Unit NearestTarget = null; float distanceToTarget = 999999999f; foreach (Unit U in _allUnits) { if (U.Master != SearchersTeam) { float dist = getDistance(Position, U.Position); if (dist < distanceToTarget) { NearestTarget = U; distanceToTarget = dist; } } } return(NearestTarget); }
public Building(ref BuildingStats BuildingStats, Point2D position, ref VirtualIntelligence Master) : base(BuildingStats.image, position, ref Master, BuildingStats.health) { _buildingStatsRef = BuildingStats; _timer = 0f; _intact = true; }
public void GenerateLevel() { //Make the wall's image Wall.SetImage(VisibleUnit.AddBitmap("wall.png", "wallBitmap")); //Make the Resource's's image Resource.SetImage(VisibleUnit.AddBitmap("Resource.png", "resourceBitmap")); int NumOTeams = 0; StreamReader reader = new StreamReader(_mapLocation); try { string currentLine = reader.ReadLine(); while (currentLine != null) { //create border if (currentLine.StartsWith("d")) { string [] dimensions = currentLine.Split(new char [] { 'd', ' ' }); int width = int.Parse(dimensions [1]); int height = int.Parse(dimensions [2]); for (int i = 0; i <= width; i++) { CreateWall(i, 0); } for (int i = 1; i <= height; i++) { CreateWall(0, i); } for (int i = 1; i <= width; i++) { CreateWall(i, height); } for (int i = 1; i <= (height - 1); i++) { CreateWall(width, i); } } else //fill/line if (currentLine.StartsWith("f")) { string [] dimensions = currentLine.Split(new char [] { 'f', ' ' }); int left = int.Parse(dimensions [1]); int right = int.Parse(dimensions [3]); int top = int.Parse(dimensions [2]); int bottom = int.Parse(dimensions [4]); //across for (int h = top; h <= bottom; h++) { //height for (int w = left; w <= right; w++) { CreateWall(w, h); } } } else //create wall if (currentLine.StartsWith("w")) { string [] coordinates = currentLine.Split(new char [] { 'w', ' ' }); CreateWall(float.Parse(coordinates [1]), float.Parse(coordinates [2])); } else //create team base if (currentLine.StartsWith("t")) { string [] coordinates = currentLine.Split(new char [] { 't', ' ' }); //home base Building HomeBase = CreateBuilding(ref GameMain.MasterGameStats._buildingHome, float.Parse(coordinates [1]), float.Parse(coordinates [2])); //Archery Building Archery = CreateBuilding(ref GameMain.MasterGameStats._buildingArchery, float.Parse(coordinates [3]), float.Parse(coordinates [4])); //Barraks Building Barraks = CreateBuilding(ref GameMain.MasterGameStats._buildingBarraks, float.Parse(coordinates [5]), float.Parse(coordinates [6])); Map thisMap = this; VirtualIntelligence teamIntelligence = new VirtualIntelligence(ref thisMap, HomeBase, Archery, Barraks, GameMain.MasterGameStats._teams.Pop(), _TeamColors[NumOTeams]); if (NumOTeams < _TeamColors.Length - 1) { NumOTeams++; } else { NumOTeams = 0; } GameMain.BuildingsProcessList.Add(teamIntelligence); GameMain.BuildingsProcessList.Add(HomeBase); GameMain.BuildingsProcessList.Add(Archery); GameMain.BuildingsProcessList.Add(Barraks); } else //Create Resource if (currentLine.StartsWith("r")) { string [] coordinates = currentLine.Split(new char [] { 'r', ' ' }); CreateResource(float.Parse(coordinates [1]), float.Parse(coordinates [2])); } currentLine = reader.ReadLine(); } } finally { reader.Close(); } }
public Aggressive(Point2D position, ref VirtualIntelligence Master, ref IMoveUnitStats AggressiveStats) : base(position, ref Master, ref AggressiveStats) { _listener = new DeathListener(diaog); _unitStats = (AggressiveMoveUnitStats)AggressiveStats; }