예제 #1
0
파일: Map.cs 프로젝트: Wolfie13/RTSAI
	//
	public ResourceTile GetNearestResourceTile (IVec2 Pos, ResourceType type)
	{
		ResourceTile nearestTile = null;
		int nearestDistance = int.MaxValue;
		foreach (MapObject mo in entities) {
			if (mo is ResourceTile) {
				ResourceTile rt = mo as ResourceTile;
				if (rt.m_resource == type) {
					int distance = Pos.manhatttanDistance(rt.m_MapPos);
					if (distance < nearestDistance){
						nearestDistance = distance;
						nearestTile = rt;
					}
				}
				
			}
		}
		return nearestTile;
	}
예제 #2
0
파일: Map.cs 프로젝트: Wolfie13/RTSAI
	public Building GetNearestBuilding (IVec2 Pos, BuildingType type)
	{
		Building nearestBuilding = null;
		int nearestDistance = int.MaxValue;
		foreach (MapObject mo in entities) {
			if (mo is Building) {
				Building b = mo as Building;
				if (b.m_buildingtype == type) {
					int distance = Pos.manhatttanDistance(b.m_MapPos);
					if (distance < nearestDistance){
						nearestDistance = distance;
						nearestBuilding = b;
					}
				}
				
			}
		}
		return nearestBuilding;
	}
예제 #3
0
	public Building GetNearestBuilding (IVec2 Pos, BuildingType type)
	{
		Building nearestBuilding = null;
		int nearestDistance = int.MaxValue;
		foreach (Building b in Buildings) {
			if (b.m_buildingtype == type) {
				int distance = Pos.manhatttanDistance(b.m_MapPos);
				if (distance < nearestDistance){
					nearestDistance = distance;
					nearestBuilding = b;
				}
			}
		}
		return nearestBuilding;
	}