Beispiel #1
0
    //This will instantiate "buttons" or "cards" with the right UI elements as needed in runtime, If I understand this right
    private void CreateTowerCard(scrTowerSettings towerSettings) //We want to load each Tower in our scriptable object
    {
        GameObject newInstance = Instantiate(towerCardPrefab, towerPanelContainer.position, Quaternion.identity);

        newInstance.transform.SetParent(towerPanelContainer); //Parent the new instance
        newInstance.transform.localScale = Vector3.one;       //To avoid potential errors since we are using a grid layout

        scrTowerUICard cardButton = newInstance.GetComponent <scrTowerUICard>();

        cardButton.SetupTurretButton(towerSettings);
    }
Beispiel #2
0
    private void PlaceTower(scrTowerSettings towerLoaded)
    {
        if (_currentNodeSelected != null)
        {
            GameObject towerInstance = Instantiate(towerLoaded.TowerPrefab); //Get tower from tower pool instead
            towerInstance.transform.localPosition = _currentNodeSelected.transform.position;
            towerInstance.transform.parent        = _currentNodeSelected.transform;

            scrTowerTargeting     towerPlaced              = towerInstance.GetComponent <scrTowerTargeting>();
            scrTowerPrefabTracker towerPlacedLevelTracker  = towerInstance.GetComponent <scrTowerPrefabTracker>();
            scrTowerRallypointPos towerPlacedRallyPointPos = towerInstance.GetComponent <scrTowerRallypointPos>();
            _currentNodeSelected.SetRallyPointReference(towerPlacedRallyPointPos);
            _currentNodeSelected.SetTower(towerPlaced);
            _currentNodeSelected.SetTowerLevelTracker(towerPlacedLevelTracker);
        }
    }
Beispiel #3
0
 public void SetupTurretButton(scrTowerSettings towerSettings)
 {
     TowerLoaded       = towerSettings;
     towerImage.sprite = towerSettings.TowerShopSprite;          //Get the image reference from the scriptable object
     towerCost.text    = towerSettings.TowerShopCost.ToString(); //Turns an integr into text (as you should know)
 }