示例#1
0
 private CityManager(int seed)
 {
     this._random            = new System.Random(seed);
     _possibleCityPlaceables = new List <CityPlaceable>
     {
         Resources.Load <CityPlaceable>(Util.PathTo("ProceduralCity")),
     };
     _placedCities         = new List <CityPlaceable>();
     cityWorldToScreenView = Resources.Load <CityWorldToScreenView>(Util.PathTo("CityWorldToScreenUi"));
 }
示例#2
0
    public void OnPlacementPositionFound(object cityToPlaceObject)
    {
        ThreadsafePlaceable cityToPlace = (ThreadsafePlaceable)cityToPlaceObject;
        CityPlaceable       city        = GameObject.Instantiate((CityPlaceable)cityToPlace.MapPlaceable, cityToPlace.Position,
                                                                 Quaternion.identity);

        Debug.Log("City placed at: " + cityToPlace.Position);
        if (!_placementController.PlaceObject(city))
        {
            GameObject.Destroy(city.gameObject);
            return;
        }

        _placedCities.Add(city);

        WorldToScreenElement uiGameObject = _worldToScreenManager.Add(
            cityWorldToScreenView.gameObject,
            city.gameObject.transform, new Vector3(0, 50f, 0));
        CityWorldToScreenView worldToScreenView =
            uiGameObject.UiTransform.gameObject.GetComponent <CityWorldToScreenView>();

        worldToScreenView.City = city;
    }