예제 #1
0
    void CreateCityOnMap(City city, CityData cityData)
    {
        // Create new party on map
        MapCity newCityOnMap = Instantiate(cityOnMapTemplate, MapManager.Instance.GetParentTransformByType(GetComponent <MapCity>())).GetComponent <MapCity>();
        // city to original position on map
        //newCityOnMap.GetComponent<RectTransform>().offsetMin = new Vector2(cityData.cityMapPosition.offsetMinX, cityData.cityMapPosition.offsetMinY);
        //newCityOnMap.GetComponent<RectTransform>().offsetMax = new Vector2(cityData.cityMapPosition.offsetMaxX, cityData.cityMapPosition.offsetMaxY);
        // place it to original position on map based on the tile coordinates
        Vector3 cityPositionOffset = new Vector3(8f, 8f, 0);

        newCityOnMap.transform.position = MapManager.Instance.GetWorldPositionByCoordinates(cityData.cityMapCoordinates) - cityPositionOffset;
        // create links between city on map and city
        newCityOnMap.LCity = city;
        city.LMapCity      = newCityOnMap;
        // rename it
        newCityOnMap.gameObject.name = city.CityName;
        // Create city label on map
        MapObjectLabel newCityOnMapLabel = Instantiate(cityOnMapLabelTemplate, MapManager.Instance.GetParentTransformByType(GetComponent <MapObjectLabel>())).GetComponent <MapObjectLabel>();

        // Link city to the lable and label to the city
        newCityOnMap.GetComponent <MapObject>().Label = newCityOnMapLabel;
        newCityOnMapLabel.MapObject = newCityOnMap.GetComponent <MapObject>();
        // activate city label on map
        newCityOnMapLabel.gameObject.SetActive(true);
        // set color according to the player color preference
        newCityOnMap.SetColor(GetPlayerByFaction(city.CityCurrentFaction).PlayerColor);
        // activate city on map
        newCityOnMap.gameObject.SetActive(true);
    }
예제 #2
0
    public IEnumerator EnterCityEditMode(MapCity mapCity)
    {
        //Debug.Log("EnterCityEditMode");
        mapCity.DimmLabel();
        // Block mouse input
        // InputBlocker inputBlocker = transform.root.Find("MiscUI/InputBlocker").GetComponent<InputBlocker>();
        InputBlocker.SetActive(true);
        // Wait for all animations to finish
        // this depends on the labelDimTimeout parameter in MapObject, we add additional 0.1f just in case
        yield return(new WaitForSeconds(mapCity.GetComponent <MapObject>().LabelDimTimeout + 0.1f));

        // Unblock mouse input
        InputBlocker.SetActive(false);
        // map manager change to browse mode back
        // . - this is done by OnDisable() automatically in MapManager
        //MapManager mapManager = transform.parent.GetComponent<MapManager>();
        //mapManager.SetMode(MapManager.Mode.Browse);
        // Deactivate map manager with map
        MapManager.Instance.gameObject.SetActive(false);
        // Deactivate this map menu
        gameObject.SetActive(keepEnabledAfterStart);
        // Note: everything below related to mapManager or mapScreen will not be processed, because map manager is disabled
        // Activate city view = go to city edit mode
        transform.root.GetComponentInChildren <UIManager>().GetComponentInChildren <EditPartyScreen>(true).SetEditPartyScreenActive(mapCity.LCity);
    }