Exemplo n.º 1
0
    void ShowNumberForIteration(RoomIteration iteration)
    {
        string objectName;

        switch (iteration)
        {
        case RoomIteration.One:
            objectName = "One";
            break;

        case RoomIteration.Two:
            objectName = "Two";
            break;

        case RoomIteration.Three:
            objectName = "Three";
            break;

        case RoomIteration.Four:
            objectName = "Four";
            break;

        case RoomIteration.Five:
            objectName = "Five";
            break;

        case RoomIteration.Prolog:
        case RoomIteration.Epilog:
        case RoomIteration.Unknown:
        default:
            return;
        }
        ShowNumber(objectName);
    }
    override protected void UpdateForNewRoom(RoomIteration enteredIteration, bool isUpperDoorway, Vector3 displacementPastDoor)
    {
        // Teleport player.
        Vector3 rotation;
        Vector3 translation;

        if (enteredIteration != RoomIteration.Epilog)
        {
            GetTeleportTransform(isUpperDoorway, displacementPastDoor, out rotation, out translation);
        }
        else
        {
            rotation    = Vector3.zero;
            translation = Vector3.zero;
        }

        Vector3 positionEnd = PlayerController.instance.transform.position + translation;

        Debug.Log("Teleporting player: " +
                  "fromUpperDoorway=" + isUpperDoorway +
                  ", enteringIteration=" + enteredIteration +
                  ", positionStart=" + PlayerController.instance.transform.position +
                  ", positionEnd=" + positionEnd +
                  ", rotationStart=" + PlayerController.instance.transform.rotation +
                  ", rotation=" + rotation);

        PlayerController.instance.Teleport(translation, rotation);
    }
Exemplo n.º 3
0
    public static RoomIteration GetNextRoomIteration(RoomIteration previousIteration)
    {
        switch (previousIteration)
        {
        case RoomIteration.Prolog:
            return(RoomIteration.One);

        case RoomIteration.One:
            return(RoomIteration.Two);

        case RoomIteration.Two:
            return(RoomIteration.Three);

        case RoomIteration.Three:
            return(RoomIteration.Four);

        case RoomIteration.Four:
            return(RoomIteration.Five);

        case RoomIteration.Five:
            return(RoomIteration.Epilog);

        case RoomIteration.Epilog:
            Debug.LogError("Attempting to leave RoomIteration.Epilog");
            return(RoomIteration.Unknown);

        case RoomIteration.Unknown:
        default:
            Debug.LogError("Unrecognized RoomIteration: " + previousIteration);
            return(RoomIteration.Unknown);
        }
    }
Exemplo n.º 4
0
    public void OnRoomExited(bool isUpperDoorway, Vector3 displacementPastDoor)
    {
        RoomIteration previousIteration = currentRoom.iteration;
        RoomIteration nextIteration;

        if (!isUpperDoorway && currentRoom.isCompleted)
        {
            currentRoom.isCompleted = false;
            nextIteration           = GetNextRoomIteration(previousIteration);

            // TODO: Quick hack; shouldn't need this.
            if (nextIteration == RoomIteration.Four)
            {
                Debug.LogWarning("Bug here!");
                currentRoom.isCompleted = true;
                nextIteration           = RoomIteration.Three;
            }
        }
        else
        {
            nextIteration = previousIteration;
        }

        Debug.Log("OnRoomExited: " +
                  "from=" + previousIteration +
                  ", to=" + nextIteration +
                  ", isUpperDoorway=" + isUpperDoorway +
                  ", displacementPastDoor=" + displacementPastDoor);

        UpdateForNewRoom(nextIteration, isUpperDoorway, displacementPastDoor);

        // Arrange the current room.
        currentRoom.Arrange(nextIteration);
    }
Exemplo n.º 5
0
    override public void Arrange(RoomIteration iteration)
    {
        SetStartDoorVisible(false);
        SetEndDoorVisible(false);

        base.Arrange(iteration);

        ShowNumberForIteration(iteration);
    }
    // TODO: Replace this with logic to destroy previous previous on enter. Also handle next next.
    //public void OnDoorClosed()
    //{
    //    Debug.Log("OnDoorClosed");
    //    Destroy(previousRoomObject);
    //    previousRoomObject = null;
    //    previousRoom = null;
    //}

    override protected void UpdateForNewRoom(RoomIteration enteredIteration, bool isUpperDoorway, Vector3 displacementPastDoor)
    {
        previousRoomObject = currentRoomObject;
        currentRoomObject  = nextRoomObject;

        previousRoom = currentRoom;
        currentRoom  = nextRoom;

        // Create next room.
        nextRoomObject = Instantiate(roomPrefab, Vector3.zero, Quaternion.identity);
        Quaternion nextRoomRotation = enteredIteration != RoomIteration.Epilog ? currentRoomObject.transform.rotation * Quaternion.Euler(rotationBetweenDoors) : currentRoomObject.transform.rotation;
        Vector3    nextRoomPosition = enteredIteration != RoomIteration.Epilog ? currentRoomObject.transform.position + translationBetweenDoors : currentRoomObject.transform.position;

        nextRoomObject.transform.rotation = nextRoomRotation;
        nextRoomObject.transform.position = nextRoomPosition;
        nextRoom = nextRoomObject.GetComponent <RoomInterface>();
    }
Exemplo n.º 7
0
    virtual public void Arrange(RoomIteration iteration)
    {
        Debug.Log("** RoomInterface.Arrange: " + iteration);

        this.iteration = iteration;

        prologContainer   = GetReferenceToPrologContainer();
        epilogContainer   = GetReferenceToEpilogContainer();
        mainRoomContainer = GetReferenceToMainRoomContainer();

        if (iteration != RoomIteration.Prolog)
        {
            HidePrologContainer();
        }
        if (iteration != RoomIteration.Epilog)
        {
            HideEpilogContainer();
        }
        if (iteration == RoomIteration.Epilog || iteration == RoomIteration.Prolog)
        {
            HideMainRoomContainer();
        }

        SetTriggerIsActive(Triggers.StartDoor, false);
        SetTriggerIsActive(Triggers.EndDoor, false);

        switch (iteration)
        {
        case RoomIteration.Prolog:
            ArrangeForProlog();
            break;

        case RoomIteration.One:
            ArrangeForRoomOne();
            break;

        case RoomIteration.Two:
            ArrangeForRoomTwo();
            break;

        case RoomIteration.Three:
            ArrangeForRoomThree();
            break;

        case RoomIteration.Four:
            ArrangeForRoomFour();
            break;

        case RoomIteration.Five:
            ArrangeForRoomFive();
            break;

        case RoomIteration.Epilog:
            ArrangeForEpilog();
            break;

        case RoomIteration.Unknown:
        default:
            Debug.LogError("Unrecognized RoomIteration: " + iteration);
            break;
        }
    }
Exemplo n.º 8
0
 abstract protected void UpdateForNewRoom(RoomIteration enteredIteration, bool isUpperDoorway, Vector3 displacementPastDoor);