public void OnUpgradeButton(int index) { if (UIMainControl.InTouchMode()) { if (currentState != 2) { currentState = 2; SetCurrentStateToTwo(index); return; } else { if (currentUpgradeIndex == index) { ClearState(); OnExitUpgradeButton(); } else { SetCurrentStateToTwo(index); return; } } } string exception = currentTower.Upgrade(index); if (exception != "") { UIMessage.DisplayMessage(exception); } }
private int currentButtonID = -1; //last touched button, for touch mode only public void OnTowerButton(GameObject butObj, int pointerID = -1) { int ID = GetButtonID(butObj); if (UIMainControl.InTouchMode() && !BuildManager.UseDragNDrop()) { if (currentButtonID >= 0) { buttonList[currentButtonID].imgHighlight.enabled = false; } if (currentButtonID != ID) { currentButtonID = ID; buttonList[ID].imgHighlight.enabled = true; OnHoverButton(butObj); return; } ClearTouchModeButton(); } string exception = BuildManager.BuildTower(ID, buildInfo, pointerID); if (exception != "") { UIMessage.DisplayMessage(exception); return; } buildInfo = null; if (!BuildManager.UseDragNDrop()) { Hide(); } }
private int currentButtonID = -1; //last touched button, for touch mode only public void OnAbilityButton(GameObject butObj, int pointerID = -1) { int ID = GetButtonID(butObj); if (UIMainControl.InTouchMode()) { if (currentButtonID >= 0) { buttonList[currentButtonID].imgHighlight.enabled = false; } if (currentButtonID != ID) { //OnAbilitySelectingTarget(true); //to turn on cancel button butCancelCanvasG.alpha = 1; butCancelCanvasG.interactable = true; currentButtonID = ID; buttonList[ID].imgHighlight.enabled = true; OnHoverButton(butObj); return; } ClearTouchModeButton(); } string exception = AbilityManager.SelectAbility(ID, pointerID); if (exception != "") { UIMessage.DisplayMessage(exception); } }
public void _Hide() { if (UIMainControl.InTouchMode()) { ClearTouchModeButton(); } UIMainControl.FadeOut(canvasGroup, 0.25f); StartCoroutine(DelayHide()); }
void Start() { if (!AbilityManager.IsOn() || AbilityManager.GetAbilityCount() == 0) { thisObj.SetActive(false); return; } List <Ability> abList = AbilityManager.GetAbilityList(); for (int i = 0; i < abList.Count; i++) { if (i == 0) { buttonList[0].Init(); } else if (i > 0) { buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "AbilityButton" + (i + 1))); } buttonList[i].imgIcon.sprite = abList[i].icon; buttonList[i].imgHighlight.enabled = false; buttonList[i].label.text = ""; if (abList[i].usedRemained > 0) { buttonList[i].label.text = abList[i].usedRemained.ToString(); } //else buttonList[i].label.text="∞"; if (UIMainControl.InTouchMode()) { buttonList[i].SetCallback(null, null, this.OnAbilityButton, null); } else { buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnAbilityButton, null); } } tooltipRscItem.Init(); butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>(); OnAbilitySelectingTarget(false); UIItemCallback cancelCallback = butCancelObj.AddComponent <UIItemCallback>(); cancelCallback.SetDownCallback(this.OnCancelAbilityButton); //cancelCallback.SetUpCallback(up); tooltipObj.SetActive(false); }
void Start() { List <Rsc> rscList = ResourceManager.GetResourceList(); for (int i = 0; i < rscList.Count; i++) { if (i == 0) { rscItemList[0].Init(); } else { rscItemList.Add(UIObject.Clone(rscItemList[0].rootObj, "Rsc" + (i + 1))); } rscItemList[i].imgRoot.sprite = rscList[i].icon; rscItemList[i].label.text = rscList[i].value.ToString(); } rscPanelObj.SetActive(false); //buttonParentDefaultPos=buttonParent.localPosition; towerPanelPosX = towerPanelRectT.localPosition.x; if (UIMainControl.InTouchMode()) { butSell.SetCallback(null, null, this.OnSellButton, null); butUpgrade1.SetCallback(null, null, this.OnUpgradeButton1, null); butUpgrade2.SetCallback(null, null, this.OnUpgradeButton2, null); } else { butSell.SetCallback(this.OnHoverSellButton, this.OnExitSellButton, this.OnSellButton, null); butUpgrade1.SetCallback(this.OnHoverUpgradeButton1, this.OnExitUpgradeButton, this.OnUpgradeButton1, null); butUpgrade2.SetCallback(this.OnHoverUpgradeButton2, this.OnExitUpgradeButton, this.OnUpgradeButton2, null); } butSell.imgHighlight.enabled = false; butUpgrade1.imgHighlight.enabled = false; butUpgrade2.imgHighlight.enabled = false; //thisObj.SetActive(false); }
public void _Show(UnitTower tower) { if (UIMainControl.InTouchMode()) { ClearState(); rscPanelObj.SetActive(false); } bool fadeIn = currentTower == null; currentTower = tower; UpdateDisplay(); //buttonParent.localPosition=buttonParentDefaultPos; thisT.localPosition = Vector3.zero; if (fadeIn) { UIMainControl.FadeIn(canvasGroup, 0.25f); } }
public void OnSellButton(GameObject butObj = null, int index = -1) { if (UIMainControl.InTouchMode()) { if (currentState != 1) { ClearState(); OnHoverSellButton(); currentState = 1; butSell.imgHighlight.enabled = true; return; } else { ClearState(); OnExitSellButton(); } } currentTower.Sell(); Hide(); }
void Start() { if (BuildManager.GetInstance() == null) { return; } List <UnitTower> towerList = BuildManager.GetTowerList(); for (int i = 0; i < towerList.Count; i++) { if (i == 0) { buttonList[0].Init(); } else if (i > 0) { buttonList.Add(UIButton.Clone(buttonList[0].rootObj, "BuildButton" + (i + 1))); } buttonList[i].imgIcon.sprite = towerList[i].iconSprite; buttonList[i].imgHighlight.enabled = false; if (UIMainControl.InTouchMode()) { buttonList[i].SetCallback(null, null, this.OnTowerButton, null); } else { buttonList[i].SetCallback(this.OnHoverButton, this.OnExitButton, this.OnTowerButton, null); } } if (!BuildManager.UseDragNDrop()) { canvasGroup.alpha = 0; rectT.localPosition = new Vector3(0, 99999, 0); } if (!BuildManager.UseDragNDrop() && UIMainControl.UsePieMenu()) { layoutGroup.enabled = false; tooltipObj.transform.localPosition -= new Vector3(0, 60, 0); } else { layoutGroup.enabled = true; } List <Rsc> rscList = ResourceManager.GetResourceList(); for (int i = 0; i < rscList.Count; i++) { if (i == 0) { tooltipRscItemList[0].Init(); } else { tooltipRscItemList.Add(UIObject.Clone(tooltipRscItemList[0].rootObj, "Rsc" + (i + 1))); } tooltipRscItemList[i].imgRoot.sprite = rscList[i].icon; tooltipRscItemList[i].label.text = rscList[i].value.ToString(); } if (!BuildManager.UseDragNDrop()) { butCancelObj.SetActive(false); } else { butCancelCanvasG = butCancelObj.AddComponent <CanvasGroup>(); butCancelObj.transform.SetAsLastSibling(); OnDragNDrop(false); } tooltipObj.SetActive(false); }