Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        _cityPlaceable = GetComponent <CityPlaceable>();

        GameHandler gameHandler = FindObjectOfType <GameHandler>();

        _placementController = (PlacementController)gameHandler.PlacementController;
        _buildingManager     = (BuildingManager)gameHandler.BuildingManager;

        _streetData       = Resources.Load <BuildingData>(Util.PathTo("Street"));
        generationRoutine = StartCoroutine(GenerateCity(seed, maxCityProgress, _streetLengthMinMax, buildingProbability));
    }
Пример #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;
    }