Example #1
0
        private void UpdateTravel()
        {
            switch (travellingState)
            {
            case TravellingState.InRoom:
                Room room = roomnet.GetRoom(transform.position);
                if (room != null)
                {
                    currentRoom = room;
                    if (!currentRoom.isConnectedToStart)
                    {
                        state = State.Sleeping;
                        animator.SetBool("isSleeping", true);
                        sleepEmitter.enabled = true;
                        return;
                    }
                    path = roomnet.FindPath(currentRoom, targetRoom);
                    if (path == null)
                    {
                        state = State.Idle;
                        return;
                    }
                    currentTraverser = currentRoom.traverser;
                    if (targetRoom == currentRoom)
                    {
                        currentRoom.traverser.SetTarget(roomnet.WorldToRelativePos(currentRoom.center));
                        if (currentTraverser.Traverse(this))
                        {
                            state = State.Idle;
                        }
                    }
                    else
                    {
                        currentRoom.traverser.SetTarget(path[0]);
                        if (currentTraverser.Traverse(this))
                        {
                            travellingState = TravellingState.InLink;
                        }
                    }
                }
                break;

            case TravellingState.InLink:
                currentTraverser = path[0].traverser;
                path[0].traverser.SetTarget(currentRoom);

                if (currentTraverser.Traverse(this))
                {
                    travellingState = TravellingState.InRoom;
                }
                break;
            }
        }
Example #2
0
        private void Update()
        {
            Room startRoom  = roomnet.GetRoom(start.position);
            Room targetRoom = roomnet.GetRoom(target.position);

            if (startRoom == null || targetRoom == null)
            {
                //Debug.Log("No start or target!");
                return;
            }
            roomnet.FindPath(startRoom, targetRoom);
        }