Beispiel #1
0
    // Begins the room transition process...
    //
    private void OnTriggerEnter2D(Collider2D other)
    {
        // ...but only if the player triggered!
        if (!other.CompareTag("Player"))
        {
            return;
        }

        // Get the two transition positions (where we're coming from and where we're going to)
        {
            GAssert.Assert(null != m_Params._goOpposingSpawn, "Door trigger entered, but opposing spawn GameObject has not been set");
            DoorwayTrigger gcOpposing = m_Params._goOpposingSpawn.GetComponent <DoorwayTrigger>();
            GAssert.Assert(null != gcOpposing, "Unable to get opposing doorway params!");

            // Set the lerp to position to be the spawn point set in the opposing doorway trigger (t'other side of the doorway)
            // But keep the player's horiz/vertial offset where it is
            {
                GameGlobals.s_vRoomTransitionTo = m_Params._goOpposingSpawn.transform.position + gcOpposing.GetSpawnOffset();
                if (m_Params._iDir == Types.EDirection._HORIZONTAL_L2R || m_Params._iDir == Types.EDirection._HORIZONTAL_R2L)
                {
                    GameGlobals.s_vRoomTransitionTo.y = GameInstance.Object.GetPlayerPosition().y;
                }
                else
                {
                    GameGlobals.s_vRoomTransitionTo.x = GameInstance.Object.GetPlayerPosition().x;
                }
            }

            // Set the position to lerp from to be the position the player is at when they hit the trigger
            GameGlobals.s_vRoomTransitionFrom = other.transform.position;

            // Get the next room, this may or may not have a room controller attached but we don't need to care here...
            GameObject goNextRoom = gcOpposing.GetNextRoom();

            // And start the room transition.
            GameMode.BeginRoomTransition(ref m_Params._goRoom, ref goNextRoom);
        }

        // Disable the opposing trigger (t'other side of the doorway) and set a timer to re-enable it
        {
            m_gcTrigger.enabled = false;
            if (null != m_Params._goOpposingSpawn)
            {
                m_Params._goOpposingSpawn.SetActive(false);
            }
            TimerManager.AddTimer(Types.s_fCAM_RoomTransitionDuration, EnableDoorway);
        }
    }
Beispiel #2
0
    // This is used by the DevMenu, which puts all doors into a scrolling
    // list so you can jump between rooms quickly in DEBUG builds...
    //
    public Types.SDevMenuDoorDetails GetDoorwayDetails()
    {
        Types.SDevMenuDoorDetails ret = new Types.SDevMenuDoorDetails();

        DoorwayTrigger gcDoor1 = null;
        DoorwayTrigger gcDoor2 = null;

        Types.SDoorwaySpawn gcDets1;
        Types.SDoorwaySpawn gcDets2;

        if (m_iDoorOrientation == Types.EDirection._HORIZONTAL)
        {
            gcDoor1 = m_Params._gcCollider_L.gameObject.GetComponent <DoorwayTrigger>();
            GAssert.Assert(null != gcDoor1, "Door trigger set without component?!");
            gcDets1 = gcDoor1.GetParams();

            gcDoor2 = m_Params._gcCollider_L.gameObject.GetComponent <DoorwayTrigger>();
            GAssert.Assert(null != gcDoor1, "Door trigger set without component?!");
            gcDets2 = gcDoor2.GetParams();


            ret._vPos1 = m_Params._gcCollider_L.transform.position + new Vector3(gcDets1._fSpawnOffset, 0f, 0f);
            ret._vPos2 = m_Params._gcCollider_R.transform.position + new Vector3(gcDets2._fSpawnOffset, 0f, 0f);

            ret._goRoom1 = gcDets1._goRoom;
            ret._goRoom2 = gcDets2._goRoom;
        }
        else
        {
            gcDoor1 = m_Params._gcCollider_U.gameObject.GetComponent <DoorwayTrigger>();
            GAssert.Assert(null != gcDoor1, "Door trigger set without component?!");
            gcDets1 = gcDoor1.GetParams();

            gcDoor2 = m_Params._gcCollider_D.gameObject.GetComponent <DoorwayTrigger>();
            GAssert.Assert(null != gcDoor1, "Door trigger set without component?!");
            gcDets2 = gcDoor2.GetParams();


            ret._vPos1 = m_Params._gcCollider_U.transform.position + new Vector3(0f, gcDets1._fSpawnOffset, 0f);
            ret._vPos2 = m_Params._gcCollider_D.transform.position + new Vector3(0f, gcDets2._fSpawnOffset, 0f);

            ret._goRoom1 = gcDets1._goRoom;
            ret._goRoom2 = gcDets2._goRoom;
        }

        return(ret);
    }