示例#1
0
    public WorldToScreenElement Add(GameObject uiPrefab, Transform anchorTransform, Vector3 offset)
    {
        GameObject           instanceObject = Instantiate(uiPrefab, _visibleGameObject.transform);
        WorldToScreenElement uiElement      = new WorldToScreenElement(instanceObject.transform, anchorTransform, offset);

        _handledTransforms.Add(uiElement);
        return(uiElement);
    }
示例#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;
    }
示例#3
0
 public void Remove(WorldToScreenElement worldUiObject)
 {
     _handledTransforms.Remove(worldUiObject);
     Destroy(worldUiObject.UiTransform.gameObject);
     Destroy(worldUiObject.AnchorTransform.gameObject);
 }