//Places the firehouse GameObject on the map void PlaceFireHouse() { Vector2 fireHouseTilePos = new Vector2(); Map.GetFireHouseCoordinates(out fireHouseTilePos); GameObject house = (GameObject)Instantiate(firehousePrefab); Vector3 housePos = GetPositionForTile(Mathf.FloorToInt(fireHouseTilePos.x), Mathf.FloorToInt(fireHouseTilePos.y)); housePos.x += 0.5f; housePos.y = house.transform.position.y; housePos.z -= 0.5f; house.transform.position = housePos; EGFirehouse firehouse = house.GetComponent <EGFirehouse>(); firehouse.SetTGMap(this); Vector3 camPos = Camera.main.transform.position; camPos.x = housePos.x; camPos.z = housePos.z; Camera.main.transform.position = camPos; EGDispatcher dispatcher = GetComponent <EGDispatcher>(); dispatcher.SetFirehouse(firehouse); }
void Start() { _tileMap = GetComponent <TGMap>(); _dispatcher = GetComponent <EGDispatcher>(); //The orthographic size if half the height of the camera float vertExtent = Camera.main.orthographicSize; //Calculate the half height of the screen float horizExtent = Camera.main.orthographicSize * Screen.width / Screen.height; float mapX = _tileMap.Map.Width * _tileMap.tileSize; float mapZ = _tileMap.Map.Height * _tileMap.tileSize; //Limit the camera to within half the width/height of the screen //of the bounds of the map minX = 0 + horizExtent; maxX = mapX - horizExtent; minZ = -(mapZ - vertExtent); maxZ = 0 - vertExtent; }