Example #1
0
    public void SelectTurret(GameObject turretGO, ShopButtonUI button)
    {
        if (turretGO == selectedTurret)
        {
            selectedButtonUI.Deselect();
            selectedTurret = null;
            button         = null;
            return;
        }

        // 1) disselect turret
        if (selectedButtonUI != null)
        {
            selectedButtonUI.Deselect();
        }

        // 2) =
        selectedTurret   = turretGO;
        selectedButtonUI = button;

        // select
        Turret turret = selectedTurret.GetComponent <Turret>();

        SetTurretData(turret?.CurrentTurret);
        selectedButtonUI.Select();


        void SetTurretData(TurretObject data) => turretData = data;
    }
Example #2
0
    public void SetTurrets(TurretObject[] turrets)
    {
        foreach (TurretObject t in turrets)
        {
            GameObject newTurretButton = Instantiate(TurretButton);
            newTurretButton.transform.SetParent(transform);

            ShopButtonUI sbui = newTurretButton.GetComponent <ShopButtonUI>();
            sbui?.Init(t);
        }
    }
Example #3
0
 public void TurretPressed(GameObject newTurret, ShopButtonUI button) => buildManager.SelectTurret(newTurret, button);