コード例 #1
0
        private Gum.DataTypes.Variables.StateSave AddToCurrentValuesWithState(SunLevel state)
        {
            Gum.DataTypes.Variables.StateSave newState = new Gum.DataTypes.Variables.StateSave();
            switch (state)
            {
            case  SunLevel.Level1:
                newState.Variables.Add(new Gum.DataTypes.Variables.VariableSave()
                {
                    SetsValue = true,
                    Name      = "SpriteInstance.Texture Left",
                    Type      = "int",
                    Value     = SpriteInstance.TextureLeft + 164
                }
                                       );
                break;

            case  SunLevel.Level2:
                newState.Variables.Add(new Gum.DataTypes.Variables.VariableSave()
                {
                    SetsValue = true,
                    Name      = "SpriteInstance.Texture Left",
                    Type      = "int",
                    Value     = SpriteInstance.TextureLeft + 229
                }
                                       );
                break;

            case  SunLevel.Level3:
                newState.Variables.Add(new Gum.DataTypes.Variables.VariableSave()
                {
                    SetsValue = true,
                    Name      = "SpriteInstance.Texture Left",
                    Type      = "int",
                    Value     = SpriteInstance.TextureLeft + 294
                }
                                       );
                break;

            case  SunLevel.Level4:
                newState.Variables.Add(new Gum.DataTypes.Variables.VariableSave()
                {
                    SetsValue = true,
                    Name      = "SpriteInstance.Texture Left",
                    Type      = "int",
                    Value     = SpriteInstance.TextureLeft + 359
                }
                                       );
                break;
            }
            return(newState);
        }
コード例 #2
0
 public FlatRedBall.Glue.StateInterpolation.Tweener InterpolateToRelative(SunLevel toState, double secondsToTake, FlatRedBall.Glue.StateInterpolation.InterpolationType interpolationType, FlatRedBall.Glue.StateInterpolation.Easing easing, object owner = null)
 {
     Gum.DataTypes.Variables.StateSave           current       = GetCurrentValuesOnState(toState);
     Gum.DataTypes.Variables.StateSave           toAsStateSave = AddToCurrentValuesWithState(toState);
     FlatRedBall.Glue.StateInterpolation.Tweener tweener       = new FlatRedBall.Glue.StateInterpolation.Tweener(from: 0, to: 1, duration: (float)secondsToTake, type: interpolationType, easing: easing);
     if (owner == null)
     {
         tweener.Owner = this;
     }
     else
     {
         tweener.Owner = owner;
     }
     tweener.PositionChanged = newPosition => this.InterpolateBetween(current, toAsStateSave, newPosition);
     tweener.Ended          += () => this.CurrentSunLevelState = toState;
     tweener.Start();
     StateInterpolationPlugin.TweenerManager.Self.Add(tweener);
     return(tweener);
 }
コード例 #3
0
        public override void ApplyState(Gum.DataTypes.Variables.StateSave state)
        {
            bool matches = this.ElementSave.AllStates.Contains(state);

            if (matches)
            {
                var category = this.ElementSave.Categories.FirstOrDefault(item => item.States.Contains(state));
                if (category == null)
                {
                    if (state.Name == "Default")
                    {
                        this.mCurrentVariableState = VariableState.Default;
                    }
                }
                else if (category.Name == "SunLevel")
                {
                    if (state.Name == "Level1")
                    {
                        this.mCurrentSunLevelState = SunLevel.Level1;
                    }
                    if (state.Name == "Level2")
                    {
                        this.mCurrentSunLevelState = SunLevel.Level2;
                    }
                    if (state.Name == "Level3")
                    {
                        this.mCurrentSunLevelState = SunLevel.Level3;
                    }
                    if (state.Name == "Level4")
                    {
                        this.mCurrentSunLevelState = SunLevel.Level4;
                    }
                }
            }
            base.ApplyState(state);
        }
コード例 #4
0
        public void InterpolateBetween(SunLevel firstState, SunLevel secondState, float interpolationValue)
        {
                                #if DEBUG
            if (float.IsNaN(interpolationValue))
            {
                throw new System.Exception("interpolationValue cannot be NaN");
            }
                                #endif
            bool setSpriteInstanceTextureLeftFirstValue  = false;
            bool setSpriteInstanceTextureLeftSecondValue = false;
            int  SpriteInstanceTextureLeftFirstValue     = 0;
            int  SpriteInstanceTextureLeftSecondValue    = 0;
            switch (firstState)
            {
            case  SunLevel.Level1:
                setSpriteInstanceTextureLeftFirstValue = true;
                SpriteInstanceTextureLeftFirstValue    = 164;
                break;

            case  SunLevel.Level2:
                setSpriteInstanceTextureLeftFirstValue = true;
                SpriteInstanceTextureLeftFirstValue    = 229;
                break;

            case  SunLevel.Level3:
                setSpriteInstanceTextureLeftFirstValue = true;
                SpriteInstanceTextureLeftFirstValue    = 294;
                break;

            case  SunLevel.Level4:
                setSpriteInstanceTextureLeftFirstValue = true;
                SpriteInstanceTextureLeftFirstValue    = 359;
                break;
            }
            switch (secondState)
            {
            case  SunLevel.Level1:
                setSpriteInstanceTextureLeftSecondValue = true;
                SpriteInstanceTextureLeftSecondValue    = 164;
                break;

            case  SunLevel.Level2:
                setSpriteInstanceTextureLeftSecondValue = true;
                SpriteInstanceTextureLeftSecondValue    = 229;
                break;

            case  SunLevel.Level3:
                setSpriteInstanceTextureLeftSecondValue = true;
                SpriteInstanceTextureLeftSecondValue    = 294;
                break;

            case  SunLevel.Level4:
                setSpriteInstanceTextureLeftSecondValue = true;
                SpriteInstanceTextureLeftSecondValue    = 359;
                break;
            }
            if (setSpriteInstanceTextureLeftFirstValue && setSpriteInstanceTextureLeftSecondValue)
            {
                SpriteInstance.TextureLeft = FlatRedBall.Math.MathFunctions.RoundToInt(SpriteInstanceTextureLeftFirstValue * (1 - interpolationValue) + SpriteInstanceTextureLeftSecondValue * interpolationValue);
            }
            if (interpolationValue < 1)
            {
                mCurrentSunLevelState = firstState;
            }
            else
            {
                mCurrentSunLevelState = secondState;
            }
        }