Ejemplo n.º 1
0
        private void UpdateState()
        {
            Vector3 prevPos = roomnet.WorldToRelativePos(transform.position);

            switch (state)
            {
            case State.Idle:
                if (!currentRoom.isConnectedToStart)
                {
                    state = State.Sleeping;
                    animator.SetBool("isSleeping", true);
                    sleepEmitter.enabled = true;
                }
                else if (targetRoom != null && targetRoom != currentRoom)
                {
                    state = State.Travelling;
                }
                break;

            case State.Travelling:
                UpdateTravel();
                break;

            case State.Sleeping:
                if (currentRoom.isConnectedToStart)
                {
                    Room connectedEnd = roomnet.GetLinkedEndRoom();
                    if (connectedEnd != null)                               //Has direct link to end
                    {
                        targetRoom = connectedEnd;
                    }
                    else
                    {
                        targetRoom = roomnet.fallbackRoom;
                    }
                    state = State.Travelling;
                    animator.SetBool("isSleeping", false);
                    sleepEmitter.enabled = false;
                }
                break;
            }
            Vector3 deltaPos = roomnet.WorldToRelativePos(transform.position) - prevPos;

            animator.SetFloat("Velocity", deltaPos.magnitude / Time.deltaTime);
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            roomnet     = GetComponentInParent <RoomNetwork>();
            link        = GetComponent <RoomLink>();
            levelLoader = GetComponent <SteamVR_LoadLevel>();
            Vector3 entry1Pos = roomnet.WorldToRelativePos(transform.Find("Entry1").position);
            Vector3 entry2Pos = roomnet.WorldToRelativePos(transform.Find("Entry2").position);

            if (Vector3.Distance(entry1Pos, roomnet.WorldToRelativePos(link.room1.center)) < Vector3.Distance(entry2Pos, roomnet.WorldToRelativePos(link.room1.center)))
            {
                link.entry1 = entry1Pos;
                link.entry2 = entry2Pos;
            }
            else
            {
                link.entry1   = entry2Pos;
                link.entry2   = entry1Pos;
                link.reversed = true;
            }
            link.isOpen = true;
        }
Ejemplo n.º 3
0
        private void Awake()
        {
            roomnet       = GetComponentInParent <RoomNetwork>();
            link          = GetComponent <RoomLink>();
            linearMapping = GetComponent <LinearMapping>();
            entry1        = transform.Find("Entry1");
            entry2        = transform.Find("Entry2");
            Vector3 entry1Pos = roomnet.WorldToRelativePos(entry1.position);
            Vector3 entry2Pos = roomnet.WorldToRelativePos(entry2.position);

            if (Vector3.Distance(entry1Pos, roomnet.WorldToRelativePos(link.room1.center)) < Vector3.Distance(entry2Pos, roomnet.WorldToRelativePos(link.room1.center)))
            {
                link.entry1 = entry1Pos;
                link.entry2 = entry2Pos;
            }
            else
            {
                link.entry1   = entry2Pos;
                link.entry2   = entry1Pos;
                link.reversed = true;
            }
            link.isOpen = true;             // Elevator Link Always open
        }
Ejemplo n.º 4
0
        private void Awake()
        {
            roomnet      = GetComponentInParent <RoomNetwork>();
            link         = GetComponentInParent <RoomLink>();
            entry1       = transform.Find("Entry1");
            entry2       = transform.Find("Entry2");
            centerTransf = transform.Find("Center");
            Vector3 entry1Pos = roomnet.WorldToRelativePos(entry1.position);
            Vector3 entry2Pos = roomnet.WorldToRelativePos(entry2.position);

            if (Vector3.Distance(entry1Pos, roomnet.WorldToRelativePos(link.room1.center)) < Vector3.Distance(entry2Pos, roomnet.WorldToRelativePos(link.room1.center)))
            {
                link.entry1 = entry1Pos;
                link.entry2 = entry2Pos;
            }
            else
            {
                link.entry1   = entry2Pos;
                link.entry2   = entry1Pos;
                link.reversed = true;
            }

            outlined = GetComponent <Outlined>();
        }