Exemplo n.º 1
0
    public GameObject AddScreen(ScreenObject theScreen, Vector3 pos, int height)
    {
        // create a new screen object
        GameObject instance = (GameObject)Instantiate(screenPrefab.gameObject, pos, Quaternion.identity);
        instance.GetComponent<Screen_Script>().theScreen = theScreen;
        instance.name = "Screen#" + theScreen.GetScreenNumber();
        instance.tag = "Screen";
        instance.GetComponent<SpriteRenderer>().sortingOrder = height - theScreen.GetY() - 1;

        if (!theScreen.ConstructionInProgress())
        {
            instance.GetComponent<SpriteRenderer>().sprite = screenImages[theScreen.GetUpgradeLevel()];
        }
        else
        {
            instance.GetComponent<SpriteRenderer>().sprite = screenImages[0];
            CreateBuilder(theScreen.GetX(), theScreen.GetY(), theScreen.GetScreenNumber());
        }

        screenObjectList.Add(instance);

        return instance;
    }