示例#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;
	}