Esempio n. 1
0
        /// <summary>
        /// Creates a new gameplay screen.
        /// </summary>
        public GameplayScreen(FishingGameContext context)
        {
            _context = context;
            _context.Input.ControllerDisconnected += (s, a) => PauseGame();
            _context.Game.Exiting         += (s, a) => ExitGame();
            _context.Trial.TrialModeEnded += (s, a) => ConfigureStorage();

            _camera = new CameraSprite(_context.Game.GraphicsDevice);
            _state  = GameState.Story;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new camera controller.
        /// </summary>
        /// <param name="camera">The camera to control.</param>
        /// <param name="scene">The scene displaying the action.</param>
        /// <param name="fishing">The fishing state to monitor.</param>
        public CameraController(CameraSprite camera, Scene scene, FishingState fishing)
        {
            _camera          = camera;
            _camera.Position = InitialPosition;
            SetCameraFocus(InitialFocus);

            _scene = scene;

            _fishing = fishing;
            _fishing.ActionChanged += OnActionChanged;
            _fishing.Event         += OnFishingEvent;
        }
Esempio n. 3
0
    private static IEnumerator process(TransforPointIndex originBorn, AnimationCurve pop, float popTime)
    {
        ColorScreen.Main.SetColor(Color.black, 0);
        var getFinished = SceneTransforer.Main.TransforToPoint(originBorn, 1);

        yield return(new WaitUntil(getFinished));

        PlayerProperty.Main.born = originBorn;
        yield return(new WaitForSeconds(1));

        Func <bool> xoCtrlConnected = () => {
            var names = Input.GetJoystickNames();
            return(names.Length != 0 && names[0] != "");
        };
        var              path        = xoCtrlConnected() ? gamepadPath : keyboardPath;
        CameraSprite     ctrlSprite  = new CameraSprite("CtrlPadUI", path, Vector2.right);
        var              originScale = ctrlSprite.transform.localScale;
        Func <float>     getScale    = () => ctrlSprite.transform.localScale.x / originScale.x;
        Action <float>   setScale    = (f) => ctrlSprite.transform.localScale = originScale * f;
        ClassRef <float> scaleRef    = new ClassRef <float>(setScale, getScale);

        Time.timeScale = 0;
        scaleRef.set(0);
        float timeCount = 0;

        while (timeCount < 1)
        {
            yield return(null);

            timeCount += Time.unscaledDeltaTime / popTime;
            timeCount  = Mathf.Clamp01(timeCount);
            scaleRef.set(pop.Evaluate(timeCount));
        }
        yield return(new WaitUntil(() => Input.anyKey));

        var s = getScale();

        timeCount = 0;
        while (timeCount < 1)
        {
            yield return(null);

            timeCount += Time.unscaledDeltaTime / 0.3f;
            timeCount  = Mathf.Clamp01(timeCount);
            scaleRef.set(Mathf.Lerp(s, 0, timeCount));
        }
        ctrlSprite.Destroy();
        Time.timeScale = 1;
    }
Esempio n. 4
0
        protected override void LoadComplete()
        {
            base.LoadComplete();

            AddRange(new Drawable[]
            {
                new Box
                {
                    Size   = new Vector2(684),
                    Anchor = Anchor.Centre,
                    Origin = Anchor.Centre,
                    Colour = Colour4.Red,
                },
                new Container
                {
                    Size     = new Vector2(512),
                    Anchor   = Anchor.Centre,
                    Origin   = Anchor.Centre,
                    Children = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Colour4.Blue,
                        },
                        display = new CameraSprite
                        {
                            RelativeSizeAxes = Axes.Both,
                            FillMode         = FillMode.Fit,
                            Anchor           = Anchor.Centre,
                            Origin           = Anchor.Centre,
                        }
                    }
                },
                deviceList = new BasicDropdown <string>
                {
                    Width  = 300,
                    Margin = new MarginPadding(10),
                    Items  = camera.CameraDeviceNames
                },
            });

            camera.OnNewDevice  += updateDevices;
            camera.OnLostDevice += updateDevices;

            device.BindTo(deviceList.Current);
            device.ValueChanged += (v) => display.CameraID = camera.CameraDeviceNames.ToList().IndexOf(v.NewValue);
        }
Esempio n. 5
0
        public TestSceneFaceTracking()
        {
            Children = new Drawable[]
            {
                tracker = new FaceTracker(),
                camera  = new CameraSprite
                {
                    CameraID = 0,
                },
                faceLocationsContainer = new Container <TrackingBox>
                {
                    Name = @"face locations",
                    Size = new Vector2(640, 480),
                },
                new Container
                {
                    AutoSizeAxes = Axes.Both,
                    Children     = new Drawable[]
                    {
                        new Box
                        {
                            Colour           = Colour4.Black,
                            RelativeSizeAxes = Axes.Both,
                        },
                        status = new SpriteText
                        {
                            AlwaysPresent = true,
                            Margin        = new MarginPadding(5)
                        },
                    }
                }
            };

            tracker.StartTracking(camera);
            tracker.OnTrackerUpdate += _ =>
            {
                trackerDeltaTime = Time.Current - lastTrackingTime;
                lastTrackingTime = Time.Current;
            };
        }
Esempio n. 6
0
        public CameraDisplay()
        {
            Size = new Vector2(260, 195);

            Children = new Drawable[]
            {
                new Box
                {
                    Colour           = VignetteColor.Darker,
                    RelativeSizeAxes = Axes.Both,
                },
                sprite = new CameraSprite
                {
                    FillMode         = FillMode.Fit,
                    RelativeSizeAxes = Axes.Both,
                },
                hover = new Container
                {
                    RelativeSizeAxes = Axes.Both,
                    Alpha            = 0,
                    Children         = new Drawable[]
                    {
                        new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Colour           = Colour4.Black.Opacity(0.75f),
                        },
                        new Container
                        {
                            RelativeSizeAxes = Axes.Both,
                            Padding          = new MarginPadding(10),
                            Child            = dropdown = new CameraDevicesDropdown {
                                RelativeSizeAxes = Axes.X
                            },
                        }
                    }
                },
            };
        }
Esempio n. 7
0
 public void Init()
 {
     colorSprite          = new CameraSprite("ColorScreen", colorSpritePath);
     inited               = true;
     colorSprite.sr.color = targetColor;
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a new scene view.
 /// </summary>
 /// <param name="scene">The scene to draw.</param>
 /// <param name="camera">The camera viewing the scene.</param>
 public SceneView(Scene scene, CameraSprite camera)
 {
     _scene  = scene;
     _camera = camera;
 }