Beispiel #1
0
    IEnumerator WhichRoom(GameObject room)
    {
        roomWitch = room.GetComponent <RoomWitches>();

        if (room == initialRoom)
        {
        }
        else
        {
            witchesInTheRoom = roomWitch.witches;
            foreach (GameObject witch in witchesInTheRoom)
            {
                SpriteRenderer witchRenderer = witch.GetComponent <SpriteRenderer>();
                EnemySpawner   witchSpawner  = witch.GetComponent <EnemySpawner>();
                witchRenderer.enabled = true;
                witchSpawner.enabled  = true;
            }
        }

        yield return(new WaitForEndOfFrame());
    }
Beispiel #2
0
    IEnumerator WhichRoom(GameObject room)
    {
        roomWitch = room.GetComponent <RoomWitches>();

        // When the player is still in the menu room
        if (room == initialRoom)
        {
        }
        else
        {
            witchesInTheRoom = roomWitch.witches;

            #region Trash
            #region First Try
            //foreach (GameObject witch in witchesInTheRoom)
            //{
            //    SpriteRenderer witchRenderer = witch.GetComponent<SpriteRenderer>();
            //    EnemySpawner witchSpawner = witch.GetComponent<EnemySpawner>();
            //    witchRenderer.enabled = true;
            //    witchSpawner.enabled = true;
            //}
            #endregion

            #region Second Try
            //if(witchesInTheRoom[0] != null)
            //{
            //    SpriteRenderer witchRenderer = witchesInTheRoom[0].GetComponent<SpriteRenderer>();
            //    EnemySpawner witchSpawner = witchesInTheRoom[0].GetComponent<EnemySpawner>();
            //    witchRenderer.enabled = true;
            //    witchSpawner.enabled = true;
            //}

            //if (witchesInTheRoom[1] != null)
            //{
            //    SpriteRenderer witchRenderer = witchesInTheRoom[1].GetComponent<SpriteRenderer>();
            //    EnemySpawner witchSpawner = witchesInTheRoom[1].GetComponent<EnemySpawner>();
            //    witchRenderer.enabled = true;
            //    witchSpawner.enabled = true;
            //}
            #endregion
            #endregion

            for (int i = 0; i < witchesInTheRoom.Length; i++)
            {
                // When the witches exists
                if (witchesInTheRoom[i] != null)
                {
                    SpriteRenderer witchRenderer = witchesInTheRoom[i].GetComponent <SpriteRenderer>();
                    EnemySpawner   witchSpawner  = witchesInTheRoom[i].GetComponent <EnemySpawner>();
                    // Set the sprite renderer of every witch in the room to true
                    witchRenderer.enabled = true;
                    // Set the enemy spawner of every witch in the room to true
                    witchSpawner.enabled = true;
                }

                // When none
                else
                {
                    witchesInTheRoom[i] = null;
                }
            }
        }

        yield return(new WaitForEndOfFrame());
    }