Beispiel #1
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         _instance = this;
         DontDestroyOnLoad(this);
     }
 }
Beispiel #2
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "UpgradeEntry")
        {
            interactText.text = "Press E to select upgrades";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("UpgradeScreen");
            }
        }

        if (collision.gameObject.tag == "S1Entry")
        {
            interactText.text = "Press E to enter level 1";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("Stage1");
            }
        }

        if (collision.gameObject.tag == "S2Entry")
        {
            interactText.text = "Press E to enter level 2";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("Stage2");
            }
        }

        if (collision.gameObject.tag == "S3Entry")
        {
            interactText.text = "Press E to enter level 3";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("Stage3");
            }
        }

        if (collision.gameObject.tag == "S4Entry")
        {
            interactText.text = "Press E to enter level 4";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("Stage4");
            }
        }

        if (collision.gameObject.tag == "S5Entry")
        {
            MapStateController map = MapStateController._instance;
            if (!map.key1Collected || !map.key2Collected || !map.key3Collected || !map.key4Collected)
            {
                interactText.text = "Must collect all keys: " + MapStateController._instance.numKeys + "/4";
            }
            else
            {
                interactText.text = "Press E to enter command center";
                if (Input.GetKeyDown(KeyCode.E))
                {
                    SceneManager.LoadScene("Stage5");
                }
            }
        }

        if (collision.gameObject.tag == "Ending1")
        {
            interactText.text = "Press E launch spacecraft back to Earth";
            if (Input.GetKeyDown(KeyCode.E))
            {
                ShowEnding1();
            }
        }

        if (collision.gameObject.tag == "Ending2")
        {
            interactText.text = "Press E to self-destruct the colony";
            if (Input.GetKeyDown(KeyCode.E))
            {
                ShowEnding2();
            }
        }

        if (collision.gameObject.tag == "UpgradeAreaEntry")
        {
            interactText.text = "Press E to enter upgrade area";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("UpgradeArea");
            }
        }

        if (collision.gameObject.tag == "Exit")
        {
            interactText.text = "Press E to exit";
            if (Input.GetKeyDown(KeyCode.E))
            {
                SceneManager.LoadScene("Hub");
            }
        }
    }