public void Init(HexGrid _hexGrid)
    {
        hexGrid = _hexGrid;

        MyU.GetCom(out Button newMapButton, "Button_New", transform);
        MyU.GetCom(out createNewMapBg, "Bg_CreateNewMap", transform);
        MyU.GetCom(out Toggle generateToggle, "Toggle_Generate", createNewMapBg);
        MyU.GetCom(out Toggle wrappingToggle, "Toggle_Wrapping", createNewMapBg);
        MyU.GetCom(out Button smallButton, "Button_Small", createNewMapBg);
        MyU.GetCom(out Button mediumButton, "Button_Medium", createNewMapBg);
        MyU.GetCom(out Button largeButton, "Button_Large", createNewMapBg);
        MyU.GetCom(out Button cancelButton, "Button_Cancel", createNewMapBg);

        MyU.AddValChange(generateToggle, val => isGenerate = val);
        MyU.AddValChange(wrappingToggle, val => isWrapping = val);
        MyU.AddClick(newMapButton, ShowHideCreateNewMapBg, true);
        MyU.AddClick(cancelButton, ShowHideCreateNewMapBg, false);
        MyU.AddClick(smallButton, CreateNewMap, 0);
        MyU.AddClick(mediumButton, CreateNewMap, 1);
        MyU.AddClick(largeButton, CreateNewMap, 2);
    }
Esempio n. 2
0
    private void Awake()
    {
        Instance = this;
        mainCam  = Camera.main;
        hexGrid  = GameObject.Find("HexGrid").GetComponent <HexGrid>();

        #region Get Init Component

        MyU.GetCom(out editModeToggle, "Toggle_EditMode", transform);

        MyU.GetGo(out leftEditorBg, "Editor_LeftBg", transform);
        MyU.BeginParent(leftEditorBg);
        MyU.GetCom(out ToggleGroup colorToggleGroup, "ToggleGroup_Color");
        MyU.GetCom(out Toggle elevationToggle, "Toggle_Elevation");
        MyU.GetCom(out Slider elevationSlider, "Slider_Elevation");
        MyU.GetCom(out Toggle waterToggle, "Toggle_Water");
        MyU.GetCom(out Slider waterSlider, "Slider_Water");
        MyU.GetCom(out ToggleGroup riverToggleGroup, "ToggleGroup_River");
        MyU.GetCom(out ToggleGroup roadToggleGroup, "ToggleGroup_Road");
        MyU.GetCom(out Slider brushSlider, "Slider_BrustSize");
        MyU.GetCom(out Toggle gridToggle, "Toggle_Grid");

        MyU.GetGo(out rightEditorBg, "Editor_RightBg", transform);
        MyU.BeginParent(rightEditorBg);
        MyU.GetCom(out Toggle urbanToggle, "Toggle_Urban");
        MyU.GetCom(out Slider urbanSlider, "Slider_Urban");
        MyU.GetCom(out Toggle farmToggle, "Toggle_Farm");
        MyU.GetCom(out Slider farmSlider, "Slider_Farm");
        MyU.GetCom(out Toggle plantToggle, "Toggle_Plant");
        MyU.GetCom(out Slider plantSlider, "Slider_Plant");
        MyU.GetCom(out Toggle specialToggle, "Toggle_Special");
        MyU.GetCom(out Slider specialSlider, "Slider_Special");
        MyU.GetCom(out ToggleGroup walledToggleGroup, "ToggleGroup_Walled");
        MyU.GetCom(out Transform fileBg, "Bg_File");
        MyU.GetCom(out saveLoadUI, fileBg);
        MyU.GetCom(out newMapUI, fileBg);


        var colorToggles  = colorToggleGroup.GetComponentsInChildren <Toggle>();
        var riverToggles  = riverToggleGroup.GetComponentsInChildren <Toggle>();
        var roadToggles   = roadToggleGroup.GetComponentsInChildren <Toggle>();
        var walledToggles = walledToggleGroup.GetComponentsInChildren <Toggle>();

        MyU.AddValChange(plantSlider, val => activePlantLevel = (int)val);
        MyU.AddValChange(editModeToggle, SetEditMode);

        MyU.AddValChange(elevationToggle, bo => applyElevation   = bo);
        MyU.AddValChange(elevationSlider, val => activeElevation = (int)val);
        MyU.AddValChange(waterToggle, bo => applyWaterLevel      = bo);
        MyU.AddValChange(waterSlider, val => activeWaterLevel    = (int)val);
        MyU.AddValChange(brushSlider, val => brushSize           = (int)val);
        MyU.AddValChange(gridToggle, ShowGrid);

        MyU.AddValChange(urbanToggle, bo => applyUrbanLevel       = bo);
        MyU.AddValChange(urbanSlider, val => activeUrbanLevel     = (int)val);
        MyU.AddValChange(farmToggle, bo => applyFarmLevel         = bo);
        MyU.AddValChange(farmSlider, val => activeFarmLevel       = (int)val);
        MyU.AddValChange(specialToggle, bo => applySpecialLevel   = bo);
        MyU.AddValChange(specialSlider, val => activeSpecialLevel = (int)val);
        MyU.AddValChange(plantToggle, bo => applyPlantLevel       = bo);

        InitToggles(colorToggles, SetColor);
        InitToggles(riverToggles, SetRiverMode);
        InitToggles(roadToggles, SetRoadMode);
        InitToggles(walledToggles, SetWalledMode);

        #endregion

        saveLoadUI.Init(hexGrid);
        newMapUI.Init(hexGrid);
    }