Example #1
0
    //Collision Callbacks on Stay(Trigger).
    void OnTriggerStay2D(Collider2D collider)
    {
        //Check if colliding with an enemy.
        if (collider.gameObject.tag == "enemy1")
        {
            if (!mIsDead)
            {
                //The other enemy that the player is colliding with.
                DustBunny enemy1 = collider.gameObject.GetComponent <DustBunny>();

                //Only get affected by the enemy if it isn't already dead.
                if (!enemy1.GetIsDead())
                {
                    TakeDamage();
                }
            }
        }
        else if (collider.gameObject.tag == "spider")
        {
            if (!mIsDead)
            {
                //The other enemy that the player is colliding with.
                Spider spiderComp = collider.gameObject.GetComponent <Spider>();

                //Only get affected by the enemy if it isn't already dead.
                if (!spiderComp.GetIsDead())
                {
                    TakeDamage();
                }
            }
        }
    }
Example #2
0
    //Setters:
    public void SetPaused(bool paused)
    {
        if (!paused)
        {
            mIsPaused = false;

            Destroy(transform.GetChild(3).gameObject);

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("Player"))
            {
                Player playerScript = gameObject.GetComponent <Player>();

                playerScript.UnPause();
            }

            GameObject.Find("GlobalData").GetComponent <GlobalData>().UnPause();

            if (GameObject.Find("Pawser") != null)
            {
                GameObject.Find("Pawser").GetComponent <Pawser>().UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("enemy1"))
            {
                DustBunny dustBunnyScript = gameObject.GetComponent <DustBunny>();

                dustBunnyScript.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("spider"))
            {
                Spider spiderScriptComp = gameObject.GetComponent <Spider>();

                spiderScriptComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("bullet"))
            {
                Bullet bulletComp = gameObject.GetComponent <Bullet>();

                bulletComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("knifeHandler"))
            {
                KnifeHandler knifeHandlerComp = gameObject.GetComponent <KnifeHandler>();

                knifeHandlerComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("knife"))
            {
                Knife knifeComp = gameObject.GetComponent <Knife>();

                knifeComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("tilechunk"))
            {
                TileChunk tileChunkComp = gameObject.GetComponent <TileChunk>();

                tileChunkComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("shockwaveSpawner"))
            {
                ShockwaveSpawner curComp = gameObject.GetComponent <ShockwaveSpawner>();

                curComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("hairball"))
            {
                Hairball curComp = gameObject.GetComponent <Hairball>();

                curComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("debris"))
            {
                TileDebris tileDebrisComp = gameObject.GetComponent <TileDebris>();

                tileDebrisComp.UnPause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("bee"))
            {
                Bee beeComp = gameObject.GetComponent <Bee>();

                beeComp.UnPause();
            }

            if (Camera.main.GetComponent <WallCamera>())
            {
                Camera.main.GetComponent <WallCamera>().UnPause();
            }
        }
        else
        {
            mIsPaused = true;

            GameObject pauseMenuObj = GameObject.Instantiate(mPauseMenuPrefab, new Vector3(
                                                                 0.0f, 0.0f, -10.0f),
                                                             Quaternion.identity);

            pauseMenuObj.transform.SetParent(transform);

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("Player"))
            {
                Player playerScript = gameObject.GetComponent <Player>();

                playerScript.Pause();
            }

            GameObject.Find("GlobalData").GetComponent <GlobalData>().Pause();

            if (GameObject.Find("Pawser") != null)
            {
                GameObject.Find("Pawser").GetComponent <Pawser>().Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("enemy1"))
            {
                DustBunny dustBunnyScript = gameObject.GetComponent <DustBunny>();

                dustBunnyScript.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("spider"))
            {
                Spider spiderScriptComp = gameObject.GetComponent <Spider>();

                spiderScriptComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("bullet"))
            {
                Bullet bulletComp = gameObject.GetComponent <Bullet>();

                bulletComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("knifeHandler"))
            {
                KnifeHandler knifeHandlerComp = gameObject.GetComponent <KnifeHandler>();

                knifeHandlerComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("knife"))
            {
                Knife knifeComp = gameObject.GetComponent <Knife>();

                knifeComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("tilechunk"))
            {
                TileChunk tileChunkComp = gameObject.GetComponent <TileChunk>();

                tileChunkComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("shockwaveSpawner"))
            {
                ShockwaveSpawner curComp = gameObject.GetComponent <ShockwaveSpawner>();

                curComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("hairball"))
            {
                Hairball curComp = gameObject.GetComponent <Hairball>();

                curComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("debris"))
            {
                TileDebris tileDebrisComp = gameObject.GetComponent <TileDebris>();

                tileDebrisComp.Pause();
            }

            foreach (GameObject gameObject in GameObject.FindGameObjectsWithTag("bee"))
            {
                Bee beeComp = gameObject.GetComponent <Bee>();

                beeComp.Pause();
            }

            if (Camera.main.GetComponent <WallCamera>())
            {
                Camera.main.GetComponent <WallCamera>().Pause();
            }
        }
    }