private void ButtonAction(GameObject buttonObject, SelectedAction sa, Tower tower) { if (Scroller.IsDragging()) { return; // don't do button action while scrolling } // destroy the info panel, if it was present if (infoPanel != null) { Destroy(infoPanel); } BuildManager buildManager = BuildManager.instance; if (sa == SelectedAction.SetRallyPoint) { buildManager.StartRallyPointSelector(); // destroy the menu; deselecting the lymph node also destroys the menu, so that works fine // todo: if a design decision is made to not deselect the node after starting the action, // then this has to be redone, because not destroying the menu leaves the selected button buildManager.DeselectLymphNode(); return; } if (buildManager.GetSelectedAction() == sa) // if this button is already selected, do the action { tempButton = null; buildManager.DoSelectedAction(tower); // destroy the menu; deselecting the lymph node also destroys the menu, so that works fine // todo: if a design decision is made to not deselect the node after starting the action, // then this has to be redone, because not destroying the menu leaves the selected button buildManager.DeselectLymphNode(); } else // if this button isn't selected, just select it (if the action is possible) { ResetPreviouslySelectedButton(); bool enoughMoney = buildManager.EnoughMoneyForAction(sa, tower); SetButtonAsSelected(buttonObject, enoughMoney); if (enoughMoney) { buildManager.SelectAction(sa); } else { buildManager.SelectAction(SelectedAction.Nothing); UIManager.instance.FlashNotEnoughMoney(1f); } // show info panel when selecting a button infoPanel = UIManager.instance.ShowInfoPanel(buttonObject.transform.parent, sa, tower); } }
public void ButtonBottomCenterAction() { //if (Scroller.instance.IsDragging()) return; // don't do button action while scrolling if (Scroller.IsDragging()) { return; // don't do button action while scrolling } //if (GameManager.instance.IsSettingRallyPoint()) return; // don't do button action if setting rally point on a melee tower GameManager.instance.StopSettingRallyPoint(); BuildManager buildManager = BuildManager.instance; buildManager.DeselectLymphNode(); if (buildManager.IsFinishedWithSS()) { if (WaveSpawner.instance.IsFinishedSpawning()) { return; } // if waves are already spawning, spawn next wave early if (WaveSpawner.instance.IsLevelStarted()) { WaveSpawner.instance.EarlyNextWave(); } else // else, start spawning waves { // start spawning waves of enemies WaveSpawner.instance.StartLevel(); // show UI elements that should be visible once the waves have started UIManager.instance.SetEnabledButtonBottomCenter(false); UIManager.instance.ShowPostSSUIElements(); } } else { buildManager.FinishWithSS(); } }
private void OnMouseUpAsButton() { // if there's a ui element above, don't do anything if (EventSystem.current.IsPointerOverGameObject()) { return; } //if (Scroller.instance.IsDragging()) return; if (Scroller.IsDragging()) { return; } if (buildManager == null) { return; //todo } // if we're still picking SS's if (!buildManager.IsFinishedWithSS()) { // if this SS hasn't been selected (and the number of selected < max allowed), select it if (!this.selected) { if (buildManager.SelectSS(this)) { // this SS has been successfully selected this.selected = true; HighlightOn(); // mark this square visually as selected } } else // if this SS is already selected, deselect it { buildManager.DeselectSS(this); this.selected = false; HighlightOff(); // mark this square visually as not selected } } }
private void OnMouseUpAsButton() { //Debug.Log("LymphNode.OnMouseUpAsButton"); // if there's a ui element above, don't do anything if (EventSystem.current.IsPointerOverGameObject()) { return; } // if (Scroller.instance.IsDragging()) return; if (Scroller.IsDragging()) { return; } // if this node's melee tower is selecting a new rally point, stop selecting it if ((GetTowerComponent() as MeleeTower) != null && ((MeleeTower)GetTowerComponent()).IsSettingRallyPoint()) { ((MeleeTower)GetTowerComponent()).StopSettingNewRallyPoint(); return; } // if another tower is setting a rally point, don't select this lymph node if (BuildManager.instance.IsSettingRallyPoint()) { return; } // if not selected, select it if (!selected) { BuildManager.instance.SelectLymphNode(this); Select(); // could be redundant, if it's called from BuildManager too UIManager uim = BuildManager.instance.gameObject.GetComponent <UIManager>(); if (IsVacant()) // if there's no tower here, show building menu { // vacant: show building menu menu = uim.ShowBuildingMenu(transform); } else // if there's a tower here, show other menu (sell, upgrade, rally point..) { // not vacant: show tower menu menu = uim.ShowTowerMenu(this.transform, GetTowerComponent()); } // if menu is too low or too high, scroll the camera int scrH = Screen.height; RectTransform menuRT = menu.GetComponent <RectTransform>(); float menuCenterY = menuRT.position.y; float menuHalfHeight = menuRT.sizeDelta.y / 2; float menuTop = menuCenterY + menuHalfHeight; float menuBottom = menuCenterY - menuHalfHeight; float spaceToBottom = 0 + menuBottom; float spaceToTop = scrH - menuTop; if (spaceToBottom < 10) { // scroll to bottom Scroller.ScrollToBottom(); } else if (spaceToTop < 10) { // scroll to top Scroller.ScrollToTop(); } } // if selected, deselect it else { BuildManager.instance.DeselectLymphNode(); Deselect(); // redundant, called from BuildManager too } }