Exemplo n.º 1
0
    private void InitTower()
    {
        TowerPanel = GameObject.Find("TowerPanel");
        towerSlots = new List <BuildingSlot>();
        for (int i = 0; i < GameManager.instance.GetTowerCount(); i++)
        {
            GameObject   slot      = Instantiate(prefabBuildingSlot, TowerPanel.transform);
            BuildingSlot towerSlot = slot.GetComponent <BuildingSlot>();
            towerSlot.InitTower(GameManager.instance.Towers[i].GetComponent <AbstractTower>().buildingData);
            towerSlots.Add(towerSlot);

            Button slotButton = slot.GetComponent <Button>();
            slotButton.onClick.AddListener(delegate { CreateTower(towerSlot.objectId); });
        }
    }