Ejemplo n.º 1
0
        public override void OnEnter()
        {
            AcquireCamera();
            if (targetCamera == null ||
                targetView == null)
            {
                Continue();
                return;
            }

            CameraController cameraController = CameraController.GetInstance();

            if (waitUntilFinished)
            {
                cameraController.waiting = true;
            }

            Vector3    targetPosition = targetView.transform.position;
            Quaternion targetRotation = targetView.transform.rotation;
            float      targetSize     = targetView.viewSize;

            cameraController.PanToPosition(targetCamera, targetPosition, targetRotation, targetSize, duration, delegate {
                if (waitUntilFinished)
                {
                    cameraController.waiting = false;
                    Continue();
                }
            });

            if (!waitUntilFinished)
            {
                Continue();
            }
        }
Ejemplo n.º 2
0
        // Called by Game when player enters the room
        void Enter()
        {
            Game             game             = Game.GetInstance();
            CameraController cameraController = game.gameObject.GetComponent <CameraController>();

            // Pick first view found in the room and snap to camera to this view.
            // It is allowed for a room to not have any views.
            // In this case the camera will attempt to snap to the room sprite.
            View view = gameObject.GetComponentInChildren <View>();

            if (view == null)
            {
                // No view defined for this room, try to center on room sprite
                SpriteRenderer spriteRenderer = GetComponent <SpriteRenderer>();
                if (spriteRenderer != null)
                {
                    cameraController.CenterOnSprite(spriteRenderer);
                }
                else
                {
                    Debug.LogError("Failed to set camera view when entering room.");
                }
            }
            else
            {
                // Snap to new view
                cameraController.PanToPosition(view.transform.position, view.viewSize, 0, null);
            }

            // Hide all buttons in the room before entering
            // Buttons must always be made visible using a ShowButton() command
            Button[] buttons = game.activeRoom.GetComponentsInChildren <Button>();
            foreach (Button button in buttons)
            {
                button.SetAlpha(0f);
            }

            // Reset Page layout to default setting specified in Game object
            game.pageController.SetDefaultPageLayout();

            // Rooms may have multiple child views and page.
            // It is the responsibility of the client room script to set the desired active view & page in the OnEnter method.
            game.commandQueue.CallCommandMethod(game.activeRoom.gameObject, "OnEnter");

            visitCount++;
        }