Пример #1
0
 private void Start()
 {
     towerbutton.onClick.AddListener
         (delegate { selectionSection.SetSelected(towerbutton.GetComponent <UISelectionDescription>(), false); });
     researchCenterbutton.onClick.AddListener
         (delegate { selectionSection.SetSelected(researchCenterbutton.GetComponent <UISelectionDescription>(), false); });
     upgradeCenterbutton.onClick.AddListener
         (delegate { selectionSection.SetSelected(upgradeCenterbutton.GetComponent <UISelectionDescription>(), false); });
     enemyBreederbutton.onClick.AddListener
         (delegate { selectionSection.SetSelected(enemyBreederbutton.GetComponent <UISelectionDescription>(), false); });
 }
Пример #2
0
        private void MakeSelection()
        {
            if (mouseOverUI || isBuilding)
            {
                return;
            }
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity))
            {
                if (Input.GetMouseButtonDown(0))
                {
                    if (!hit.collider.gameObject.GetComponent <UISelectionDescription>())
                    {
                        currentSelection = null;
                        selectionSection.SetSelected(currentSelection, false);
                        return;
                    }
                    currentSelection = hit.collider.gameObject.GetComponent <UISelectionDescription>();
                    selectionSection.SetSelected(currentSelection, false);
                }
            }
        }
Пример #3
0
 public void SetButtons(UISelectionDescription selected)
 {
     Tower[] evolutions = selected.GetPossibleEvolutions();
     foreach (Button button in EvoButtons)
     {
         button.onClick.RemoveAllListeners();
         button.gameObject.SetActive(false);
     }
     for (int i = 0; i < evolutions.Length; i++)
     {
         Button button = EvoButtons[i];
         button.gameObject.SetActive(true);
         Tower tower       = selected.GetComponent <Tower>();
         var   myEvoNumber = evolutions[i];
         button.onClick.AddListener
             (delegate { selectionSection.SetSelected(myEvoNumber.GetComponent <UISelectionDescription>(), true); });
         button.image.sprite = evolutions[i].GetComponent <UISelectionDescription>().GetMyImage();
         button.transform.Find("Name Text").GetComponent <Text>().text =
             evolutions[i].GetComponent <UISelectionDescription>().GetMyName();
         button.transform.Find("Cost Text Number").GetComponent <Text>().text =
             evolutions[i].GetComponent <UISelectionDescription>().GetBuildCost().ToString();
     }
 }