Example #1
0
        public static Int32 Evaluate(Object state, ref Boolean error, Int32 timeoffset)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(0);
            }

            Animations.Animation animation = character.AnimationManager.CurrentAnimation;
            if (animation == null)
            {
                error = true;
                return(0);
            }

            Int32 animtime = character.AnimationManager.TimeInAnimation;

            Int32 checktime = animtime + timeoffset;

            if (checktime < 0)
            {
                error = true;
                return(0);
            }

            Int32 elem_index = animation.GetElementFromTime(checktime).Id;

            return(elem_index + 1);
        }
Example #2
0
        public static Int32 Evaluate(Object state, ref Boolean error)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(0);
            }

            Animations.Animation animation = character.AnimationManager.CurrentAnimation;
            if (animation == null)
            {
                error = true;
                return(0);
            }

            Int32 animtime = character.AnimationManager.TimeInAnimation;

            if (animation.TotalTime == -1)
            {
                return(animtime + 1);
            }
            else
            {
                return(animtime - animation.TotalTime);
            }
        }
Example #3
0
        public static Int32 Evaluate(Object state, ref Boolean error, Int32 value)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(0);
            }

            Animations.Animation animation = character.AnimationManager.CurrentAnimation;
            if (animation == null)
            {
                error = true;
                return(0);
            }

            //Document states that if element == null, SFalse should be return. Testing seems to show that 0 is returned instead.

            Int32 element_index = value - 1;

            if (animation.Elements.Count <= element_index)
            {
                return(0);
            }

            Int32 animation_time    = character.AnimationManager.TimeInAnimation;
            Int32 element_starttime = animation.GetElementStartTime(element_index);

            Int32 result = animation_time - element_starttime;

            //if (animation.TotalTime != -1 && result >= animation.TotalTime) result = (result % animation.TotalTime);

            return(result);
        }
Example #4
0
        /// <summary>
        /// Callback invoked when an "in" animation has just finished.
        /// </summary>
        /// <param name="animation">The animation.</param>
        public void InAnimationFinished(Animations.Animation animation)
        {
            Debug.Log(gameObject.name + " - " + animation.GetType().Name + " finished");

            if (AnimationManager.Instance.Configuration.PingPongAfterInAnimation)
            {
                StartAllPingPongAnimations();
            }
        }
Example #5
0
    public void PlayAnimation(Animations.Animation animToPlay)
    {
        switch (animToPlay.animationType)
        {
        case Messages.AnimationMessage.AnimationMessageTypes.Scale:
            ScaleTo(animToPlay.transform, animToPlay.speed, animToPlay.target);
            animToPlay.isPlaying = true;
            if (Vector3.Distance(animToPlay.transform.localScale, animToPlay.target) < 0.001f)
            {
                animToPlay.transform.localScale = animToPlay.target;
                animToPlay.isPlaying            = false;
                animToPlay.hasFinished          = true;
            }

            break;

        case Messages.AnimationMessage.AnimationMessageTypes.MoveTo:
            //Debug.Log("Anim to play speed: " + animToPlay.speed + " time " + Time.deltaTime);

            MoveTo(animToPlay.transform, animToPlay.speed, animToPlay.target);
            animToPlay.isPlaying    = true;
            animToPlay.lastTimePlay = Time.time;
            if (Vector3.Distance(animToPlay.transform.GetComponent <RectTransform>().anchoredPosition, animToPlay.target) < 2.0f)
            {
                animToPlay.isPlaying   = false;
                animToPlay.hasFinished = true;
                animToPlay.transform.GetComponent <RectTransform>().anchoredPosition = animToPlay.target;
            }
            break;

        case Messages.AnimationMessage.AnimationMessageTypes.ChangeSprite:
            animToPlay.isPlaying = true;
            ChangeSprite(animToPlay.transform, animToPlay.targetSprite, animToPlay.targetColor);
            animToPlay.hasFinished = true;
            animToPlay.isPlaying   = false;
            break;

        case Messages.AnimationMessage.AnimationMessageTypes.Scroll:
            animToPlay.isPlaying = true;
            DetailsManager.WriteDestroyedCashElement(animToPlay.text, animToPlay.targetSprite);
            animToPlay.hasFinished = true;
            animToPlay.isPlaying   = false;
            break;

        case Messages.AnimationMessage.AnimationMessageTypes.PopUpBox:
            animToPlay.isPlaying = true;
            popUpText.text       = animToPlay.text;
            popUpImage.sprite    = animToPlay.targetSprite;
            popUpPanel.gameObject.SetActive(true);
            Client.PauseGame();
            animToPlay.hasFinished = true;
            animToPlay.isPlaying   = false;
            break;
        }
    }
Example #6
0
        public void LoadSprites(Animations.Animation animation)
        {
            if (animation == null)
            {
                throw new ArgumentNullException("animation");
            }

            foreach (Animations.AnimationElement element in animation)
            {
                GetSprite(element.SpriteId);
            }
        }
Example #7
0
        public static Boolean Evaluate(Object state, ref Boolean error, Int32 r1, Int32 rhs, Operator compare_type)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(false);
            }

            Animations.Animation animation = character.AnimationManager.CurrentAnimation;
            if (animation == null)
            {
                error = true;
                return(false);
            }

            Int32 elementindex = r1 - 1;

            if (elementindex < 0 || elementindex >= animation.Elements.Count)
            {
                error = true;
                return(false);
            }

            Int32 elementstarttime = animation.GetElementStartTime(elementindex);
            Int32 animationtime    = character.AnimationManager.TimeInAnimation;

            while (animation.TotalTime != -1 && animationtime >= animation.TotalTime)
            {
                Int32 looptime = animation.TotalTime - animation.GetElementStartTime(animation.Loopstart);
                animationtime -= looptime;
            }

            Int32 timeoffset = animationtime - elementstarttime;

            if (character.AnimationManager.IsAnimationFinished == true)
            {
                return(false);
            }

            Boolean result = SpecialFunctions.LogicalOperation(compare_type, timeoffset, rhs);

            return((compare_type == Operator.Equals) ? result && character.UpdatedAnimation : result);
        }
Example #8
0
        public static Boolean Evaluate(Object state, ref Boolean error, Int32 r1, Int32 pre, Int32 post, Operator compare_type, Symbol pre_check, Symbol post_check)
        {
            Combat.Character character = state as Combat.Character;
            if (character == null)
            {
                error = true;
                return(false);
            }

            Animations.Animation animation = character.AnimationManager.CurrentAnimation;
            if (animation == null)
            {
                error = true;
                return(false);
            }

            Int32 elementindex = r1 - 1;

            if (elementindex < 0 || elementindex >= animation.Elements.Count)
            {
                error = true;
                return(false);
            }

            Int32 elementstarttime = animation.GetElementStartTime(elementindex);
            Int32 animationtime    = character.AnimationManager.TimeInAnimation;

            while (animation.TotalTime != -1 && animationtime >= animation.TotalTime)
            {
                Int32 looptime = animation.TotalTime - animation.GetElementStartTime(animation.Loopstart);
                animationtime -= looptime;
            }

            Int32 timeoffset = animationtime - elementstarttime;

            if (character.AnimationManager.IsAnimationFinished == true)
            {
                return(false);
            }

            return(SpecialFunctions.Range(timeoffset, pre, post, compare_type, pre_check, post_check));
        }
Example #9
0
 public CycleButton(string Name, string displayText, Rectangle bounds, List <Button> buttons, Rectangle SourceRect, float scale, Animations.Animation defaultAnimation, Color DrawColor, Color TextColor, ButtonFunctionality buttonFunctionality, bool AnimationEnabled, List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> > extraTexture) : base(Name, bounds, buttons.ElementAt(0).animationManager.getExtendedTexture(), displayText, SourceRect, scale, defaultAnimation, DrawColor, TextColor, buttonFunctionality, AnimationEnabled, extraTexture)
 {
     this.buttons     = buttons;
     this.buttonIndex = 0;
 }
Example #10
0
 /// <summary>Construct an instance.</summary>
 public SliderButton(string name, string displayText, Rectangle bounds, Texture2DExtended buttonTexture, Button barTexture, Rectangle sourceRect, float scale, SliderInformation sliderInformation, Animations.Animation defaultAnimation, Color drawColor, Color textColor, ButtonFunctionality buttonFunctionality, bool animationEnabled, Dictionary <string, List <Animations.Animation> > animationsToPlay, string startingKey, int startingAnimationFrame, List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> > extraTexture, bool getLabelXYPos = true)
     : base(name, bounds, buttonTexture, displayText, sourceRect, scale, defaultAnimation, animationsToPlay, startingKey, drawColor, textColor, buttonFunctionality, startingAnimationFrame, animationEnabled, extraTexture)
 {
     this.sliderInformation = sliderInformation;
     this.getLabelXYPos     = getLabelXYPos;
     this.sliderBar         = barTexture;
     this.initializeBounds();
 }
Example #11
0
 /// <summary>
 /// Callback invoked when an "out" animation is stopped before finishing.
 /// </summary>
 /// <param name="animation">The animation.</param>
 public void OutAnimationStopped(Animations.Animation animation)
 {
     Debug.Log(gameObject.name + " - " + animation.GetType().Name + " stopped");
 }
Example #12
0
 /// <summary>
 /// Callback invoked when an "out" animation has just finished.
 /// </summary>
 /// <param name="animation">The animation.</param>
 public void OutAnimationFinished(Animations.Animation animation)
 {
     Debug.Log(gameObject.name + " - " + animation.GetType().Name + " finished");
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="displayText"></param>
 /// <param name="bounds"></param>
 /// <param name="buttonTexture"></param>
 /// <param name="barTexture"></param>
 /// <param name="SourceRect"></param>
 /// <param name="scale"></param>
 /// <param name="sliderInformation"></param>
 /// <param name="defaultAnimation"></param>
 /// <param name="DrawColor"></param>
 /// <param name="TextColor"></param>
 /// <param name="buttonFunctionality"></param>
 /// <param name="AnimationEnabled"></param>
 /// <param name="extraTexture"></param>
 /// <param name="getLabelXYPos"></param>
 public SliderButton(string Name, string displayText, Rectangle bounds, Texture2DExtended buttonTexture, Button barTexture, Rectangle SourceRect, float scale, SliderInformation sliderInformation, Animations.Animation defaultAnimation, Color DrawColor, Color TextColor, ButtonFunctionality buttonFunctionality, bool AnimationEnabled, List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> > extraTexture, bool getLabelXYPos = true) : base(Name, bounds, buttonTexture, displayText, SourceRect, scale, defaultAnimation, DrawColor, TextColor, buttonFunctionality, AnimationEnabled, extraTexture)
 {
     this.sliderInformation = sliderInformation;
     this.getLabelXYPos     = getLabelXYPos;
     this.sliderBar         = barTexture;
     initializeBounds();
 }
Example #14
0
 /// <summary>
 /// Callback invoked when an "in" animation has just started.
 /// </summary>
 /// <param name="animation">The animation.</param>
 public void InAnimationStarted(Animations.Animation animation)
 {
     Debug.Log(gameObject.name + " - " + animation.GetType().Name + " started");
 }
Example #15
0
 public CycleButton(string name, string displayText, Rectangle bounds, List <Button> buttons, Rectangle sourceRect, float scale, Animations.Animation defaultAnimation, Color drawColor, Color textColor, ButtonFunctionality buttonFunctionality, bool animationEnabled, Dictionary <string, Animations.Animation> animationsToPlay, string startingKey, int startingAnimationFrame, List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> > extraTexture)
     : base(name, bounds, buttons.ElementAt(0).animationManager.getExtendedTexture(), displayText, sourceRect, scale, defaultAnimation, animationsToPlay, startingKey, drawColor, textColor, buttonFunctionality, startingAnimationFrame, animationEnabled, extraTexture)
 {
     this.buttons     = buttons;
     this.buttonIndex = 0;
 }
Example #16
0
 /// <summary>
 /// A more advanced Button constructor that deals with an animation manager.
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="Bounds"></param>
 /// <param name="Texture"></param>
 /// <param name="displayText"></param>
 /// <param name="sourceRect"></param>
 /// <param name="Scale"></param>
 /// <param name="defaultAnimation"></param>
 /// <param name="animationsToPlay"></param>
 /// <param name="startingAnimationKey"></param>
 /// <param name="startingAnimationFrame"></param>
 /// <param name="AnimationEnabled"></param>
 public Button(string Name, Rectangle Bounds, Texture2D Texture, string displayText, Rectangle sourceRect, float Scale, Animations.Animation defaultAnimation, Dictionary <string, List <Animations.Animation> > animationsToPlay, string startingAnimationKey, Color DrawColor, Color TextColor, int startingAnimationFrame = 0, bool AnimationEnabled = true) : base(Bounds, Texture, sourceRect, Scale)
 {
     this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation, animationsToPlay, startingAnimationKey, startingAnimationFrame, AnimationEnabled);
     this.label            = displayText;
     this.name             = Name;
     this.textureColor     = DrawColor;
     if (this.textureColor == null)
     {
         this.textureColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
     }
     this.textColor = DrawColor;
     if (this.textColor == null)
     {
         this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
     }
 }
Example #17
0
 /// <summary>A more advanced Button constructor that deals with an animation manager.</summary>
 public Button(string name, Rectangle bounds, Texture2DExtended texture, string displayText, Rectangle sourceRect, float scale, Animations.Animation defaultAnimation, Dictionary <string, List <Animations.Animation> > animationsToPlay, string startingAnimationKey, Color drawColor, Color textColor, ButtonFunctionality functionality, int startingAnimationFrame = 0, bool animationEnabled = true, List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> > extraTexture = null, bool DrawLabel = true)
     : base(bounds, texture.getTexture(), sourceRect, scale)
 {
     this.animationManager    = new Animations.AnimationManager(texture, defaultAnimation, animationsToPlay, startingAnimationKey, startingAnimationFrame, animationEnabled);
     this.label               = displayText;
     this.name                = name;
     this.textureColor        = drawColor; // ?? IlluminateFramework.Colors.getColorFromList("White");
     this.textColor           = drawColor; // ?? IlluminateFramework.Colors.getColorFromList("White");
     this.buttonFunctionality = functionality;
     this.extraTextures       = extraTexture ?? new List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> >();
     this.scale               = scale;
     this.drawLabel           = DrawLabel;
 }
Example #18
0
        /// <summary>
        /// Basic Button constructor.
        /// </summary>
        /// <param name="Bounds"></param>
        /// <param name="Texture">The texture sheet to be drawn to the screen. Used with the animation manager this allows you to reference different parts of the sheet at any given time.</param>
        /// <param name="sourceRect"></param>
        /// <param name="Scale"></param>
        /// <param name="defaultAnimation"></param>
        /// <param name="AnimationEnabled"></param>
        public Button(string Name, Rectangle Bounds, Texture2DExtended Texture, string displayText, Rectangle sourceRect, float Scale, Animations.Animation defaultAnimation, Color DrawColor, Color TextColor, ButtonFunctionality Functionality, bool AnimationEnabled = true, List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> > extraTexture = null) : base(Bounds, Texture.getTexture(), sourceRect, Scale)
        {
            this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation, AnimationEnabled);
            this.label            = displayText;
            this.name             = Name;
            this.textureColor     = DrawColor;
            if (this.textureColor == null)
            {
                this.textureColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
            }
            this.textColor = TextColor;
            if (this.textColor == null)
            {
                this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
            }
            this.buttonFunctionality = Functionality;
            if (extraTexture == null)
            {
                extraTexture = new List <KeyValuePair <ClickableTextureComponent, ExtraTextureDrawOrder> >();
            }
            extraTextures = extraTexture;

            this.scale = Scale;
        }
Example #19
0
 /// <summary>
 /// Basic Button constructor.
 /// </summary>
 /// <param name="Bounds"></param>
 /// <param name="Texture">The texture sheet to be drawn to the screen. Used with the animation manager this allows you to reference different parts of the sheet at any given time.</param>
 /// <param name="sourceRect"></param>
 /// <param name="Scale"></param>
 /// <param name="defaultAnimation"></param>
 /// <param name="AnimationEnabled"></param>
 public Button(string Name, Rectangle Bounds, Texture2DExtended Texture, string displayText, Rectangle sourceRect, float Scale, Animations.Animation defaultAnimation, Color DrawColor, Color TextColor, ButtonFunctionality Functionality, bool AnimationEnabled = true) : base(Bounds, Texture.texture, sourceRect, Scale)
 {
     this.animationManager = new Animations.AnimationManager(Texture, defaultAnimation, AnimationEnabled);
     this.label            = displayText;
     this.name             = Name;
     this.textureColor     = DrawColor;
     if (this.textureColor == null)
     {
         this.textureColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
     }
     this.textColor = TextColor;
     if (this.textColor == null)
     {
         this.textColor = StardustCore.IlluminateFramework.Colors.getColorFromList("White");
     }
     this.buttonFunctionality = Functionality;
 }