public static Vector2 FindClosestTarget(Zed zed) { var buildingLocation = new Vector2(); var humanLocation = new Vector2(); var target = new Vector2(); float closestBuilding = 1000; float closestHuman = 1000; if (HumanList.Count != 0) { foreach (var human in HumanList) { var distance = Vector2.Distance(zed.Position, human.Position); if (distance <= closestHuman) { closestHuman = distance; humanLocation = human.Position; } } } else if (BuildingList.Count != 0) { foreach (var building in BuildingList) { var distance = Vector2.Distance(zed.Position, building.Position); { if (distance <= closestBuilding) { closestBuilding = distance; buildingLocation = building.Position; } } } } if (closestHuman < closestBuilding) { target = humanLocation; } else { target = buildingLocation; } return(target); }
public static void PopulateZedList() { for (var i = 0; i < ZedQuantity; i++) { var zed = new Zed { Position = ZedSpawnPoint(), HasSpawned = true, IsAlive = true, Health = 1, Speed = 0.25f, ID = Guid.NewGuid().ToString(), boundingBox = new BoundingBox() }; StopZedsBunching(); ZedList.Add(zed); } }
public static void UpdateZedPosition(Zed zed, float rotation, Vector2 dir) { zed.Angle = rotation; zed.Position += dir * zed.Speed; }