Example #1
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);
    }