public void OnHoverBuildButton(GameObject butObj) { Debug.Log(butObj); if (!ValidForInteraction()) { return; } int idx = UI.GetItemIndex(butObj, buildButtons); if (UIControl.UseDragNDropMode()) { UITooltip.Show(buildableList[idx], UI.GetCorner(buildButtons[idx].rectT, 1), 0, new Vector3(0, .25f, 0)); } else { if (UIControl.UsePieMenuForBuild()) { UITooltip.Show(sInfo.buildableList[idx]); } else { UITooltip.Show(sInfo.buildableList[idx], UI.GetCorner(buildButtons[idx].rectT, 1), 0, new Vector3(0, .25f, 0)); } } if (UIControl.UsePointNBuildMode()) { TowerManager.ShowSampleTower(sInfo.buildableList[idx].prefabID, sInfo); } }
public void OnBuildButton(GameObject butObj, int pointerID = -1) { if (!ValidForInteraction()) { return; } int idx = UI.GetItemIndex(butObj, buildButtons); if (UIControl.UsePointNBuildMode() && UIControl.InTouchMode()) { if (touchModeButtonIdx != idx) { if (touchModeButtonIdx >= 0) { ClearTouchModeSelect(); } touchModeButtonIdx = idx; buildButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(true); OnHoverBuildButton(butObj); return; } ClearTouchModeSelect(); } if (UIControl.UsePointNBuildMode()) { if (!CheckCost(sInfo.buildableList[idx].GetCost())) { return; } TowerManager.BuildTower(sInfo.buildableList[idx], sInfo.platform, sInfo.nodeID); SelectControl.ClearNode(); OnExitBuildButton(null); Hide(); TowerManager.HideSampleTower(); } if (UIControl.UseDragNDropMode()) { if (!CheckCost(buildableList[idx].GetCost())) { return; } SelectControl.ClearUnit(); UITowerSelect.Hide(); TowerManager.CreateDragNDropTower(buildableList[idx]); } }
public void OnExitBuildButton(GameObject butObj) { if (!ValidForInteraction()) { return; } UITooltip.Hide(); if (UIControl.UsePointNBuildMode()) { TowerManager.HideSampleTower(); } }
public override void Start() { base.Start(); buildableList = TowerManager.GetBuildableList(); for (int i = 0; i < buildableList.Count; i++) { AddBuildButton(i, buildableList[i].icon, buildableList[i].GetCost()[0].ToString("f0")); } if (UIControl.UsePointNBuildMode()) { thisObj.SetActive(false); } else if (UIControl.UseDragNDropMode()) { UpdateBuildableStatus(); canvasGroup.alpha = 1; thisObj.SetActive(true); } }
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; }