public override void Update()
            {
                int  maxLines = 3;
                bool changed  = false;
                int  numLines = shared.descBlob != null ? shared.descBlob.NumLines : 0;

                // MouseInput
                {
                    Vector2 mouseHit = MouseInput.GetAspectRatioAdjustedPosition(shared.camera, true);

                    if (shared.chooseBox.LeftPressed(mouseHit))
                    {
                        Select();
                    }

                    if (shared.descBlob != null && shared.rightStickBox.LeftPressed(mouseHit))
                    {
                        // Up?
                        if (mouseHit.Y < (shared.rightStickBox.Min.Y + shared.rightStickBox.Max.Y) / 2.0f)
                        {
                            // Up
                            if (shared.topLine > 0)
                            {
                                --shared.topLine;
                                changed = true;
                            }
                        }
                        else
                        {
                            // Down
                            if (numLines - maxLines > shared.topLine)
                            {
                                ++shared.topLine;
                                changed = true;
                            }
                        }
                    }

                    if (shared.leftStickBox.LeftPressed(mouseHit))
                    {
                        // Up?
                        if (mouseHit.Y < (shared.leftStickBox.Min.Y + shared.leftStickBox.Max.Y) / 2.0f)
                        {
                            // Up
                            shared.examplesGrid.MoveUp();
                        }
                        else
                        {
                            // Down
                            shared.examplesGrid.MoveDown();
                        }
                    }

                    // If we get a mouse click outside of the help area, just exit.
                    // Use the leftStickBox and chooseBox as the extents of our box.
                    AABB2D bigBox = new AABB2D(shared.leftStickBox.Min, shared.chooseBox.Max);
                    if (MouseInput.Left.WasPressed && !bigBox.Contains(mouseHit))
                    {
                        // Done
                        parent.Deactivate();
                    }
                }   // end of mouse input

                // Our children may have input focus but we can still steal away the buttons we care about.
                GamePadInput pad = GamePadInput.GetGamePad0();

                if (Actions.Cancel.WasPressed)
                {
                    Actions.Cancel.ClearAllWasPressedState();

                    // Done
                    parent.Deactivate();
                }

                if (Actions.Select.WasPressed)
                {
                    Actions.Select.ClearAllWasPressedState();
                    Select();
                }

                if (shared.descBlob != null)
                {
                    if (Actions.AltUp.WasPressedOrRepeat)
                    {
                        Actions.AltUp.ClearAllWasPressedState();

                        if (shared.topLine > 0)
                        {
                            --shared.topLine;
                            changed = true;
                        }
                    }

                    if (Actions.AltDown.WasPressedOrRepeat)
                    {
                        Actions.AltDown.ClearAllWasPressedState();

                        if (numLines - maxLines > shared.topLine)
                        {
                            ++shared.topLine;
                            changed = true;
                        }
                    }

                    if (changed)
                    {
                        // Start a twitch to move the description text offset.
                        TwitchManager.Set <float> set = delegate(float value, Object param) { shared.descOffset = (int)value; };
                        TwitchManager.CreateTwitch <float>(shared.descOffset, -shared.topLine * UI2D.Shared.GameFont24.LineSpacing, set, 0.2f, TwitchCurve.Shape.EaseInOut);
                    }
                }

                // If we're not shutting down, update the child grids.
                if (parent.Active)
                {
                    Matrix world = Matrix.Identity;

                    if (shared.examplesGrid != null)
                    {
                        shared.examplesGrid.Update(ref world);
                    }
                } // end if not shutting down.
            }     // end of Update()
        }   // end of Update()

        private void HandleGamePad()
        {
            GamePadInput pad = GamePadInput.GetGamePad0();

            // Accept changes.
            if (pad.ButtonA.WasPressed)
            {
                pad.ButtonA.ClearAllWasPressedState();
                Deactivate(saveChanges: true);
            }

            // Cancel changes.
            if (pad.ButtonB.WasPressed)
            {
                pad.ButtonB.ClearAllWasPressedState();
                Deactivate(saveChanges: false);
            }

            // Toggle LED.
            if (pad.ButtonY.WasPressed)
            {
                pad.ButtonY.ClearAllWasPressedState();
                ledGrid.LEDs[ledGrid.FocusLEDIndex] = !ledGrid.LEDs[ledGrid.FocusLEDIndex];
            }

            // LED Grid
            {
                int i = ledGrid.FocusLEDIndex % 5;
                int j = ledGrid.FocusLEDIndex / 5;
                if (pad.LeftStickLeft.WasPressedOrRepeat)
                {
                    if (i > 0)
                    {
                        --i;
                    }
                }
                if (pad.LeftStickRight.WasPressedOrRepeat)
                {
                    if (i < 4)
                    {
                        ++i;
                    }
                }
                if (pad.LeftStickUp.WasPressedOrRepeat)
                {
                    if (j > 0)
                    {
                        --j;
                    }
                }
                if (pad.LeftStickDown.WasPressedOrRepeat)
                {
                    if (j < 4)
                    {
                        ++j;
                    }
                }

                ledGrid.FocusLEDIndex = j * 5 + i;
            }

            // Sliders
            if (pad.RightStickDown.WasPressedOrRepeat)
            {
                if (brightnessSlider.Selected == true)
                {
                    brightnessSlider.Selected = false;
                    durationSlider.Selected   = true;

                    {
                        TwitchManager.Set <Vector2> set = delegate(Vector2 value, Object param) { rightStickPosition = value; };
                        TwitchManager.CreateTwitch <Vector2>(rightStickPosition, rightStickPositionDuration, set, 0.2f, TwitchCurve.Shape.EaseOut);
                    }
                }
            }
            if (pad.RightStickUp.WasPressedOrRepeat)
            {
                if (brightnessSlider.Selected == false)
                {
                    brightnessSlider.Selected = true;
                    durationSlider.Selected   = false;

                    {
                        TwitchManager.Set <Vector2> set = delegate(Vector2 value, Object param) { rightStickPosition = value; };
                        TwitchManager.CreateTwitch <Vector2>(rightStickPosition, rightStickPositionBrightness, set, 0.2f, TwitchCurve.Shape.EaseOut);
                    }
                }
            }
        }   // end of HandleGamePad()
Пример #3
0
            }     // end of Update()

            public void TwitchTextOffset()
            {
                // Start a twitch to move the text text offset.
                TwitchManager.Set <float> set = delegate(float val, Object param) { shared.textOffset = (int)val; };
                TwitchManager.CreateTwitch <float>(shared.textOffset, -shared.topLine * parent.renderObj.Font().LineSpacing, set, 0.2f, TwitchCurve.Shape.OvershootOut);
            }   // end of TwitchTextOffset()
Пример #4
0
        private async Task Receive(ClientWebSocket webSocket, CancellationToken cancellationToken, TwitchService twitchService,
                                   TwitchManager twitchManager, AccessToken accessToken)
        {
            if (webSocket.State != WebSocketState.Open)
            {
                throw new InvalidOperationException($"[TwitchBackgroundService] Twitch socket {webSocket.State.ToString()}");
            }
            var user = await twitchManager.GetUser();

            var encoder = new UTF8Encoding();
            var partial = string.Empty;

            while (webSocket.State == WebSocketState.Open &&
                   !cancellationToken.IsCancellationRequested &&
                   await twitchService.IsEnabled() &&
                   accessToken.Status == AccessTokenStatus.Ok)
            {
                var buffer = new byte[receiveChunkSize];
                logger.LogDebug($"[TwitchBackgroundService] Listening to socket");
                var result = await webSocket.ReceiveAsync(new ArraySegment <byte>(buffer), cancellationToken);

                logger.LogDebug($"[TwitchBackgroundService] Receive status {result.MessageType}");

                if (result.MessageType == WebSocketMessageType.Close)
                {
                    await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, cancellationToken);
                }
                else if (result.MessageType == WebSocketMessageType.Text)
                {
                    var text = partial + encoder.GetString(buffer).Replace("\0", "");
                    partial = string.Empty;

                    if (string.IsNullOrEmpty(text))
                    {
                        continue;
                    }

                    var lines = (text.Substring(0, text.LastIndexOf('\r'))).Split('\r');

                    foreach (var line in lines)
                    {
                        //logger.LogDebug($"[TwitchBackgroundService] Twitch Chat < {line}");

                        if (line.Contains("PING"))
                        {
                            var host = line.Substring(line.IndexOf(':'));
                            Send($"PONG :{host}");
                            await UpdateDashboardStatus(IntegrationStatus.Connected,
                                                        cancellationToken);

                            continue;
                        }

                        await twitchService.ProcessMessage(line);
                    }

                    partial = text.Substring(text.LastIndexOf('\r'));
                }

                await Task.Delay(delay, cancellationToken);
            }
        }
Пример #5
0
 public TwitchController(TwitchService twitchService, UserService userService, TwitchManager twitchManager, ConfigurationService configurationService)
 {
     this.twitchService        = twitchService;
     this.userService          = userService;
     this.twitchManager        = twitchManager;
     this.configurationService = configurationService;
 }
Пример #6
0
 public ChatController(DiscordManager discordManager, TwitchManager twitchManager, IDocumentStore documentStore)
 {
     _discordManager = discordManager;
     _twitchManager  = twitchManager;
     _documentStore  = documentStore;
 }
Пример #7
0
        /// <summary>
        /// Performs input handling for the Load Level UI grid in lieu of default grid drag.
        /// </summary>
        /// <param name="camera"></param>
        public override void HandleTouchInput(Camera camera)
        {
            TouchContact touch = TouchInput.GetOldestTouch();

            if (touch == null)
            {
                return;
            }

            if (touch.phase == TouchPhase.Ended)
            {
                isDragging = false;
                return;
            }
            else if (!isDragging)
            {
                // This touch hasn't yet been classified as a drag yet.. so we
                // will see if it meets the criteria.
                float minDiff = MIN_DRAG_START;
                float diff    = (touch.position - touch.startPosition).Length();
                if (diff < minDiff)
                {
                    return;
                }
                else
                {
                    isDragging = true;
                }
            }

            // Get local coordinates difference between this touch position and the previous
            Matrix  localInvMatrix  = Matrix.Invert(LocalMatrix);
            Vector2 currentLocalPos = TouchInput.GetLocalXYFromScreenCoords(
                touch.position,
                camera,
                ref localInvMatrix);
            Vector2 previousLocalPos = TouchInput.GetLocalXYFromScreenCoords(
                touch.previousPosition,
                camera,
                ref localInvMatrix);
            float localXMove = (currentLocalPos - previousLocalPos).X;

            if (SlideByX(localXMove))
            {
                // We did a successful move, so capture the momentum of the touch in pixels/frame
                float duration = 1.0f;

                if (Math.Abs(localXMove) > 0.2f)
                {
                    residualVelocity    = localXMove / 4.0f;
                    hasResidualVelocity = true;
                    TwitchManager.Set <float> set = velocityDelegate;
                    TwitchManager.CreateTwitch <float>(residualVelocity, 0, set, duration,
                                                       TwitchCurve.Shape.EaseOut);
                }
                else if (touch.phase == TouchPhase.Stationary)
                {
                    // If the user has stopped moving but hasn't ended his touch, we will put
                    // the brakes on any residual velocity, as the user probably wants to settle
                    // here.
                    residualVelocity    = 0.0f;
                    hasResidualVelocity = false;
                }
            }
        }
Пример #8
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (hitBoxA.LeftPressed(hit))
            {
                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            if (hitBoxB.LeftPressed(hit))
            {
                // Disable this hint until reset by user.
                XmlOptionsData.SetHintAsDisabled(curHint.ID);

                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }

            // Check for hover and adjust text color to match.
            Color newColor;

            newColor = hitBoxA.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelATargetColor)
            {
                labelATargetColor = newColor;
                Vector3 curColor  = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelAColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelAColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelAColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }

            newColor = hitBoxB.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelBTargetColor)
            {
                labelBTargetColor = newColor;
                Vector3 curColor  = new Vector3(labelBColor.R / 255.0f, labelBColor.G / 255.0f, labelBColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelBColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelBColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelBColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }
        }   // end of HandleMouseInput()
Пример #9
0
 public TwitchService(UserService userService, ILogger <TwitchService> logger, ChatProcessor chatService,
                      ConfigurationService configurationService, IntegrationService integrationService, TwitchManager twitchManager)
 {
     this.userService          = userService;
     this.logger               = logger;
     this.chatService          = chatService;
     this.configurationService = configurationService;
     this.integrationService   = integrationService;
     this.twitchManager        = twitchManager;
 }
Пример #10
0
        private static void Prefix(MainMenuManager __instance)
        {
            if (TheOtherRolesPlugin.DebugMode.Value)
            {
                DestroyableSingleton <EOSManager> .Instance.PlayOffline();
            }
            AssetLoader.LoadAssets();
            CustomHatLoader.LaunchHatFetcher();
            var template = GameObject.Find("ExitGameButton");

            // Discrodボタン
            var buttonDiscord = UnityEngine.Object.Instantiate(template, null);

            buttonDiscord.transform.localPosition = new Vector3(buttonDiscord.transform.localPosition.x, buttonDiscord.transform.localPosition.y + 0.6f, buttonDiscord.transform.localPosition.z);

            var textDiscord = buttonDiscord.transform.GetChild(0).GetComponent <TMPro.TMP_Text>();

            __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => {
                textDiscord.SetText("Discord");
            })));

            PassiveButton  passiveButtonDiscord = buttonDiscord.GetComponent <PassiveButton>();
            SpriteRenderer buttonSpriteDiscord  = buttonDiscord.GetComponent <SpriteRenderer>();

            passiveButtonDiscord.OnClick = new Button.ButtonClickedEvent();
            passiveButtonDiscord.OnClick.AddListener((System.Action)(() => Application.OpenURL("https://discord.gg/sTt8EzEpHP")));

            Color discordColor = new Color32(88, 101, 242, byte.MaxValue);

            buttonSpriteDiscord.color = textDiscord.color = discordColor;
            passiveButtonDiscord.OnMouseOut.AddListener((System.Action) delegate {
                buttonSpriteDiscord.color = textDiscord.color = discordColor;
            });

            // Twitterボタン
            var buttonTwitter = UnityEngine.Object.Instantiate(template, null);

            buttonTwitter.transform.localPosition = new Vector3(buttonTwitter.transform.localPosition.x, buttonTwitter.transform.localPosition.y + 1.2f, buttonTwitter.transform.localPosition.z);

            var textTwitter = buttonTwitter.transform.GetChild(0).GetComponent <TMPro.TMP_Text>();

            __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => {
                textTwitter.SetText("Twitter");
            })));

            PassiveButton  passiveButtonTwitter = buttonTwitter.GetComponent <PassiveButton>();
            SpriteRenderer buttonSpriteTwitter  = buttonTwitter.GetComponent <SpriteRenderer>();

            passiveButtonTwitter.OnClick = new Button.ButtonClickedEvent();
            passiveButtonTwitter.OnClick.AddListener((System.Action)(() => Application.OpenURL("https://twitter.com/haoming_dev")));

            Color twitterColor = new Color32(29, 161, 242, byte.MaxValue);

            buttonSpriteTwitter.color = textTwitter.color = twitterColor;
            passiveButtonTwitter.OnMouseOut.AddListener((System.Action) delegate {
                buttonSpriteTwitter.color = textTwitter.color = twitterColor;
            });

            // アップデートボタン
            ModUpdater.LaunchUpdater();
            if (!ModUpdater.hasUpdate)
            {
                return;
            }
            if (template == null)
            {
                return;
            }

            var button = UnityEngine.Object.Instantiate(template, null);

            button.transform.localPosition = new Vector3(button.transform.localPosition.x, button.transform.localPosition.y + 0.6f, button.transform.localPosition.z);

            PassiveButton passiveButton = button.GetComponent <PassiveButton>();

            passiveButton.OnClick = new Button.ButtonClickedEvent();
            passiveButton.OnClick.AddListener((UnityEngine.Events.UnityAction)onClick);

            var text = button.transform.GetChild(0).GetComponent <TMPro.TMP_Text>();

            __instance.StartCoroutine(Effects.Lerp(0.1f, new System.Action <float>((p) => {
                text.SetText(ModTranslation.getString("updateButton"));
            })));

            TwitchManager man = DestroyableSingleton <TwitchManager> .Instance;

            ModUpdater.InfoPopup = UnityEngine.Object.Instantiate <GenericPopup>(man.TwitchPopup);
            ModUpdater.InfoPopup.TextAreaTMP.fontSize        *= 0.7f;
            ModUpdater.InfoPopup.TextAreaTMP.enableAutoSizing = false;

            // Discordボタンを上にずらす
            buttonDiscord.transform.localPosition = new Vector3(buttonDiscord.transform.localPosition.x, buttonDiscord.transform.localPosition.y + 0.6f, buttonDiscord.transform.localPosition.z);
            buttonTwitter.transform.localPosition = new Vector3(buttonTwitter.transform.localPosition.x, buttonTwitter.transform.localPosition.y + 0.6f, buttonTwitter.transform.localPosition.z);

            void onClick()
            {
                ModUpdater.ExecuteUpdate();
                button.SetActive(false);
            }
        }
Пример #11
0
 public TwitchCommands(TwitchManager twitchManager)
 {
     _twitchManager = twitchManager;
 }
 protected override void IStart()
 {
     // Twitches are just so convienent! and cross-platform.
     TwitchManager.Set <float> set = delegate(float val, Object param) { };
     TwitchManager.CreateTwitch <float>(0, 1, set, duration, TwitchCurve.Shape.Linear, null, OnTwitchComplete);
 }
Пример #13
0
 private void StartDownloadInProgressTwitchBack(object unused)
 {
     TwitchManager.Set <float> set = delegate(float value, object param) { downloadInProgressAnimOffset = value; };
     TwitchManager.CreateTwitch(downloadInProgressAnimOffset, kDownloadInProgressIconOffset, set, kDownloadInProgressIconTwitchTime, TwitchCurve.Shape.EaseInOut, null, MaybeRestartDownloadInProgressTwitch);
 }
Пример #14
0
 private void StartDownloadStateIconAlphaTwitch(object unused)
 {
     downloadStateIconAlpha = 0;
     TwitchManager.Set <float> set = delegate(float value, object param) { downloadStateIconAlpha = value; };
     TwitchManager.CreateTwitch(downloadStateIconAlpha, 1, set, kDownloadStateIconAlphaTwitchTime, TwitchCurve.Shape.Linear);
 }
Пример #15
0
        /// <summary>
        /// Takes the current state and set the parameters to control the facial features.
        /// </summary>
        protected virtual void SetState(FaceState state)
        {
            float pupilSizeLeftTarget  = 1.0f;
            float pupilSizeRightTarget = 1.0f;
            int   milliseconds         = (int)(Time.GameTimeTotalSeconds * 1000.0);

            switch (state)
            {
            case FaceState.Crazy:
                eyeShapeLeft         = EyeShape.Open;
                eyeShapeRight        = EyeShape.Squint;
                pupilSizeLeftTarget  = 0.3f;
                pupilSizeRightTarget = 1.2f;
                browPositionLeft     = BrowPosition.Up;
                browPositionRight    = BrowPosition.Down;
                int brow = ((int)(Time.GameTimeTotalSeconds * 1000.0)) % 400 / 100;
                switch (brow)
                {
                case 0:
                    browPositionRight = BrowPosition.Normal;
                    break;

                case 1:
                    browPositionRight = BrowPosition.Down;
                    break;

                case 2:
                    browPositionRight = BrowPosition.Normal;
                    break;

                case 3:
                    browPositionRight = BrowPosition.Up;
                    break;
                }
                break;

            case FaceState.Happy:
                eyeShapeLeft        = eyeShapeRight = EyeShape.Open;
                pupilSizeLeftTarget = pupilSizeRightTarget = 1.2f;
                // Wiggle the brows.
                if ((milliseconds % 200) > 100)
                {
                    browPositionLeft = BrowPosition.Normal;
                }
                else
                {
                    browPositionLeft = BrowPosition.Up;
                }
                if ((milliseconds % 200) > 120)
                {
                    browPositionRight = BrowPosition.Normal;
                }
                else
                {
                    browPositionRight = BrowPosition.Up;
                }
                break;

            case FaceState.Mad:
                eyeShapeLeft        = eyeShapeRight = EyeShape.Squint;
                pupilSizeLeftTarget = pupilSizeRightTarget = 0.4f;
                browPositionLeft    = browPositionRight = BrowPosition.Down;
                break;

            case FaceState.Sad:
                eyeShapeLeft        = eyeShapeRight = EyeShape.Open;
                pupilSizeLeftTarget = pupilSizeRightTarget = 1.6f;
                browPositionLeft    = browPositionRight = BrowPosition.Up;
                break;

            case FaceState.Remember:
                // Boku looks up and to the left like he's remembering.
                eyeShapeLeft        = eyeShapeRight = EyeShape.Open;
                pupilSizeLeftTarget = pupilSizeRightTarget = 0.9f;
                browPositionLeft    = browPositionRight = BrowPosition.Up;
                gazeState           = GazeState.Fixed;
                gazeDuration        = 0.01f;
                pupilOffsetLeft     = new Vector2(-0.10f, 0.15f);
                pupilOffsetRight    = pupilOffsetLeft;
                break;

            case FaceState.Squint:
                eyeShapeLeft        = eyeShapeRight = EyeShape.Squint;
                pupilSizeLeftTarget = pupilSizeRightTarget = 0.9f;
                browPositionLeft    = browPositionRight = BrowPosition.Up;
                break;

            case FaceState.Dead:
                eyeShapeLeft         = EyeShape.Open;
                eyeShapeRight        = EyeShape.Squint;
                pupilSizeLeftTarget  = 0.5f;
                pupilSizeRightTarget = 0.5f;
                browPositionLeft     = BrowPosition.Normal;
                browPositionRight    = BrowPosition.Normal;
                pupilOffsetLeft      = pupilOffsetRight = new Vector2();
                gazeState            = GazeState.Fixed;
                gazeDuration         = float.MaxValue;
                break;

            default:
                eyeShapeLeft        = eyeShapeRight = EyeShape.Open;
                pupilSizeLeftTarget = pupilSizeRightTarget = 1.0f;
                browPositionLeft    = browPositionRight = BrowPosition.Normal;
                break;
            }

            // fire the change event so others can react
            if (newState && FaceChange != null)
            {
                FaceChange(state);
            }

            // A change of state may change the size of the pupils.  If so,
            // launch a twitch to smoothly change the size.
            if (newState)
            {
                newState = false;
                if (pupilSizeLeft != pupilSizeLeftTarget)
                {
                    TwitchManager.Set <float> set = delegate(float val, Object param) { pupilSizeLeft = val; };
                    TwitchManager.CreateTwitch <float>(pupilSizeLeft, pupilSizeLeftTarget, set, 0.2f, TwitchCurve.Shape.EaseInOut, null, null, true);
                }
                if (pupilSizeRight != pupilSizeRightTarget)
                {
                    TwitchManager.Set <float> set = delegate(float val, Object param) { pupilSizeRight = val; };
                    TwitchManager.CreateTwitch <float>(pupilSizeRight, pupilSizeRightTarget, set, 0.2f, TwitchCurve.Shape.EaseInOut, null, null, true);
                }
            }
        }   // end of Face SetState()
Пример #16
0
 public TwitchController(TwitchManager twitchManager)
 {
     this.twitchManager = twitchManager;
 }
Пример #17
0
        }   // end of ScrollUp()

        private void TwitchTextOffset()
        {
            // Start a twitch to move the text text offset.
            TwitchManager.Set <float> set = delegate(float val, Object param) { textOffset = (int)val; dirty = true; };
            TwitchManager.CreateTwitch <float>(textOffset, -topLine * Font().LineSpacing, set, 0.2f, TwitchCurve.Shape.OvershootOut);
        }   // end of TwitchTextOffset()
Пример #18
0
            public override void Update()
            {
                // Did we switch modes?
                if (inputMode != GamePadInput.ActiveMode)
                {
                    inputMode    = GamePadInput.ActiveMode;
                    shared.dirty = true;
                }

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                // Input focus and not pushing?
                if (parent.Active && CommandStack.Peek() == parent.commandMap && shared.pushOffset == 0.0f)
                {
                    GamePadInput pad = GamePadInput.GetGamePad0();

                    if (Actions.Cancel.WasPressed)
                    {
                        Actions.Cancel.ClearAllWasPressedState();

                        parent.Deactivate();
                        Foley.PlayShuffle();
                        shared.dirty = true;
                    }

                    bool moveLeft  = false;
                    bool moveRight = false;

                    // left
                    if (Actions.ComboLeft.WasPressedOrRepeat)
                    {
                        moveLeft = true;
                    }

                    // right
                    if (Actions.ComboRight.WasPressedOrRepeat)
                    {
                        moveRight = true;
                    }

                    //touch?
                    if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch)
                    {
                        TouchContact touch    = TouchInput.GetOldestTouch();
                        Vector2      touchHit = Vector2.Zero;

                        SwipeGestureRecognizer swipeGesture = TouchGestureManager.Get().SwipeGesture;
                        if (swipeGesture.WasSwiped() &&
                            swipeGesture.SwipeDirection == Boku.Programming.Directions.East)
                        {
                            moveLeft = true;
                        }
                        else if (swipeGesture.WasSwiped() &&
                                 swipeGesture.SwipeDirection == Boku.Programming.Directions.West)
                        {
                            moveRight = true;
                        }
                        else if (touch != null)
                        {
                            touchHit = touch.position;

                            if (shared.leftArrowBox.Touched(touch, touchHit))
                            {
                                moveLeft = true;
                            }

                            if (shared.rightArrowBox.Touched(touch, touchHit))
                            {
                                moveRight = true;
                            }

                            if (shared.backBox.Touched(touch, touchHit))
                            {
                                Actions.Cancel.ClearAllWasPressedState();

                                parent.Deactivate();
                                Foley.PlayShuffle();
                                shared.dirty = true;
                            }
                        }
                    }

                    // Mouse hit?
                    else if (GamePadInput.ActiveMode == GamePadInput.InputMode.KeyboardMouse)
                    {
                        Vector2 mouseHit = new Vector2(MouseInput.Position.X, MouseInput.Position.Y);

                        if (shared.leftArrowBox.LeftPressed(mouseHit))
                        {
                            moveLeft = true;
                        }

                        if (shared.rightArrowBox.LeftPressed(mouseHit))
                        {
                            moveRight = true;
                        }

                        if (shared.backBox.LeftPressed(mouseHit))
                        {
                            Actions.Cancel.ClearAllWasPressedState();

                            parent.Deactivate();
                            Foley.PlayShuffle();
                            shared.dirty = true;
                        }
                    }

                    if (moveLeft)
                    {
                        --shared.curScreen;
                        if (shared.curScreen < 0)
                        {
                            parent.Deactivate();
                        }
                        Foley.PlayShuffle();
                        shared.dirty = true;

                        shared.pushOffset = -BokuGame.ScreenSize.X;
                    }

                    if (moveRight)
                    {
                        ++shared.curScreen;
                        if (shared.curScreen >= shared.screenList.Count)
                        {
                            parent.Deactivate();
                        }
                        Foley.PlayShuffle();
                        shared.dirty = true;

                        shared.pushOffset = BokuGame.ScreenSize.X;
                    }
                }

                if (shared.dirty && shared.curScreen >= 0 && shared.curScreen < shared.screenList.Count)
                {
                    shared.prevTexture = shared.curTexture;

                    // Get the correct overlay image to use depending on input mode.
                    string name = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? shared.screenList[shared.curScreen].name : shared.screenList[shared.curScreen].mouseName;
                    shared.curTexture = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\HelpScreens\" + name);
                    shared.dirty      = false;

                    // Create a twitch to do the push.
                    TwitchManager.Set <float> set = delegate(float val, Object param) { shared.pushOffset = val; };
                    TwitchManager.CreateTwitch <float>(shared.pushOffset, 0.0f, set, 0.3f, TwitchCurve.Shape.EaseOut);
                }
            }   // end of Update()
Пример #19
0
        private void HandleTouchInput(TouchContact touch, Vector2 hit)
        {
            if (hitBoxA.Touched(touch, hit))
            {
                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (hitBoxB.Touched(touch, hit))
            {
                // Disable this hint until reset by user.
                XmlOptionsData.SetHintAsDisabled(curHint.ID);

                // Disable this hint for this session.
                if (curHint.ShowOnce)
                {
                    curHint.Disabled = true;
                }

                Deactivate();
            }
            else if (upBox.Touched(touch, hit))
            {
                ScrollDown();
            }
            else if (downBox.Touched(touch, hit))
            {
                ScrollUp();
            }
            else
            {
                // Touch is active, but none of the buttons were hit so assume user is trying to scroll text.
                if (touch.phase == TouchPhase.Began)
                {
                    prevTouchY = touch.position.Y;
                }
                if (touch.phase == TouchPhase.Moved)
                {
                    // Note we calc the delta ourselves since the TouchInput code
                    // may return the TouchContact for multiple frames.
                    float delta = touch.position.Y - prevTouchY;

                    // Adjust for screen / rt ratio.
                    Vector2 ratio = TouchInput.GetWinRTRatio(camera);
                    delta /= ratio.Y;

                    accumulatedTouchInput += delta;
                    prevTouchY             = touch.position.Y;
                    if (accumulatedTouchInput > blob.TotalSpacing / 2)
                    {
                        accumulatedTouchInput -= blob.TotalSpacing;
                        ScrollDown();
                    }
                    else if (accumulatedTouchInput < -blob.TotalSpacing / 2)
                    {
                        accumulatedTouchInput += blob.TotalSpacing;
                        ScrollUp();
                    }
                }
            }

            // Check for hover and adjust text color to match.
            Color newColor;

            newColor = hitBoxA.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelATargetColor)
            {
                labelATargetColor = newColor;
                Vector3 curColor  = new Vector3(labelAColor.R / 255.0f, labelAColor.G / 255.0f, labelAColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelAColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelAColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelAColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }

            newColor = hitBoxB.Contains(hit) ? hoverTextColor : lightTextColor;
            if (newColor != labelBTargetColor)
            {
                labelBTargetColor = newColor;
                Vector3 curColor  = new Vector3(labelBColor.R / 255.0f, labelBColor.G / 255.0f, labelBColor.B / 255.0f);
                Vector3 destColor = new Vector3(newColor.R / 255.0f, newColor.G / 255.0f, newColor.B / 255.0f);

                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                {
                    labelBColor.R = (byte)(value.X * 255.0f + 0.5f);
                    labelBColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    labelBColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }
        }   // end of HandleTouchInput()
Пример #20
0
 private void Awake()
 {
     instance = this;
 }