Esempio n. 1
0
    /// <summary>
    /// Player has entered the next room; get ready for a new roomState
    /// </summary>
    public void NextRoom(string nextRoom, string prevRoom, bool playDoorSound)
    {
        IRoom pRoom = Blueprints.GetRoom(prevRoom);

        pRoom.Visited = true;
        IRoom nRoom = Blueprints.GetRoom(nextRoom);

        nRoom.Visited  = true;
        this.roomState = string.Empty;
        Logger.Log("UPDATED GAME STATE: " + Dump());
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        //Debug.Log("RoomBuilder Start");
        gameState = Camera.main.GetComponent <GameState>();
        gameState.Load();

        Logger.Log("NEW GAME: " + gameState.Dump());

        if (Overrides.Enabled)
        {
            START_ROOM     = Overrides.InitialRoom;
            START_POSITION = Overrides.StartPosition;
        }

        Blueprints.ResetRooms(gameState);

        if (!gameState.CurrentRoom.Equals(GameConstants.GAMEOVER))
        {
            Vector3 startPosition = START_POSITION;
            if (gameState.HasSavedState)
            {
                currentRoom   = Blueprints.GetRoom(gameState.CurrentRoom);
                startPosition = gameState.CurrentPosition;
            }
            else
            {
                currentRoom = Blueprints.GetRoom(START_ROOM);
            }

            if (currentRoom != null)
            {
                currentRoom.Visited = true;
            }

            // build the first room
            BuildRoom(currentRoom, startPosition);

            // initialize the screen boundaries
            ScreenUtils.Initialize();

            // start room music
            //PlayMusic();

            // Listen for when we need to build a new room
            EventManager.AddNextRoomListener(buildNextRoom);
        }
        else
        {
            isGameOver = true;
        }

        this.gameOverEvent = new GameOverEvent();
        EventManager.AddGameOverInvoker(this);
    }
Esempio n. 3
0
    /// <summary>
    /// If user has left previous room; need to load the next room
    /// </summary>
    private void buildNextRoom(string nextRoom, string prevRoom, bool playDoorSound)
    {
        IRoom room = Blueprints.GetRoom(nextRoom);

        if (playDoorSound)
        {
            //Debug.Log(prevRoom + " > " + nextRoom);
            if ((prevRoom.Equals("TheFilingCabinet") && nextRoom.Equals("TheResultOfTheQuirkafleeg")) ||
                (prevRoom.Equals("TheResultOfTheQuirkafleeg") && nextRoom.Equals("TheFilingCabinet")))
            {
                //Debug.Log("play portal sound");
                AudioManager.Instance.PlayOneShot(AudioClipName.Portal);
            }
            else
            {
                //Debug.Log("play door sound");
                AudioManager.Instance.PlayOneShot(AudioClipName.Door);
            }
        }

        // if a room is not found, return to the prevRoom
        if (room == null)
        {
            // get previous room
            room = Blueprints.GetRoom(prevRoom);
            // so what was the next room becomes the previous room
            prevRoom = nextRoom;
            // get id of the room we are returning to
            nextRoom = room.GetID();
        }

        if (room != null)
        {
            Vector3 startPosition = room.GetStartPosition(prevRoom);

            Logger.Log("ENTERING " + nextRoom + " FROM " + prevRoom);

            room.Visited = true;

            gameState.CurrentRoom     = room.GetID();
            gameState.CurrentPosition = startPosition;
            Logger.Log("SAVING STATE: " + gameState.Dump(), LogType.TO_DEBUG_ONLY);
            gameState.Save();
            Logger.Log("SAVED STATE: " + gameState.Dump(), LogType.TO_DEBUG_ONLY);

            BuildRoom(room, startPosition);
        }
        else
        {
            SceneManager.LoadScene(GameConstants.MAINMENU);
        }
    }
Esempio n. 4
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        // if player exits the door, let the RoomBuilder know to build
        // the next room
        if (collision.gameObject.CompareTag(GameConstants.PLAYER))
        {
            // if there is no next room, show the "under construction" message
            if (nextRoom.Equals(currentRoom) || Blueprints.GetRoom(nextRoom) == null)
            {
                ShowMissingRoomMessage();
            }

            this.nextRoomEvent.Invoke(nextRoom, currentRoom, playSound);
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        if (playerController == null)
        {
            GameObject player = GameObject.FindGameObjectWithTag(GameConstants.PLAYER);
            if (player)
            {
                playerController = player.GetComponent <PlayerController>();
            }
        }

        if (playerController != null)
        {
            FadeMap(playerController.PlayerState is MovingState);

            if (playerController.transform.position.x > 0f)
            {
                transform.localPosition = positionLeft;
            }
            else
            {
                transform.localPosition = positionRight;
            }
        }

        string currentRoom = gameState.CurrentRoom;

        foreach (string roomId in roomIds)
        {
            IRoom room = Blueprints.GetRoom(roomId);

            SpriteMask spriteMask = null;
            if (spriteMasks != null && room != null && spriteMasks.TryGetValue(room.GetID(), out spriteMask))
            {
                spriteMask.enabled = !room.Visited;

                if (room.GetID().Equals(currentRoom))
                {
                    highlightSprite.enabled            = true;
                    highlightSprite.transform.position = spriteMask.transform.position;
                }
            }
        }
    }