Ejemplo n.º 1
0
        public void PurchaseTower(TowerPlatform _platform)
        {
            Player.instance.PurchaseTower(towerToPurchase);
            Tower newTower = Instantiate(towerToPurchase);

            _platform.AddTower(newTower);
            aliveTowers.Add(newTower);
        }
Ejemplo n.º 2
0
    private void InstantiateNewTower(TowerPlatform towerPlatform)
    {
        Tower placedTower = Instantiate(tower, towerPlatform.transform.position, Quaternion.identity, parent);

        placedTower.builtOnPlatform = towerPlatform;

        towerPlatform.TogglePlaceable();

        towers.Enqueue(placedTower);
    }
 private void OnTriggerEnter(Collider other)
 {
     currentTowerPlatform = other.GetComponentInParent <TowerPlatform>();
     towerExists          = other.GetComponentInChildren <TowerCheck>();
     currentTower         = other.GetComponentInChildren <TowerCheck>();
     if (other.GetComponentInChildren <TowerType>())
     {
         upgradePriceText.text = "$" + other.GetComponentInChildren <TowerType>().upgradeCost;
     }
     towerManager.SetupTowerPrices();
 }
Ejemplo n.º 4
0
 public void AddTower(TowerPlatform towerPlatform)
 {
     if (towers.Count < towerLimit)
     {
         InstantiateNewTower(towerPlatform);
         print(towers.Count + " tower(s) in scene");
     }
     else
     {
         MoveExistingTower(towerPlatform);
     }
 }
Ejemplo n.º 5
0
    //De activates the radial menu object.
    void DisableRadialMenu()
    {
        StartCoroutine(RadialMenuCloseAnimation());

        if (selectedTowerPlatform != null)
        {
            //selectedTowerPlatform.transform.FindChild("Model").GetComponent<MeshRenderer>().material.color = Color.white;
        }

        selectedTower         = null;
        selectedTowerPlatform = null;
    }
Ejemplo n.º 6
0
    //Enables the tower platform radial menu.
    void SetRadialMenu(Vector2 posOnScreen, TowerPlatform towerPlatform)
    {
        towerPlatformMenu.SetActive(true);
        StartCoroutine(RadialMenuOpenAnimation());

        SetTowerPlatformMenuButtons(towerPlatform);
        selectedTowerPlatform = towerPlatform;

        //Set the radial menu position to the same as the touch position on screen.
        transform.localPosition = new Vector3(posOnScreen.x - (Screen.width / 2), posOnScreen.y - (Screen.height / 2), 0);

        //towerPlatform.transform.FindChild("Model").GetComponent<MeshRenderer>().material.color = Color.green;

        FixRadialMenuPosition();
    }
Ejemplo n.º 7
0
    public void enableBuildUI(GameObject towerPlatform)
    {
        selectedTowerPlatform = towerPlatform.GetComponent <TowerPlatform>();
        towerPos = towerPlatform.transform.position;
        transform.GetChild(0).gameObject.SetActive(true);
        Vector3 viewPos = mainCamera.WorldToViewportPoint(towerPos);

        if (viewPos.x >= 0.5f)
        {
            buildUI.rectTransform.anchoredPosition = new Vector2(180, 0);
        }
        else
        {
            buildUI.rectTransform.anchoredPosition = new Vector2(620, 0);
        }
    }
Ejemplo n.º 8
0
        public bool PurchaseTower(TowerPlatform _platform, TowerTypes _towerType)
        {
            // true - if enough money, false - if not enough money
            bool towerWasBought = Player.instance.PurchaseTower(towers[_towerType]);

            if (towerWasBought)
            {
                Tower newTower = Instantiate(towers[_towerType]);
                _platform.AddTower(newTower);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 9
0
    private void MoveExistingTower(TowerPlatform newPlatform)
    {
        // take the bottom tower off the queue
        Tower towerBeingMoved = towers.Dequeue();

        // set old platform as placeable
        towerBeingMoved.builtOnPlatform.TogglePlaceable();

        // set the new platform position
        towerBeingMoved.transform.position = newPlatform.transform.position;
        // set tower's new platform
        towerBeingMoved.builtOnPlatform = newPlatform;
        // set new platform as not placeable
        newPlatform.TogglePlaceable();

        // add the tower on top of the queue
        towers.Enqueue(towerBeingMoved);
    }
Ejemplo n.º 10
0
    //Sets the tower platform buttons to disable when pressed.
    //Sets the tower platform buttons to build a tower on the platform when pressed.
    void SetTowerPlatformMenuButtons(TowerPlatform towerPlatform)
    {
        foreach (Button button in towerPlatformMenuButtons)
        {
            button.onClick.RemoveAllListeners();
        }

        towerPlatformMenuButtons[0].onClick.AddListener(() => towerPlatform.BuildTower(TowerType.RobotArm));
        towerPlatformMenuButtons[1].onClick.AddListener(() => towerPlatform.BuildTower(TowerType.Crusher));
        towerPlatformMenuButtons[2].onClick.AddListener(() => towerPlatform.BuildTower(TowerType.Lazer));
        towerPlatformMenuButtons[3].onClick.AddListener(() => towerPlatform.BuildTower(TowerType.AcidEtcher));
        towerPlatformMenuButtons[4].onClick.AddListener(() => towerPlatform.BuildTower(TowerType.Drill));

        foreach (Button button in towerPlatformMenuButtons)
        {
            button.onClick.AddListener(DisableRadialMenu);
        }
    }