void ActivateTowerMenu() { //if placing a tower, a menu should not be activated if (attachedTower != null) { return; } //if another menu is active, don't just make more if (currentMenu != null) { return; } //if there is something in that cell if (currentCell.occupant != null) { //and that something is a tower spot currentSpot = currentCell.occupant.GetComponent <TowerSpot>(); if (currentSpot != null) { //and the tower spot contains a tower currentTower = currentSpot.Occupant; if (currentTower != null) { //instantiate tower menu object on canvas at tower point //hook tower up to menu buttons //pause game currentMenu = Instantiate(TowerMenuPrefab, mainCanvas.transform); currentMenu.GetComponent <RectTransform>().anchoredPosition = currentCell.transform.position; currentMenu.Init(currentTower); } } } }
private void Start() { towerMenu = GameObject.Find("TowerManager").GetComponent <TowerMenu>(); gameSystems = GameObject.Find("GameManager").GetComponent <GameSystems>(); canvas = GameObject.Find("Canvas").GetComponent <Transform>(); towerMenu.buttonList.Add(gameObject); gameObject.GetComponent <Button>().onClick.AddListener(TowerMenuSwitch); }
void Start() { btm = FindObjectOfType <BuildTowerMenu>(); towerRangeCircle = FindObjectOfType <TowerRangeCircle>(); tm = FindObjectOfType <TowerMenu>(); hero = FindObjectOfType <Hero>(); reinforcements = FindObjectOfType <Reinforcements>(); sh1 = FindObjectsOfType <SpecialHability>(); }
void Awake() { if (instance != null) { Destroy(this); } else { instance = this; } }
void Start() { // Set up the Tower Panels TowerMenu menu = buildTowerMenu.GetComponent <TowerMenu>(); // Fire menu.towerPanels[0].GetComponent <TowerPanel>().tower = FireTowers[0]; // Water menu.towerPanels[1].GetComponent <TowerPanel>().tower = WaterTowers[0]; // Energy menu.towerPanels[2].GetComponent <TowerPanel>().tower = EnergyTowers[0]; }
void OnMouseDown() { // Deactivate the build menu buildTowerMenu.SetActive(false); // Move the active menu to the tower activeTowerMenu.transform.position = this.transform.position; TowerMenu upgradeMenu = activeTowerMenu.GetComponent <TowerMenu> (); upgradeMenu.currentSlot = this.gameObject; // Set the appropriate upgrades TowerPanel upgradeA = upgradeMenu.towerPanels[0].GetComponent <TowerPanel> (); TowerPanel upgradeB = upgradeMenu.towerPanels[1].GetComponent <TowerPanel> (); activeTowerMenu.SetActive(true); }
public void Init() { EventManager = EventManager.InstancePublic; TowerShop = new TowerShop(this) { Price = 400 }; MoneyCounter = new MoneyCounter(this, 1000); LivesCounter = new LivesCounter(this, 100); //temp, parse var tempList = new List <TowerInfo>() { new TowerInfo("tower_1_square", 500, 650), new TowerInfo("tower_2_square", 900, 1100), new TowerInfo("tower_3_square", 0, 1500) }; TowerMenu = new TowerMenu(this, tempList); }
void OnMouseDown() { // Deactivate the build menu buildTowerMenu.SetActive(false); // Move the active menu to the tower activeTowerMenu.transform.position = this.transform.position; TowerMenu upgradeMenu = activeTowerMenu.GetComponent <TowerMenu> (); upgradeMenu.currentSlot = this.transform.parent.gameObject; // Set the appropriate upgrades TowerPanel upgradeA = upgradeMenu.towerPanels[0].GetComponent <TowerPanel> (); //TowerPanel upgradeB = upgradeMenu.towerPanels[1].GetComponent<TowerPanel> (); bool upgradeable = false; if (GetComponentInParent <Tower> ().number == 0) { upgradeA.tower = towerManager.GetComponent <TowerManager> ().getTower(GetComponentInParent <Tower> ().type, 1); upgradeA.number = 1; upgradeA.element_type = GetComponentInParent <Tower> ().type; upgradeable = true; //upgradeB.tower = towerManager.GetComponent<TowerManager> ().getTower (GetComponentInParent<Tower> ().element_type, 3); //upgradeB.number = 3; } activeTowerMenu.GetComponent <TowerMenu> ().number = 1; activeTowerMenu.SetActive(true); if (!upgradeable) { activeTowerMenu.GetComponent <TowerMenu> ().towerPanels [0].SetActive(false); } else { activeTowerMenu.GetComponent <TowerMenu> ().towerPanels [0].SetActive(true); } }
public void Start() { image = GetComponent <Image>(); originalColor = image.color; towerMenu = FindObjectOfType <TowerMenu>(); }
void Awake() { menu = GetComponentInParent <TowerMenu>(); }
void Start() { towerMenu = TowerMenu.Instance; balance = Balance.Instance; }
/// <summary> /// Generic function for handling responses to input events /// </summary> void HandleInput() { //pause game on space if (Input.GetKeyDown(KeyCode.Space)) { if (isPaused) { ResumeGame(); } else { PauseGame(); } } //bring up pause menu on escape if (Input.GetKeyUp(KeyCode.Escape)) { if (attachedTower != null) { Destroy(attachedTower.gameObject); } else if (currentMenu != null && currentMenu.gameObject.activeSelf) { currentMenu.gameObject.SetActive(false); } else if (PauseMenu.activeSelf) { ResumeGame(); PauseMenu.SetActive(false); } else { ActivatePauseMenu(); } } //dont allow other inputs if pause menu is up if (PauseMenu != null && PauseMenu.activeSelf) { return; } //Check for the current cell and force the currently attached tower to that cell Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(inputRay, out hit)) { //Debug.Log( mainMap.GetCellAtPosition(hit.point).occupant); currentCell = mainMap.GetCellAtPosition(hit.point); if (currentCell != null) { //if a tower is attached to cursor, place it if (attachedTower != null) { attachedTower.transform.position = currentCell.transform.position; } if (currentCell.occupant != null) { currentSpot = currentCell.occupant.GetComponent <TowerSpot>(); } } } if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject() && currentMenu != null) { Destroy(currentMenu.gameObject); currentMenu = null; } //Place the currently attached tower if the user clicks on the spot if (Input.GetMouseButtonUp(0) && !EventSystem.current.IsPointerOverGameObject()) { if (!PlaceTower()) { ActivateTowerMenu(); } } //right click cancels tower placement if (Input.GetMouseButton(1)) { if (attachedTower != null) { Destroy(attachedTower.gameObject); } } }
public void Start() { towerMenu = FindObjectOfType <TowerMenu>(); }
void Awake() { menu = transform.root.GetComponent <TowerMenu>(); costText = transform.parent.GetComponentInChildren <TextMeshProUGUI>(); }