void Start() { if (!UIControl.ShowTextOverlay()) { gameObject.SetActive(false); return; } for (int i = 0; i < 30; i++) { if (i == 0) { overlayItemList.Add(rootOverlayItem.AddComponent <UITextOverlayItem>()); } else { overlayItemList.Add(UI.Clone(rootOverlayItem).GetComponent <UITextOverlayItem>()); } overlayItemList[i].Init(); } }
private void AddBuildButton(int idx, Sprite icon, string txt) { if (idx > 0) { buildButtons.Add(UIButton.Clone(buildButtons[0].rootObj, "Button" + (idx))); } buildButtons[idx].Init(); if (UIControl.InTouchMode() && UIControl.UsePointNBuildMode()) { buildButtons[idx].SetCallback(null, null, this.OnBuildButton, null); } else { buildButtons[idx].SetCallback(this.OnHoverBuildButton, this.OnExitBuildButton, this.OnBuildButton, null); } if (icon != null) { buildButtons[idx].imgMain.sprite = icon; } buildButtons[idx].lbMain.text = txt; }
public void OnClearSelectButton(GameObject butObj, int pointerID = -1) { if (!AbilityManager.IsEnabled()) { return; } if (touchModeButtonIdx >= 0) { ClearTouchModeSelect(); } else { UIControl.ClearSelectedAbility(); for (int i = 0; i < abilityButtons.Count; i++) { abilityButtons[i].imgHighlight.gameObject.SetActive(false); } } buttonClearSelect.SetActive(false); UITooltip.Hide(); }
public override void Start() { base.Start(); if (!PerkManager.IsEnabled()) { thisObj.SetActive(false); return; } if (PerkManager.UseRscManagerForCost()) { for (int i = 0; i < RscManager.GetResourceCount(); i++) { if (i > 0) { costItemList.Add(new UIObject(UI.Clone(costItemList[0].rootObj))); } costItemList[i].Init(); costItemList[i].imgMain.sprite = RscManager.GetRscIcon(i); } } else { costItemList[0].Init(); costItemList[0].imgMain.sprite = PerkDB.GetRscIcon(); } if (customLayout) { List <Perk> perkList = PerkManager.GetPerkList(); for (int i = 0; i < itemList.Count; i++) { itemList[i].Init(); itemList[i].SetCallback(null, null, this.OnItem, null); bool matched = false; for (int n = 0; n < perkList.Count; n++) { if (itemList[i].linkedPerkPID == perkList[n].prefabID) { itemList[i].linkedPerkIdx = n; matched = true; itemList[i].imgMain.sprite = perkList[n].icon; } } if (!matched) { Debug.LogWarning("No perk with matching prefab found"); itemList[i].rootObj.SetActive(false); continue; } itemList[i].UnparentConnector(); itemList[i].UnparentConnectorBase(); } } else { List <Perk> perkList = PerkManager.GetPerkList(); for (int i = 0; i < perkList.Count; i++) { if (i > 0) { itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i))); } itemList[i].Init(); itemList[i].SetCallback(null, null, this.OnItem, null); itemList[i].linkedPerkIdx = i; itemList[i].imgMain.sprite = perkList[i].icon; } } buttonPurchase.Init(); buttonPurchase.SetCallback(null, null, this.OnPurchaseButton, null); if (UIControl.IsGameScene()) { buttonClose.Init(); buttonClose.SetCallback(null, null, this.OnCloseButton, null); } if (!UIControl.IsGameScene()) { canvasGroup.alpha = 1; thisObj.SetActive(true); StartCoroutine(DelayUpdateList()); } else { thisObj.SetActive(false); } OnItem(itemList[0].rootObj); }
public static float GetScaleFactor() { return(UIControl.GetScaleReferenceWidth() / Screen.width); }
// Use this for initialization void Start() { GameObject lastSpaceObj = null; if (UIControl.IsGameScene()) { lifeItem.Init(); waveItem.Init(); UpdateLifeDisplay(GameControl.GetLife()); UpdateWaveDisplay(1); lastSpaceObj = spaceObjLife; } else { waveItem.rootObj.SetActive(false); spaceObjWave.SetActive(false); lifeItem.rootObj.SetActive(false); spaceObjLife.SetActive(false); } if (UIControl.IsGameScene() || PerkManager.UseRscManagerForCost()) { for (int i = 0; i < RscManager.GetResourceCount(); i++) { if (i > 0) { rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj))); } rscItemList[i].Init(); rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i); rscItemList[i].rectT.SetSiblingIndex(rscItemList[0].rectT.GetSiblingIndex() + i); } UpdateResourceDisplay(RscManager.GetResourceList()); lastSpaceObj = spaceObjRsc; } else { rscItemList[0].rootObj.SetActive(false); spaceObjRsc.SetActive(false); } if (!UIControl.IsGameScene() || !AbilityManager.IsEnabled() || AbilityManager.UseRscManagerForCost()) { sliderAbilityRsc.gameObject.SetActive(false); spaceObjAbility.SetActive(false); } else { imgAbilityRsc.sprite = AbilityDB.GetRscIcon(); UpdateAbilityRscDisplay(AbilityManager.GetRsc()); lastSpaceObj = spaceObjAbility; } if (!PerkManager.IsEnabled() || PerkManager.UseRscManagerForCost()) { perkRscItem.rootObj.SetActive(false); //spaceObjPerk.SetActive(false); lastSpaceObj.SetActive(false); } else { perkRscItem.Init(); perkRscItem.imgMain.sprite = PerkDB.GetRscIcon(); UpdatePerkRscDisplay(PerkManager.GetRsc()); } //~ if(!UIControl.DisablePerkScreen()){ //~ buttonPerk.Init(); //~ buttonPerk.SetCallback(null, null, this.OnPerkButton, null); //~ } //~ else{ //~ if(buttonPerk.rootObj!=null) buttonPerk.rootObj.SetActive(false); //~ } //~ buttonFF.Init(); //~ buttonFF.SetCallback(null, null, this.OnFFButton, null); //~ buttonPause.Init(); //~ buttonPause.SetCallback(null, null, this.OnPauseButton, null); }
void Awake() { instance = this; }
public void OnAbilityButton(GameObject butObj, int pointerID = -1) { int idx = UI.GetItemIndex(butObj, abilityButtons); if (UIControl.InTargetSelectionMode()) { if (AbilityManager.GetPendingTargetAbilityIndex() == idx || UIControl.GetPendingAbilityIdx() == idx) { abilityButtons[idx].imgHighlight.gameObject.SetActive(false); UIControl.ClearSelectedAbility(); buttonClearSelect.SetActive(false); return; } } Ability._Status status = AbilityManager.IsReady(idx); if (status != Ability._Status.Ready) { if (status == Ability._Status.OnCooldown) { GameControl.InvalidAction("Ability is on cooldown"); } if (status == Ability._Status.InsufficientRsc) { GameControl.InvalidAction("Insufficient resource"); } if (status == Ability._Status.UseLimitReached) { GameControl.InvalidAction("Use limit exceeded"); } return; } if (UIControl.InTouchMode()) { if (!AbilityManager.RequireTargetSelection(idx) && touchModeButtonIdx != idx) { if (touchModeButtonIdx >= 0) { ClearTouchModeSelect(); } touchModeButtonIdx = idx; abilityButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(true); OnHoverAbilityButton(butObj); buttonClearSelect.SetActive(true); return; } ClearTouchModeSelect(); } if (AbilityManager.RequireTargetSelection(idx)) { UIControl.SelectAbility(idx); abilityButtons[idx].imgHighlight.gameObject.SetActive(true); buttonClearSelect.SetActive(true); } else { AbilityManager.ActivateAbility(idx); abilityButtons[idx].lbMain.text = AbilityManager.GetAbility(idx).GetUseLimitText(); } }