public void Init() { var inGameWindows = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows"); //Debug.Log(inGameWindows); GUIGOModeSelect = VeinPlanter.Instantiate(VeinPlanter.bundleAssets.LoadAsset <GameObject>("Assets/UI/VeinGardener/UIVeinPlanterMode.prefab")); AttachGameObject(GUIGOModeSelect, inGameWindows.transform); UIVGMode = GUIGOModeSelect.GetComponent <UIVeinGardenerMode>(); if (!UIVGMode.IsInit) { UIVGMode.Init(); } Debug.Log("Registering callbacks for VG.Mode"); UIVGMode.UIOnCreateNewVeinGroup = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.AddVeinGroup); Hide(); }; UIVGMode.UIOnDeleteVein = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.RemoveVein); Hide(); }; UIVGMode.UIOnDeleteVeinGroup = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.RemoveVeinGroup); Hide(); }; UIVGMode.UIOnExtendVeinGroup = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.ExtendVein); Hide(); }; UIVGMode.UIOnModifyVeinGroup = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.ModifyVeinGroup); Hide(); }; UIVGMode.UIOnWorldEditShowAll = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.PlanetVeins); Hide(); }; UIVGMode.UIOnCreateNewVeinGroupTypeChanged = newValue => { _veinGardenerState.newVeinGroupType = (EVeinType)(newValue + 1); }; UIVGMode.UIOnClose = () => { _veinGardenerState.ChangeMode(eVeinModificationMode.Deactivated); Hide(); }; Debug.Log("Populating UIVGGroupEdit.VeinTypeDropdown"); UIVGMode.VeinTypeDropdown.ClearOptions(); foreach (EVeinType tabType in Enum.GetValues(typeof(EVeinType))) { if (tabType == EVeinType.Max || tabType == EVeinType.None) { continue; } int veinProduct = PlanetModelingManager.veinProducts[(int)tabType]; ItemProto itemProto = veinProduct != 0 ? LDB.items.Select(veinProduct) : null; if (itemProto != null) { UIVGMode.VeinTypeDropdown.options.Add(new UnityEngine.UI.Dropdown.OptionData() { image = itemProto.iconSprite, text = itemProto.name.Translate() }); } } }
public void Init() { var inGameWindows = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows"); //Debug.Log(inGameWindows); ContentParent = inGameWindows.GetComponent <RectTransform>(); GUIGOVeinGroupModify = VeinPlanter.Instantiate(bundleAssets.LoadAsset <GameObject>("Assets/UI/VeinGardener/UIVeinGardenerGroupEdit.prefab")); AttachGameObject(GUIGOVeinGroupModify, inGameWindows.transform); UIVGGroupEdit = GUIGOVeinGroupModify.GetComponent <UIVeinGardenerGroupEdit>(); if (!UIVGGroupEdit.IsInit) { UIVGGroupEdit.Init(); } UIVGGroupEdit.Hide(); //GUIGOVeinGroupModify.SetActive(true); Debug.Log("Registering callbacks for VG.GroupEdit"); UIVGGroupEdit.UIOnVeinTypeChanged = newValue => { if (IsNotValidVGState) { return; } EVeinType newType = (EVeinType)newValue + 1; PlanetData.VeinGroup veinGroup = _veinGardenerState.localPlanet.veinGroups[_veinGardenerState.veinGroupIndex]; if (veinGroup.type == newType) { return; } Gardener.VeinGroup.ChangeType(_veinGardenerState.veinGroupIndex, newType, _veinGardenerState.localPlanet); int extingProductId = Gardener.VeinGroup.GetProductType(_veinGardenerState.veinGroupIndex, _veinGardenerState.localPlanet); UIVGGroupEdit.ProductTypeDropdown.value = _veinGardenerState.products.FindIndex(p => p == extingProductId); }; UIVGGroupEdit.UIOnProductTypeChanged = newValue => { if (IsNotValidVGState) { return; } PlanetData.VeinGroup veinGroup = _veinGardenerState.localPlanet.veinGroups[_veinGardenerState.veinGroupIndex]; int newProductId = _veinGardenerState.products[newValue]; int extingProductId = Gardener.VeinGroup.GetProductType(_veinGardenerState.veinGroupIndex, _veinGardenerState.localPlanet); if (newProductId == extingProductId) { return; } Debug.Log("Changing product type for vein: " + _veinGardenerState.veinGroupIndex + "(" + veinGroup.type + ") to " + _veinGardenerState.products[newValue]); Gardener.VeinGroup.ChangeType(_veinGardenerState.veinGroupIndex, veinGroup.type, _veinGardenerState.localPlanet, productId: newProductId); }; UIVGGroupEdit.UIOnVeinAmountSliderValueChanged = newValue => { Debug.Log("VG.GroupEdit : VeinAmountSliderValueChanged : " + newValue); Gardener.VeinGroup.UpdateVeinAmount(_veinGardenerState.veinGroupIndex, (long)(newValue / _veinGardenerState.oreMultiplier), _veinGardenerState.localPlanet); PlanetData.VeinGroup veinGroup = _veinGardenerState.localPlanet.veinGroups[_veinGardenerState.veinGroupIndex]; if (veinGroup.type == EVeinType.Oil) { Gardener.VeinGroup.UpdateVeinAmount(_veinGardenerState.veinGroupIndex, (long)(newValue / VeinData.oilSpeedMultiplier), _veinGardenerState.localPlanet); } else { Gardener.VeinGroup.UpdateVeinAmount(_veinGardenerState.veinGroupIndex, (long)(newValue / oreMultiplier), _veinGardenerState.localPlanet); } }; //UnityEngine.UI.Dropdown VeinTypeDropdown = GetNamedComponentInChildren<UnityEngine.UI.Dropdown>(GUIGOVeinGroupModify, "VeinTypeDropdown"); //UnityEngine.UI.Dropdown ProductTypeDropdown = GetNamedComponentInChildren<UnityEngine.UI.Dropdown>(GUIGOVeinGroupModify, "ProductTypeDropdown"); //UnityEngine.UI.Dropdown ModeVeinTypeDropdown = GetNamedComponentInChildren<UnityEngine.UI.Dropdown>(GUIGOModeSelect, "VeinTypeDropdown"); Debug.Log("Populating UIVGGroupEdit.VeinTypeDropdown"); UIVGGroupEdit.VeinTypeDropdown.ClearOptions(); foreach (EVeinType tabType in Enum.GetValues(typeof(EVeinType))) { if (tabType == EVeinType.Max || tabType == EVeinType.None) { continue; } int veinProduct = PlanetModelingManager.veinProducts[(int)tabType]; ItemProto itemProto = veinProduct != 0 ? LDB.items.Select(veinProduct) : null; if (itemProto != null) { UIVGGroupEdit.VeinTypeDropdown.options.Add(new UnityEngine.UI.Dropdown.OptionData() { image = itemProto.iconSprite, text = itemProto.name.Translate() }); } } Debug.Log("Populating Group Edit Products"); UIVGGroupEdit.ProductTypeDropdown.ClearOptions(); foreach (int prodId in _veinGardenerState.products) { ItemProto itemProto = prodId != 0 ? LDB.items.Select(prodId) : null; if (itemProto != null) { UIVGGroupEdit.ProductTypeDropdown.options.Add(new UnityEngine.UI.Dropdown.OptionData() { image = itemProto.iconSprite, text = itemProto.name.Translate() }); } } UIVGGroupEdit.ContentTrans = GUIGOVeinGroupModify.GetComponent <RectTransform>(); }