Example #1
0
    void setSpriteType(TowerSpriteType type)
    {
        if (currentSprite != null && type == currentSprite.type)
        {
            return;
        }

        if (myToy.building.tower_sprite)
        {
            currentSprite = TowerVisualStore.Instance.getSprite(myToy.runetype, myToy.toy_type, type, false);
            if (currentSprite != null)
            {
                myToy.building.tower_sprite.sprite = currentSprite.sprite;
            }
        }

        if (!haveUpgrades || !myToy.building.upgrade_sprite)
        {
            return;
        }
        currentUpgradeSprite = TowerVisualStore.Instance.getSprite(myToy.runetype, myToy.toy_type, type, true);
        if (currentUpgradeSprite != null)
        {
            bool turn_me_on = myToy.building.upgrade_sprite.gameObject.activeSelf;
            myToy.building.upgrade_sprite.gameObject.SetActive(false);
            myToy.building.upgrade_sprite.sprite = currentUpgradeSprite.sprite;

            myToy.building.upgrade_sprite.gameObject.SetActive(turn_me_on);
        }
    }
Example #2
0
    void SpawnTowers()
    {
        towers = new Dictionary <TowerLocation, TowerSprite>();
        foreach (KeyValuePair <TowerLocation, Vector3Int> towerPos in towerPositions)
        {
            TowerLocation towerLoc = towerPos.Key;
            Vector3Int    position = towerPos.Value;

            GameObject tower = Instantiate(towerPrefab, position, Quaternion.identity);
            tower.transform.SetParent(this.transform);
            TowerSprite towerSprite = tower.GetComponent <TowerSprite>();
            towerSprite.OnInitializedSpawnAtTilePosition(position);
            towers[towerLoc] = towerSprite;
        }
    }