Ejemplo n.º 1
0
    // Instantly set player's position to the given location. No error checking
    //
    public static void TeleportPlayer(Vector3 vNewPos, ref GameObject goRoomTo)
    {
        GameInstance gcGameInstance = GameInstance.Object;

        Messenger.Invoke(Types.s_sGF_BeginRoomTransition);

        // Transition  (Camera is NOT responsible for calling Begin/EndRoomTransition!)
        {
            gcGameInstance.GetPlayerState().LockPlayer();
            gcGameInstance.GetPlayerController().BeginTeleport();
            gcGameInstance.GetGameCamera().BeginTeleport(goRoomTo.transform.position);
        }

        // Let the rooms cleanup...
        {
            m_gcActiveRoomController.OnRoomExit();
            m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>();
            GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!");
            m_gcActiveRoomController.OnRoomEnter();
        }


        // Set player..
        {
            gcGameInstance.GetPlayerState().UnlockPlayer();
            gcGameInstance.GetPlayerController().EndTeleport();
            GameInstance.Object.GetPlayerObject().transform.position = vNewPos;
            GameGlobals.s_vRoomTransitionTo = vNewPos;
        }

        Messenger.Invoke(Types.s_sGF_EndRoomTransition);
    }
Ejemplo n.º 2
0
    public static void WarpPlayerToLevel2()
    {
        GameObject goRoomTo = GameObject.Find(Types.s_sRC_LevelTwoRoomController);

        GAssert.Assert(null != goRoomTo, "GameInstance unable to find the level 2 room controller!");

        GameInstance gcGameInstance = GameInstance.Object;

        Messenger.Invoke(Types.s_sGF_BeginRoomTransition);

        // Transition  (Camera is NOT responsible for calling Begin/EndRoomTransition!)
        {
            gcGameInstance.GetPlayerController().BeginTeleport();
            gcGameInstance.GetGameCamera().BeginTeleport(goRoomTo.transform.position);
        }

        // Let the rooms cleanup...
        {
            m_gcActiveRoomController.OnRoomExit();
            m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>();
            GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!");
            m_gcActiveRoomController.OnRoomEnter();
        }

        TimerManager.AddTimer(2f, EndWarpToLevel2);
    }
Ejemplo n.º 3
0
    // Called by Doors, to initialise the transition of the player between rooms
    //
    public static void BeginRoomTransition(ref GameObject goRoomFrom, ref GameObject goRoomTo)
    {
        GAssert.Assert(null != goRoomTo, "BeginRoomTransition called from a Door that's not setup with two rooms!");
        GameInstance gcGameInstance = GameInstance.Object;

        // Play Some Audio
        gcGameInstance.GetAudioManager().PlayAudio(EGameSFX._SFX_MISC_ROOM_TRANSITION);

        // Do the transition (Camera is responsible for calling Begin/EndRoomTransition!)
        {
            gcGameInstance.GetPlayerState().LockPlayer();
            gcGameInstance.GetPlayerController().BeginRoomTransition();
            gcGameInstance.GetGameCamera().BeginRoomTransition(goRoomTo.transform.position);
            ;
        }


        // NOTE: Order is important here! OnRoomEnter may want to calculate it's origin, which
        //       will only be accurate AFTER Camera.BeginRoomTransition!
        //
        //				Every room MUST have a room controller attached, even if there's no logic!
        //				Doorways assume this, and it simplifies the logic here...
        //
        {
            m_gcActiveRoomController.OnRoomExit();
            m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>();
            GAssert.Assert(null != m_gcActiveRoomController, "There's no room controller on this room!");
            m_gcActiveRoomController.OnRoomEnter();
        }


        // The player takes longer to transition than the camera does, and we know the duration, so set a timer
        TimerManager.AddTimer(Types.s_fPLAYER_RoomTransitionDuration, EndRoomTransition);
    }
Ejemplo n.º 4
0
    // Called on first entry into a new scene (level), just after load.
    // Searches through every gameobject in the scene, so shouldn't be used in
    // any other circumstance!
    //
    // It is assumed that every scene will have an initial RoomController on a game
    // object called: "ROOM_SpawnRoom"
    //
    public static void TransitionToDefaultRoom()
    {
        // Flag for the pause/UI controls that we're in-game.
        // Order is important! OnRomEnter() might immediately set this back to false!
        // GNTODO:  it probably does in all cases... Remove this when Cecconoid handles it properly
        m_bCanPause = true;

        // SUPER DUPER SLOW!
        GameObject goRoomTo = GameObject.Find(Types.s_sRC_DefaultRoomController);

        GAssert.Assert(null != goRoomTo, "GameInstance unable to find the default room controller in this level!");

        // Init the first room!
        m_gcActiveRoomController = goRoomTo.GetComponent <RoomControllerBase>();
        GAssert.Assert(null != m_gcActiveRoomController, "No room controller on the default room gameobject!");
        m_gcActiveRoomController.OnRoomEnter();


        // Because there's always a transition in (Spawn Effect, of screen roll) Player reset needs to delay
        // The rc_RobotronController in Eugatron scene handles all this for us, though...
        if (GameInstance.Object.m_bIsCecconoid)
        {
            TimerManager.AddTimer(2f, EndTransitionToDefaultRoom);
        }
    }