예제 #1
0
        public virtual void Start()
        {
            cameraController = GetComponent<CameraController>();
            commandQueue = GetComponent<CommandQueue>();

            if (activeRoom == null)
            {
                // Pick first room found if none is specified
                activeRoom = GameObject.FindObjectOfType(typeof(Room)) as Room;
            }

            if (activeRoom != null)
            {
                MoveToRoom(activeRoom);
            }
        }
예제 #2
0
        public void MoveToRoom(Room room)
        {
            if (room == null)
            {
                Debug.LogError("Failed to move to room. Room must not be null.");
                return;
            }

            // Fade out screen
            cameraController.Fade(0f, fadeDuration / 2f, delegate {

                if (activeRoom != null)
                {
                    activeRoom.Leave();
                }

                activeRoom = room;

                activeRoom.Enter();

                // Fade in screen
                cameraController.Fade(1f, fadeDuration / 2f, null);
            });
        }
예제 #3
0
 // Changes the active room to a different room
 public void MoveToRoom(Room room)
 {
     commandQueue.AddCommand(new MoveToRoomCommand(room));
 }
예제 #4
0
        void DrawLinkToRoom(Room room)
        {
            if (!room)
            {
                Gizmos.color = Color.red;
                Gizmos.DrawWireCube(transform.position, renderer.bounds.size * 1.1f);
                return;
            }

            if (!Game.GetInstance().showLinks)
            {
                return;
            }

            Gizmos.color = Color.green;
            Vector3 posA = transform.position;
            Vector3 posB = room.transform.position;

            Ray toA = new Ray(posB, posA - posB);
            Ray toB = new Ray(posA, posB - posA);

            float tA = 0;
            if (renderer)
            {
                if (renderer.bounds.IntersectRay(toA, out tA))
                {
                    posA = toA.GetPoint(tA * 0.95f);
                }
            }

            float tB = 0;
            if (room.gameObject.renderer)
            {
                if (room.gameObject.renderer.bounds.IntersectRay(toB, out tB))
                {
                    posB = toB.GetPoint(tB * 0.95f);
                }
            }

            Gizmos.DrawLine(posA, posB);

            float arrowHeadSize = 0.25f;

            Vector3 arrowPosA = posB;
            Vector3 arrowPosB = arrowPosA;
            Vector3 arrowPosC = arrowPosA;

            arrowPosB.x += toB.direction.y * arrowHeadSize;
            arrowPosB.y -= toB.direction.x * arrowHeadSize;
            arrowPosB -= toB.direction * arrowHeadSize;
            Gizmos.DrawLine(arrowPosA, arrowPosB);

            arrowPosC.x -= toB.direction.y * arrowHeadSize;
            arrowPosC.y += toB.direction.x * arrowHeadSize;
            arrowPosC -= toB.direction * arrowHeadSize;
            Gizmos.DrawLine(arrowPosA, arrowPosC);
        }
        public MoveToRoomCommand(Room _room)
        {
            if (_room == null)
            {
                Debug.LogError("Room must not be null.");
                return;
            }

            room = _room;
        }