void AddPictures()
        {
            game.Map.Library.ImagesFolder = new PathInfo {
                Path = "..\\..\\images", Type = PathType.Relative
            };
            ReadPictures("platform", "Red", 4);
            ReadPictures("flyer", "Red", 3);
            ReadPictures("flyer", "Sand", 4);
            ReadPictures("Missile", "Red", 1);
            game.Map.Library.AddPicture("base", "fanning_unit.png");
            ReadPictures("exp", "", 9);
            ReadPictures("tower", "Sand", 8);
            ReadPictures("tower", "Red", 3);
            ReadPictures("platform", "Sand", 9);
            ReadPictures("exp4-", "", 16);
            ReadPictures("blast", "", 9);
            game.Map.Library.AddPicture("Nothing", "nothing.png");
            game.Map.Library.AddPicture("MediumTank", "MediumTank.png");
            game.Map.Library.AddPicture("scavenger", "scavenger.png");
            game.Map.Library.AddPicture("tank1", "tank1.png");
            game.Map.Library.AddPicture("platformRedDestroyed3", "platformRedDestroyed3.png");
            string[] s = new string[9];
            for (int i = 1; i <= 9; i++)
            {
                s[i - 1] = "exp" + i.ToString();
            }
            AnimationDefinition a = new AnimationDefinition();

            a.AddEqualFrames(50, s);
            game.Map.Library.AddAnimation("explosion", a);
        }
Exemple #2
0
    public static bool CurrentAnimationIsNew()
    {
        AnimationDefinition def  = instance.currentAnimation;
        SpriteInfo          info = instance.loadedSpriteInfo;

        return(!info.animations.Contains(def));
    }
        void addPictures()
        {
            Map.Library.AddPicture("map", "map.jpg");
            Map.Library.AddPicture("player", "player.png");
            Map.Library.AddContainer("player", "player", ContainerType.AutosizedSingleImage);
            player.container = "player";
            Map.ContainerSetMaxSide("player", 150);
            Map.ContainerSetCoordinate("player", player.x, player.y);
            Map.ContainerSetAngle("player", player.angle);
            Map.Library.AddPicture("bullet", "bullet.png");
            Map.Library.AddPicture("mishen", "misha.png");
            Map.Library.AddPicture("GO", "Game over.png");
            Map.Library.AddPicture("enemy", "enemy.png");
            Map.Library.AddPicture("enemyShoot", "enemyShoot.png");
            Map.Library.AddPicture("heal", "heal.png");
            Map.Library.AddPicture("box", "box.png");
            AnimationDefinition animation = new AnimationDefinition();
            for (int i = 0; i < 10; i++)
            {
                Map.Library.AddPicture("exp" + i, "exp" + i + ".png");
                animation.AddFrame(100, "exp" + i);
            }

            for (int i = 0; i < 11; i++)
            {
                Map.Library.AddPicture("hp" + i, "hp" + i + ".png");
            }
            Map.Library.AddAnimation("explosion", animation);
            Map.Library.AddPicture("0", "exp10.png");
            animation.AddFrame(10, "0");
            animation.LastFrame = "0";
        }
Exemple #4
0
        static public AnimationDefinition LoadAnimationDefinition(XmlNode animationRoot)
        {
            AnimationDefinition res = new AnimationDefinition();

            res.IsBlocking = !XmlUtilities.GetBool(animationRoot, "nonBlocking");
            var frames = animationRoot.SelectNodes("./frame");

            for (int f = 0; f < frames.Count; f++)
            {
                var frame = new AnimationFrame(
                    XmlUtilities.GetInt(frames [f], "x"),
                    XmlUtilities.GetInt(frames [f], "y"),
                    XmlUtilities.GetInt(frames [f], "width"),
                    XmlUtilities.GetInt(frames [f], "height"),
                    XmlUtilities.GetInt(frames [f], "duration"),
                    XmlUtilities.GetString(frames [f], "sfx")
                    );
                frame.offset = new Vector2f(
                    XmlUtilities.GetFloat(frames [f], "offsetX"),
                    XmlUtilities.GetFloat(frames [f], "offsetY")
                    );
                res.AddFrame(frame);
            }
            return(res);
        }
 public override void execute()
 {
     animationToModify           = LegacyEditorData.instance.currentAnimation;
     previousList                = animationToModify.subimages;
     animationToModify.subimages = nextList;
     LegacyEditorData.ChangedAnimation();
 }
Exemple #6
0
 public void PlayAnimation(AnimationDefinition _anim)
 {
     if (animations.Contains(_anim) == false)
     {
         animations.Add(_anim);
     }
 }
Exemple #7
0
 public AnimationComponent(IAnimatable animationTarget, AnimationDefinition animationDefinition, string startingAnimation)
 {
     AnimationDefinition         = animationDefinition;
     AnimationTarget             = animationTarget;
     CurrentAnimation            = startingAnimation;
     CurrentAnimationElapsedTime = 0;
 }
    private void LegacyAnimation(AnimationDefinition animDef)
    {
        if (!string.IsNullOrEmpty(animDef.Animation))
        {
            var thisAnimation = Animation[animDef.Animation];
            thisAnimation.wrapMode = animDef.WrapMode;
            thisAnimation.speed    = animDef.Speed;

            if (animDef.Backwards)
            {
                thisAnimation.speed *= -1;
            }

            var asvt = Rm_RPGHandler.Instance.ASVT;
            if (!string.IsNullOrEmpty(animDef.Name) && asvt.UseStatForMovementSpeed && new[] { "Walk, Strafe, Run" }.Any(s => s.Contains(animDef.Name)))
            {
                var asvtStat  = asvt.StatForMovementID;
                var bonusMove = _controller.Character.GetStatByID(asvtStat).TotalValue - 1;
                if (bonusMove > 0)
                {
                    var add = 1 + (bonusMove / 4);
                    thisAnimation.speed *= add;
                }
            }

            Animation.CrossFade(animDef.Animation);
        }
        else
        {
            if (!string.IsNullOrEmpty(_controller.LegacyAnimation.IdleAnim.Animation))
            {
                Animation.CrossFade(_controller.LegacyAnimation.IdleAnim.Animation);
            }
        }
    }
Exemple #9
0
        /// <summary>
        ///     Loads the content for the player
        /// </summary>
        /// <param name="content"></param>
        public void LoadContent(ContentManager content)
        {
            AnimationDefinition animationDefinition = content.Load <AnimationDefinition>("playerAnimation");
            Texture2D           texture             = content.Load <Texture2D>("player");

            _sprite = new AnimatedSprite(texture, animationDefinition, this.Position);
        }
    public void AddAnimation(AnimationDefinition newDef, bool overwrite = false)
    {
        //Get all of the animations whose names match this one
        List <AnimationDefinition> existingAnimations = animations.FindAll(s => s.AnimationName == newDef.AnimationName);

        if (existingAnimations.Count > 1)
        {
            throw new System.Exception("Multiple Animations with the same name! I told you this would happen!");
        }
        //If there is already an animation, we need to figure out what to do with the old one based on the overwrite flag
        if (existingAnimations.Count > 0)
        {
            if (overwrite)
            {
                animations.RemoveAll(s => s.AnimationName == newDef.AnimationName);
                animations.Add(newDef);
            }
            else
            {
                AnimationDefinition cloneAnim = new AnimationDefinition(newDef);
                cloneAnim.AnimationName += "_new";
                animations.Add(cloneAnim);
            }
        }
        //If there aren't any existing animations, it's fine to just add it in
        else
        {
            animations.Add(newDef);
        }
    }
    private bool HandleDeathAnimation()
    {
        if (SimWorld.HasComponent <DeadTag>(SimEntity))
        {
            if (_previousState != AnimationType.Death)
            {
                TriggerAnimationInteruptionOnStateChange();

                _hasTriggeredAnAnimation = true;
                _lastTransitionTime      = SimWorld.Time.ElapsedTime;

                AnimationDefinition anim = FindAnimation(AnimationType.Death);
                if (anim != null)
                {
                    anim.TriggerAnimation(SimEntity, _spriteStartPos, _bone, null);
                }

                _previousState = AnimationType.Death;
            }

            return(true);
        }

        return(false);
    }
 public override void execute()
 {
     animationToModify = LegacyEditorData.instance.currentAnimation;
     removedSubimage   = animationToModify.subimages[indexToRemove];
     animationToModify.subimages.RemoveAt(indexToRemove);
     LegacyEditorData.ChangedAnimation();
 }
 public RPGAction WithAnimation(string animationname, float speed = 1.0f, WrapMode wrapMode = WrapMode.Loop, bool backwards = false)
 {
     Animation = new AnimationDefinition {
         Animation = animationname, Speed = speed, WrapMode = wrapMode, Backwards = backwards
     };
     return(this);
 }
    public void CrossfadeAnimation(string animationname, float speed = 1.0f, WrapMode wrapMode = WrapMode.Loop, bool backwards = false)
    {
        var animDef = new AnimationDefinition {
            Animation = animationname, Speed = speed, WrapMode = wrapMode, Backwards = backwards
        };

        CrossfadeAnimation(animDef);
    }
Exemple #15
0
 public void Play(AnimationDefinition animation)
 {
     /*if (type == AnimationTypes.Death) {
      *  IsDead = true;
      * }
      *
      * StartAnimation(GetAnimationClip(type), GetLayer(type));*/
 }
 private void OnDisable()
 {
     if (_currentAnimation != null)
     {
         _currentAnimation.StopAnimation(SimEntity);
         _currentAnimation = null;
     }
 }
 public RPGAction(RPGActionType actionType)
 {
     ID        = Guid.NewGuid().ToString();
     Type      = actionType;
     Params    = new Dictionary <string, object>();
     Animation = null;
     Sound     = null;
 }
 public RPGAction(RPGActionType actionType, Dictionary <string, object> parameters)
 {
     ID        = Guid.NewGuid().ToString();
     Type      = actionType;
     Params    = parameters;
     Animation = null;
     Sound     = null;
 }
 public AnimationDefinition(AnimationDefinition old)
 {
     _animationName       = old.AnimationName;
     _spriteRate          = old.SpriteRate;
     _loop                = old.Loop;
     subimages            = new List <string>(old.subimages);
     currentFrame         = 0;
     currentSubimageIndex = 0;
 }
    public override void execute()
    {
        //First we have to change to a null action, then we can delete the old one.
        previousAnimation = animationToDelete;
        LegacyEditorData.instance.currentAnimation = AnimationDefinition.NullAnimation; //Set to a null action

        previousIndex = LegacyEditorData.instance.loadedSpriteInfo.animations.IndexOf(animationToDelete);
        LegacyEditorData.instance.loadedSpriteInfo.DeleteAnimation(animationToDelete);
    }
    public override void undo()
    {
        AnimationDefinition def = LegacyEditorData.instance.currentAnimation;

        //Revert the property to it's previous value
        PropertyInfo prop = def.GetType().GetProperty(propertyToModify);

        prop.SetValue(def, propertyToModifyPreviousValue);
    }
Exemple #22
0
        public static RPGAction PlayAnimation(AnimationDefinition definition)
        {
            var parameters = new Dictionary <string, object>()
            {
                { "AnimDef", definition }
            };

            return(new RPGAction(RPGActionType.PlayAnimation, parameters));
        }
        public AnimatedSprite LoadPlayerContent(ContentManager content)
        {
            // Load the .json file
            AnimationDefinition animationDefinition = content.Load <AnimationDefinition>("Sprites/Me_Earthbound-Recovered");
            // Load the sprite sheet
            Texture2D spritesheet = content.Load <Texture2D>("Sprites/Me_Earthbound-Recovered-Sheet");

            // Return sprite sheet.
            return(_playerSprite = new AnimatedSprite(spritesheet, animationDefinition));
        }
Exemple #24
0
 void OnAnimationChanged(AnimationDefinition def)
 {
     if (LegacyEditorData.CurrentAnimationIsNew())
     {
         label.text = "Create Animation";
     }
     else
     {
         label.text = "Duplicate Animation";
     }
 }
 void ChangedAnimation(AnimationDefinition anim)
 {
     if (anim != null && anim == animationDefinition)
     {
         button.defaultColor = new Color(1, 1, 1, 1);
     }
     else
     {
         button.defaultColor = new Color(1, 1, 1, 0.5f);
     }
 }
    public void SetAnimation(AnimationDefinition anim)
    {
        animationDefinition = anim;
        label.text          = anim.AnimationName;
        ModifyLegacyEditorDataAction legacyAction = ScriptableObject.CreateInstance <ModifyLegacyEditorDataAction>();

        legacyAction.init("currentAnimation", anim);
        legacyAction.enableDeselect();

        GetComponent <OnClickSendAction>().action = legacyAction;
    }
    /// <summary>
    /// Change the current Animation of the Sprite Handler, starting
    /// </summary>
    /// <param name="animationName">The name of the Animation to get from the Sprite Info</param>
    /// <param name="startingFrame">The frame to start the animation on</param>
    public void ChangeAnimation(string animationName, int startingFrame)
    {
        AnimationDefinition anim = sprite_info.getAnimationByName(animationName);

        currentAnimation = anim; //Animation can be null, but if it is, we don't set the sprite
        if (anim != AnimationDefinition.NullAnimation)
        {
            anim.setFrame(startingFrame);
            ChangeSubimage(startingFrame);
        }
    }
        public static async Task AnimateItems(
            this Selector selector,
            AnimationDefinition animationDefinition,
            double itemDelay = 0.05,
            AnimationDefinition selectedItemAnimationDefinition = null)
        {
            if (selector == null)
            {
                return;
            }
            if (animationDefinition == null)
            {
                return;
            }
            if (itemDelay <= 0.0)
            {
                itemDelay = 0.05;
            }

            selector.UpdateLayout();

            var animations = new List <Task>();

            double baseDelay = animationDefinition.Delay;

            for (int index = 0; index < selector.Items.Count; index++)
            {
                var container = (FrameworkElement)selector.ItemContainerGenerator.ContainerFromIndex(index);
                if (container == null)
                {
                    continue;
                }

                if ((index == selector.SelectedIndex) && (selectedItemAnimationDefinition != null))
                {
                    animationDefinition.Delay = baseDelay;
                    AnimationManager.ClearAnimationProperties(container);
                    animations.Add(
                        container.AnimateAsync(selectedItemAnimationDefinition));
                }
                else
                {
                    animationDefinition.Delay = baseDelay + (itemDelay * index);
                    AnimationManager.ClearAnimationProperties(container);
                    animations.Add(
                        container.AnimateAsync(animationDefinition));
                }
            }

            animationDefinition.Delay = baseDelay;

            await Task.WhenAll(animations.ToArray());
        }
        public H3DefFileHandler(Stream fileStream)
        {
            this.inputStream = fileStream;
            this.offsets     = new List <List <UInt32> >();

            this.animation = new AnimationDefinition();

            InitializePalete();

            // Read header
            LoadHeader();
        }
    private void MecanimAnimation(AnimationDefinition animDef)
    {
        switch (animDef.RPGAnimationSet)
        {
        case RPGAnimationSet.Core:
            CoreMecanimAnimation(animDef);
            break;

        case RPGAnimationSet.DefaultAttack:
            Animator.SetInteger("weaponType", (int)animDef.RPGAnimationSet);
            Animator.SetInteger("animNumber", animDef.MecanimAnimationNumber);
            Animator.SetBool("falling", false);
            Animator.SetBool("idle", false);
            Animator.SetBool("combatIdle", false);
            Animator.SetBool("jumping", false);
            Animator.SetTrigger("attackTrigger");
            break;

        case RPGAnimationSet.WeaponTypeAttack:
            Animator.SetInteger("weaponType", animDef.WeaponTypeIndex);
            Animator.SetInteger("animNumber", animDef.MecanimAnimationNumber);
            Animator.SetBool("falling", false);
            Animator.SetBool("idle", false);
            Animator.SetBool("combatIdle", false);
            Animator.SetBool("jumping", false);
            Animator.SetTrigger("attackTrigger");
            break;

        case RPGAnimationSet.Skill:
            Animator.SetBool("isCastingAnimation", _controller.IsCastingSkill);
            Animator.SetInteger("skillAnimSet", animDef.MecanimAnimationGroup);
            Animator.SetInteger("animNumber", animDef.MecanimAnimationNumber);
            Animator.SetBool("falling", false);
            Animator.SetBool("idle", false);
            Animator.SetBool("combatIdle", false);
            Animator.SetBool("jumping", false);
            Animator.SetTrigger("skillTrigger");
            break;

        case RPGAnimationSet.Harvesting:
            Animator.SetInteger("animNumber", animDef.MecanimAnimationNumber);
            Animator.SetBool("falling", false);
            Animator.SetBool("idle", false);
            Animator.SetBool("combatIdle", false);
            Animator.SetBool("jumping", false);
            Animator.SetTrigger("harvestTrigger");
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
        public static async Task AnimateItems(
            this Selector itemsControl,
            AnimationDefinition animationDefinition,
            double itemDelay = 0.05,
            object selectedObject = null,
            AnimationDefinition selectedItemAnimationDefinition = null)
        {
            if (itemsControl == null) return;
            if (animationDefinition == null) return;
            if (itemDelay <= 0.0)
                itemDelay = 0.05;

            itemsControl.UpdateLayout();

            var animations = new List<Task>();

            double baseDelay = animationDefinition.Delay;
            for (int index = 0; index < itemsControl.Items.Count; index++)
            {
                var container = (FrameworkElement)itemsControl.ContainerFromItem(itemsControl.Items[index]);
                //var container = (FrameworkElement)itemsControl.ItemContainerGenerator.ContainerFromIndex(index);
                if (container == null) continue;

                bool found = false;
                if (selectedItemAnimationDefinition != null)
                {
                    if ((index == itemsControl.SelectedIndex) ||
                        ((selectedObject != null) && (itemsControl.Items != null) && (selectedObject == itemsControl.Items[index]))
                        )
                    {
                        found = true;

                        animationDefinition.Delay = baseDelay;
                        AnimationManager.ClearAnimationProperties(container);
                        animations.Add(
                            container.AnimateAsync(selectedItemAnimationDefinition));
                    }
                }
                if (!found)
                {
                    animationDefinition.Delay = baseDelay + (itemDelay * index);
                    AnimationManager.ClearAnimationProperties(container);
                    animations.Add(
                        container.AnimateAsync(animationDefinition));
                }
            }

            animationDefinition.Delay = baseDelay;

            await Task.WhenAll(animations.ToArray());
        }
        public static bool NavigateTo(
            this Frame f, 
            Type source, 
            AnimationDefinition closeAnimation,
            AnimationDefinition openAnimation,
            bool sequential)
        {
            var frame = f as AnimationFrame;

            if (frame != null)
                frame.SetNextNavigationAnimation(closeAnimation, openAnimation, sequential);

            return f.Navigate(source);
        }
        public static async Task AnimateItems(
            this Selector selector, 
            AnimationDefinition animationDefinition, 
            double itemDelay = 0.05, 
            AnimationDefinition selectedItemAnimationDefinition = null)
        {
            if (selector == null) return;
            if (animationDefinition == null) return;
            if (itemDelay <= 0.0)
                itemDelay = 0.05;

            selector.UpdateLayout();

            var animations = new List<Task>();

            double baseDelay = animationDefinition.Delay;
            for (int index = 0; index < selector.Items.Count; index++)
            {
                var container = (FrameworkElement)selector.ItemContainerGenerator.ContainerFromIndex(index);
                if (container == null) continue;

                if ((index == selector.SelectedIndex) && (selectedItemAnimationDefinition != null))
                {
                    animationDefinition.Delay = baseDelay;
                    AnimationManager.ClearAnimationProperties(container);
                    animations.Add(
                        container.AnimateAsync(selectedItemAnimationDefinition));
                }
                else
                {
                    animationDefinition.Delay = baseDelay + (itemDelay*index);
                    AnimationManager.ClearAnimationProperties(container);
                    animations.Add(
                        container.AnimateAsync(animationDefinition));
                }
            }

            animationDefinition.Delay = baseDelay;

            await Task.WhenAll(animations.ToArray());
        }
        public static async Task AnimateItems( this ItemsControl itemsControl,  AnimationDefinition animationDefinition,  double itemDelay = 0.05)
        {
            if (itemsControl == null) return;
            if (animationDefinition == null) return;
            if (itemDelay <= 0.0)
                itemDelay = 0.05;

            itemsControl.UpdateLayout();

            var animations = new List<Task>();

            double baseDelay = animationDefinition.Delay;

            for (int index = 0; index < itemsControl.Items.Count; index++)
            {
#if NETFX_CORE || WINDOWS_81_PORTABLE
                var container = (FrameworkElement)itemsControl.ContainerFromIndex(index);
#endif
#if WINDOWS_PHONE
                var container = (FrameworkElement) itemsControl.ItemContainerGenerator.ContainerFromIndex(index);
#endif
                if (container == null) continue;

                animationDefinition.Delay = baseDelay + (itemDelay*index);
                AnimationManager.ClearAnimationProperties(container);
                animations.Add(
                    container.AnimateAsync(animationDefinition));
            }

            animationDefinition.Delay = baseDelay;

            await Task.WhenAll(animations.ToArray());
        }