示例#1
0
            /// <summary>
            /// Updates the text color to show hover status.
            /// </summary>
            /// <param name="mouseHit"></param>
            public static void UpdateTextColor(Vector2 mouseHit)
            {
                Color newColor = undoHitBox.Contains(mouseHit) ? hoverColor : noHoverColor;

                if (newColor != undoTargetTextColor)
                {
                    undoTargetTextColor = newColor;
                    Vector3 curColor  = new Vector3(undoTextColor.R / 255.0f, undoTextColor.G / 255.0f, undoTextColor.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)
                    {
                        undoTextColor.R = (byte)(value.X * 255.0f + 0.5f);
                        undoTextColor.G = (byte)(value.Y * 255.0f + 0.5f);
                        undoTextColor.B = (byte)(value.Z * 255.0f + 0.5f);
                    };
                    TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
                }

                newColor = redoHitBox.Contains(mouseHit) ? hoverColor : noHoverColor;
                if (newColor != redoTargetTextColor)
                {
                    redoTargetTextColor = newColor;
                    Vector3 curColor  = new Vector3(redoTextColor.R / 255.0f, redoTextColor.G / 255.0f, redoTextColor.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)
                    {
                        redoTextColor.R = (byte)(value.X * 255.0f + 0.5f);
                        redoTextColor.G = (byte)(value.Y * 255.0f + 0.5f);
                        redoTextColor.B = (byte)(value.Z * 255.0f + 0.5f);
                    };
                    TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
                }
            }   // end of UpdateTextColor()
示例#2
0
        public void SetHoverState(Vector2 mouseHit)
        {
            Color newColor = box.Contains(mouseHit) ? hoverColor : color;

            if (newColor != targetColor)
            {
                if (newColor != color)
                {
                    state = ButtonState.Pressed;
                }
                else
                {
                    state = ButtonState.Released;
                }

                targetColor = newColor;
                Vector3 curColor  = new Vector3(renderColor.R / 255.0f, renderColor.G / 255.0f, renderColor.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)
                {
                    renderColor.R = (byte)(value.X * 255.0f + 0.5f);
                    renderColor.G = (byte)(value.Y * 255.0f + 0.5f);
                    renderColor.B = (byte)(value.Z * 255.0f + 0.5f);
                };
                TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
            }
        }   // end of SetHoverState()
示例#3
0
        }   // end of SetOrientation()

        /// <summary>
        /// Smoothly changes the orientation from the current values to the new.
        /// </summary>
        /// <param name="o"></param>
        public void TwitchOrientation(Orientation o)
        {
            TwitchCurve.Shape shape      = TwitchCurve.Shape.OvershootOut;
            float             twitchTime = 0.25f;

            if (Level == null)
            {
                return;
            }

            Orientation cur = orientation;

            // Rotation
            if (twitchOrientation.rotation != o.rotation)
            {
                twitchOrientation.rotation = o.rotation;
                TwitchManager.Set <float> set = delegate(float val, Object param) { cur.rotation = val; };
                TwitchManager.CreateTwitch <float>(cur.rotation, o.rotation, set, twitchTime, shape);
            }
            // Scale
            if (twitchOrientation.scale != o.scale)
            {
                twitchOrientation.scale = o.scale;
                TwitchManager.Set <float> set = delegate(float val, Object param) { cur.scale = val; };
                TwitchManager.CreateTwitch <float>(cur.scale, o.scale, set, twitchTime, shape);
            }
            // Position
            if (twitchOrientation.position != o.position)
            {
                twitchOrientation.position = o.position;
                TwitchManager.Set <Vector3> set = delegate(Vector3 val, Object param) { cur.position = val; };
                TwitchManager.CreateTwitch <Vector3>(cur.position, o.position, set, twitchTime, shape);
            }
        }   // TwitchedOrientation()
示例#4
0
        }   // end of HandleTouchInput()

        private void HandleMouseInput(Vector2 hit)
        {
            if (hitBox.LeftPressed(hit))
            {
                Deactivate();
            }

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

            newColor = hitBox.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);
            }
        }   // end of HandleMouseInput()
示例#5
0
        public override void SetColor(Classification.Colors color)
        {
            base.SetColor(color);

            // Apply a twitch to transition the RGBA color to match.
            // colorRGBA = ColorVector4(color);
            TwitchManager.Set <Vector4> set = delegate(Vector4 val, Object param) { tail.Color = val; };
            TwitchManager.CreateTwitch(tail.Color, Classification.ColorVector4(color), set, 0.1f, TwitchCurve.Shape.EaseInOut);
        }
示例#6
0
            public void SetFocus(int indexNew)
            {
                float twitchTime = 0.1f;

                // Undo previous slice selection state.
                if ((this.indexLastHoverItem > -1) &&
                    (this.indexLastHoverItem != indexNew))
                {
                    PieMenuSlice menuSlice = this.slices[indexLastHoverItem];
                    menuSlice.DiffuseColor = PieSelector.RenderObjSlice.ColorNormal;

                    if (slices.Count > 2) // dont move them if only two
                    {
                        ITransform transformSlice       = menuSlice.mySlice as ITransform;
                        TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                        {
                            transformSlice.Local.OriginTranslation = value;
                            transformSlice.Compose();
                        };
                        TwitchManager.CreateTwitch <Vector3>(
                            transformSlice.Local.OriginTranslation,
                            SliceOffsetDefault,
                            set,
                            twitchTime,
                            TwitchCurve.Shape.EaseInOut);
                    }
                }

                // apply new slice selection state
                // if (indexNew != indexCenteredItem)
                if ((indexNew > -1) &&
                    (indexNew != indexCurrentHoverItem))
                {
                    PieMenuSlice menuSlice = this.slices[indexNew];
                    menuSlice.DiffuseColor = PieSelector.RenderObjSlice.ColorSelectedBright;

                    Foley.PlayClick();
                    if (slices.Count > 2) // don't move them if only two
                    {
                        ITransform transformSlice = menuSlice.mySlice as ITransform;
                        {
                            TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
                            {
                                transformSlice.Local.OriginTranslation = value;
                                transformSlice.Compose();
                            };
                            TwitchManager.CreateTwitch <Vector3>(
                                transformSlice.Local.OriginTranslation,
                                new Vector3(0.20f, 0.0f, 0.0f),
                                set,
                                twitchTime,
                                TwitchCurve.Shape.EaseInOut);
                        }
                    }
                    indexCurrentHoverItem = indexNew;
                }
            }
示例#7
0
 private void MaybeRestartDownloadInProgressTwitch(object unused)
 {
     downloadInProgressAnimOffset = kDownloadInProgressIconOffset;
     if (Level != null && Level.DownloadState == LevelMetadata.DownloadStates.InProgress)
     {
         TwitchManager.Set <float> set = delegate(float value, object param) { downloadInProgressAnimOffset = value; };
         TwitchManager.CreateTwitch(downloadInProgressAnimOffset, 0, set, kDownloadInProgressIconTwitchTime, TwitchCurve.Shape.EaseInOut, null, StartDownloadInProgressTwitchBack);
     }
 }
示例#8
0
 /// <summary>
 /// Sets the color of the actor using a twitch to smooth the transition.
 /// Don't set this directly on GameThings, use GameThing.SetColor instead.
 /// </summary>
 /// <param name="color"></param>
 public void SetColor(Classification.Colors value)
 {
     if (color != value)
     {
         color = value;
         // Twitch ColorRGBA from whatever the current value is toward the new value.
         TwitchManager.Set <Vector4> set = delegate(Vector4 val, Object param) { colorRGBA = val; };
         TwitchManager.CreateTwitch(ColorRGBA, ColorVector4(color), set, 0.25f, TwitchCurve.Shape.EaseInOut);
     }
 }   // end of SetColor
示例#9
0
        public void AnimatePanelMove(float changeY)
        {
            position.Y += changeY;
            ITransform transform = this as ITransform;

            if (transform != null)
            {
                TwitchManager.Set <float> set = delegate(float value, Object param) { Vector3 trans = transform.Local.Translation; trans.Y = value; transform.Local.Translation = trans; transform.Compose(); };
                TwitchManager.CreateTwitch <float>(transform.Local.Translation.Y, position.Y, set, twitchTime, TwitchCurve.Shape.EaseOut);
            }
        }
示例#10
0
        public void AnimatePanelShift(float changeZ, TwitchCompleteEvent callback)
        {
            position.Z += changeZ;
            ITransform transform = this as ITransform;

            if (transform != null)
            {
                TwitchManager.Set <float> set = delegate(float value, Object param) { Vector3 trans = transform.Local.Translation; trans.Z = value; transform.Local.Translation = trans; transform.Compose(); };
                TwitchManager.CreateTwitch <float>(transform.Local.Translation.Z, position.Z, set, twitchTime, TwitchCurve.Shape.EaseOut, this, callback);
            }
        }
示例#11
0
        }   // end of UIElement Update()

        /// <summary>
        /// Change the position value using a twitch.
        /// </summary>
        /// <param name="finalValue">Destination value.</param>
        /// <param name="twitchTime">Time in seconds for twitch.</param>
        /// <param name="twitchShape">Animation curve shape to apply to twitch.</param>
        public void TwitchPosition(Vector3 finalValue, float twitchTime, TwitchCurve.Shape twitchShape)
        {
            if (twitchTime > 0.0f)
            {
                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { Position = value; };
                TwitchManager.CreateTwitch <Vector3>(Position, finalValue, set, twitchTime, twitchShape);
            }
            else
            {
                // No time, just set the result.
                position = finalValue;
            }
        }   // end of UIGridElement TwitchPosition()
示例#12
0
        /// <summary>
        /// Make a smooth transition to the new color.
        /// </summary>
        /// <param name="color"></param>
        protected void SetColor(Vector4 color)
        {
            // Apply a twitch to transition the RGBA color to match.
            // colorRGBA = ColorVector4(color);
            TwitchManager.Set <Vector4> set = delegate(Vector4 val, Object param) { tail.Color = val; };
            TwitchManager.CreateTwitch <Vector4>(
                tail.Color,
                color,
                set,
                0.1f,
                TwitchCurve.Shape.EaseInOut);

            LuzAtt.SetLightColor(color);
        }
示例#13
0
        }   // end of Render()

        public void ClearState()
        {
            state       = ButtonState.Released;
            targetColor = color;
            Vector3 curColor  = new Vector3(renderColor.R / 255.0f, renderColor.G / 255.0f, renderColor.B / 255.0f);
            Vector3 destColor = new Vector3(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f);

            TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param)
            {
                renderColor.R = (byte)(value.X * 255.0f + 0.5f);
                renderColor.G = (byte)(value.Y * 255.0f + 0.5f);
                renderColor.B = (byte)(value.Z * 255.0f + 0.5f);
            };
            TwitchManager.CreateTwitch <Vector3>(curColor, destColor, set, 0.1f, TwitchCurve.Shape.EaseOut);
        }
示例#14
0
        /// <summary>
        /// Moves the curent panel to the correct indent position to match it's current indent level.
        /// If the panel is already in the correct position, nothing happens.  This is designed to
        /// work fine if called every frame for each panel.
        /// </summary>
        public void AnimatePanelIndent(bool force)
        {
            float kIndentSpacing = 0.6f;

            float x = reflex.Indentation * kIndentSpacing;

            if (position.X != x || force)
            {
                position.X = x;
                ITransform transform = this as ITransform;
                if (transform != null)
                {
                    TwitchManager.Set <float> set = delegate(float value, Object param) { Vector3 trans = transform.Local.Translation; trans.X = value; transform.Local.Translation = trans;  transform.Compose(); };
                    TwitchManager.CreateTwitch <float>(transform.Local.Translation.X, position.X, set, 0.1f, TwitchCurve.Shape.EaseOut, this, null);
                }
            }
        }
        }   // end of Deactivate()

        public void Update()
        {
            touchedThisFrame = false;
            if (active)
            {
                InGame.SetViewportToScreen();

                camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);
                camera.Recalc();
                camera.Update();

                Matrix matrix = Matrix.Identity;
                brightnessSlider.Update(ref matrix);
                durationSlider.Update(ref matrix);
                ledGrid.Update(ref matrix);
                bar.Update(ref matrix);

                switch (GamePadInput.ActiveMode)
                {
                case GamePadInput.InputMode.GamePad:
                    HandleGamePad();
                    break;

                case GamePadInput.InputMode.Touch:
                    HandleTouch();
                    break;

                case GamePadInput.InputMode.KeyboardMouse:
                    HandleMouse();
                    break;
                }

                // Adjust alpha value for stick icons if needed.
                float targetAlpha = GamePadInput.ActiveMode == GamePadInput.InputMode.GamePad ? 1.0f : 0.0f;
                if (targetAlpha != _stickAlpha)
                {
                    _stickAlpha = targetAlpha;
                    TwitchManager.Set <float> set = delegate(float value, Object param) { stickAlpha = value; };
                    TwitchManager.CreateTwitch <float>(stickAlpha, _stickAlpha, set, 0.2f, TwitchCurve.Shape.EaseOut);
                }

                // touchedThisFrame = true;
            }
        }   // end of Update()
示例#16
0
        public void TransitionToWaterType(int newType, float transitionTime)
        {
            //check if another transition was running, if so, don't start another
            if (waterTransitioning)
            {
                //already transitioning to this type?  if so, return and let the current transition finish
                if (allTypes[newType] == transitionToDefinition)
                {
                    return;
                }
                StopWaterTransition();
            }

            transitionFromDefinition = definition;
            transitionToDefinition   = allTypes[newType];
            transitionAmount         = 0.0f;
            waterTransitioning       = true;

            //make a copy so we aren't adjusting the real values
            definition = new Definition(definition);

            //since we're moving from 0.0 to 1.0, use the input as the lerp value (even though it won't technically be linear)
            TwitchManager.Set <float> waterLerp = delegate(float value, Object param)
            {
                transitionAmount         = value;
                definition.Color         = transitionFromDefinition.Color * (1.0f - value) + transitionToDefinition.Color * value;
                definition.Emissive      = transitionFromDefinition.Emissive * (1.0f - value) + transitionToDefinition.Emissive * value;
                definition.ExplicitBloom = transitionFromDefinition.ExplicitBloom * (1.0f - value) + transitionToDefinition.ExplicitBloom * value;
                definition.Fresnel       = transitionFromDefinition.Fresnel * (1.0f - value) + transitionToDefinition.Fresnel * value;
                definition.Shininess     = transitionFromDefinition.Shininess * (1.0f - value) + transitionToDefinition.Shininess * value;
                definition.TextureTiling = transitionFromDefinition.TextureTiling * (1.0f - value) + transitionToDefinition.TextureTiling * value;
            };

            TwitchCompleteEvent waterLerpComplete = delegate(Object param)
            {
                definition         = transitionToDefinition;
                waterTransitioning = false;
            };

            TwitchCompleteEvent waterLerpTerminated = delegate(Object param) {};

            waterTwitchId = TwitchManager.CreateTwitch <float>(0.0f, 1.0f, waterLerp, transitionTime, TwitchCurve.Shape.EaseIn, null, waterLerpComplete, waterLerpTerminated, true);
        }
        }   // end of RefreshPositions()

        private void TwitchPic(int index, float size, Vector2 position)
        {
            float kTwitchTime = 0.1f;

            if (size != pics[index]._size)
            {
                // Scale.
                TwitchManager.Set <float> set = delegate(float val, Object param) { pics[index].size = val; dirty = true; };
                TwitchManager.CreateTwitch <float>(pics[index].size, size, set, kTwitchTime, TwitchCurve.Shape.EaseInOut);
                pics[index]._size = size;
            }
            if (position != pics[index]._position)
            {
                // Position.
                TwitchManager.Set <Vector2> set = delegate(Vector2 val, Object param) { pics[index].position = val; dirty = true; };
                TwitchManager.CreateTwitch <Vector2>(pics[index].position, position, set, kTwitchTime, TwitchCurve.Shape.EaseInOut);
                pics[index]._position = position;
            }
        }   // end of TwitchPick()
示例#18
0
 /// <summary>
 /// Set the color for this light. Use this rather than the accessor, to
 /// get a smooth twitch.
 /// </summary>
 /// <param name="dstCol4"></param>
 public void SetLightColor(Vector4 dstCol4)
 {
     Color = new Vector3(dstCol4.X, dstCol4.Y, dstCol4.Z);
     if (luz != null)
     {
         TwitchManager.Set <Vector3> set = delegate(Vector3 val, Object param)
         {
             if (luz != null)
             {
                 luz.Color = val;
             }
         };
         TwitchManager.CreateTwitch <Vector3>(
             luz.Color,
             Color,
             set,
             0.1f,
             TwitchCurve.Shape.EaseInOut);
     }
 }
示例#19
0
        }   // end of UIGridElement TwitchScale()

        /// <summary>
        /// Change the grey value using a twitch.
        /// </summary>
        /// <param name="finalValue">Destination value.</param>
        /// <param name="twitchTime">Time in seconds for twitch.</param>
        /// <param name="twitchShape">Animation curve shape to apply to twitch.</param>
        public void TwitchGrey(float finalValue, float twitchTime, TwitchCurve.Shape twitchShape)
        {
            if (twitchTime > 0.0f)
            {
                if (targetGrey != finalValue)
                {
                    // Create a twitch to change grey in baseColor
                    TwitchManager.Set <float> set = delegate(float value, Object param) { Grey = value; };
                    TwitchManager.CreateTwitch <float>(Grey, finalValue, set, twitchTime, twitchShape);

                    targetGrey = finalValue;
                }
            }
            else
            {
                // No time, just set the result.
                grey       = finalValue;
                targetGrey = finalValue;
            }
        }   // end of UIGridElement TwitchGrey()
示例#20
0
        /// <summary>
        /// Renders the waypoint color palette.
        /// </summary>
        /// <param name="activeColor">Active color in 0..6 range</param>
        public void Render(int activeColor)
        {
            // First, check if the active color has changed.  If so, create twitches to smoothly change scales.
            if (activeColor != prevColor)
            {
                if (prevColor != -1)
                {
                    int index = prevColor;
                    TwitchManager.Set <float> set = delegate(float val, Object param) { textureSize[index] = val; };
                    TwitchManager.CreateTwitch <float>(textureSize[index], inactiveSize, set, 0.2f, TwitchCurve.Shape.EaseInOut);
                }
                {
                    int index = activeColor;
                    TwitchManager.Set <float> set = delegate(float val, Object param) { textureSize[index] = val; };
                    TwitchManager.CreateTwitch <float>(textureSize[index], activeSize, set, 0.2f, TwitchCurve.Shape.EaseInOut);
                }

                prevColor = activeColor;
            }

            camera.Resolution = new Point((int)BokuGame.ScreenSize.X, (int)BokuGame.ScreenSize.Y);
            camera.Dirty      = true;
            camera.Recalc();

            // Update positions.
            CalcPositions(camera);

            // Set up params for rendering UI with this camera.
            Fx.ShaderGlobals.SetCamera(camera);

            for (int i = 0; i < numEntries; i++)
            {
                buttons[i].Scale    = textureSize[i];
                buttons[i].Position = new Vector3(texturePosition[i], 2.0f);
                buttons[i].Update();
                buttons[i].Render(camera);
            }
        }   // end of ColorPalette Render()
示例#21
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()
示例#22
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);
 }
示例#23
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()
            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()
 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);
 }
            }     // 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()
        }   // 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()
示例#28
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();
            }
            else 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();
            }
            else if (upBox.LeftPressed(hit))
            {
                ScrollDown();
            }
            else if (downBox.LeftPressed(hit))
            {
                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 HandleMouseInput()
示例#29
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; };
            TwitchManager.CreateTwitch <float>(textOffset, -topLine * Font().LineSpacing, set, 0.2f, TwitchCurve.Shape.OvershootOut);
        }   // end of TwitchTextOffset()
示例#30
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()