示例#1
0
        public static void UpdateAnimationChainUi(IAnimationChainAnimatable selectedObject,
                                                  ComboBox currentChainNameComboBox, FileTextBox animationChainFileTextBox)
        {
            #region Update mCurrentChainComboBox items

            if (selectedObject != null && selectedObject.AnimationChains.Count != 0)
            {
                for (int i = 0; i < selectedObject.AnimationChains.Count; i++)
                {
                    if (currentChainNameComboBox.Count <= i || currentChainNameComboBox[i].Text != selectedObject.AnimationChains[i].Name)
                    {
                        currentChainNameComboBox.InsertItem(i, selectedObject.AnimationChains[i].Name, selectedObject.AnimationChains[i]);
                    }
                }

                while (currentChainNameComboBox.Count > selectedObject.AnimationChains.Count)
                {
                    currentChainNameComboBox.RemoveAt(currentChainNameComboBox.Count - 1);
                }
            }
            #endregion

            #region Update the Animation File UI
            if (selectedObject != null && selectedObject.AnimationChains != null && selectedObject.AnimationChains.Name != null)
            {
                if (!animationChainFileTextBox.IsWindowOrChildrenReceivingInput)
                {
                    animationChainFileTextBox.Text = selectedObject.AnimationChains.Name;
                }
            }

            #endregion
        }
        public static bool ContainsChainName(this IAnimationChainAnimatable animatable, string chainName)
        {
            if (animatable == null)
            {
                throw new ArgumentNullException("animatable");
            }

            foreach (var chain in animatable.AnimationChains)
            {
                if (chain.Name == chainName)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        //public void SetSprite(TextureAtlas textureAtlas, Sprite sprite)
        //{
        //    SetSprite("", sprite);

        //    if (!string.IsNullOrEmpty(this.Texture))
        //    {
        //        var entry = textureAtlas.GetEntryFor(this.Texture);

        //        if (entry != null)
        //        {
        //            float left;
        //            float right;
        //            float top;
        //            float bottom;


        //            entry.FullToReduced(sprite.LeftTextureCoordinate, sprite.RightTextureCoordinate,
        //                sprite.TopTextureCoordinate, sprite.BottomTextureCoordinate,
        //                out left, out right, out top, out bottom);

        //            sprite.LeftTextureCoordinate = left;
        //            sprite.RightTextureCoordinate = right;
        //            sprite.TopTextureCoordinate = top;
        //            sprite.BottomTextureCoordinate = bottom;

        //            sprite.Texture = textureAtlas.Texture;

        //        }
        //    }

        //    if (!string.IsNullOrEmpty(this.AnimationChainsFile))
        //    {

        //        if (string.IsNullOrEmpty(this.AnimationChainsFile) == false)
        //        {
        //            //AnimationChains = FlatRedBall.Content.AnimationChain.AnimationChainListSave.FromFile(AnimationChainsFile);
        //            AnimationChainListSave acls = AnimationChainListSave.FromFile(this.AnimationChainsFile);
        //            sprite.AnimationChains = acls.ToAnimationChainList(textureAtlas);
        //        }

        //        if (CurrentChain != -1)
        //        {
        //            // Now using the CurrentChainName property so it works with IAnimationChainAnimatable
        //            sprite.CurrentChainName = sprite.AnimationChains[CurrentChain].Name;
        //            //sprite.SetAnimationChain();
        //        }
        //    }


        //}

        internal static void SetRuntimeAnimationChain(string contentManagerName, IAnimationChainAnimatable sprite,
                                                      AnimationChainList animationChainListInstance, int currentChain, AnimationChainListSave animationChains,
                                                      string animationChainsFile
                                                      )
        {
            if (animationChainListInstance != null)
            {
                if (animationChainListInstance != null)
                {
                    sprite.AnimationChains = animationChainListInstance;;
                }

                if (currentChain != -1)
                {
                    // Now using the CurrentChainName property so it works with IAnimationChainAnimatable
                    sprite.CurrentChainName = sprite.AnimationChains[currentChain].Name;
                    //sprite.SetAnimationChain(sprite.AnimationChains[CurrentChain]);
                }
            }
            else if (animationChains != null || string.IsNullOrEmpty(animationChainsFile) == false)
            {
                if (animationChains != null && animationChains.FileName != null && animationChains.FileName != "")
                {
                    // load the AnimationChainArray here
                    //                    AnimationChains = new AnimationChainList(saveToSetFrom.animationChains.Name);
                    sprite.AnimationChains      = animationChains.ToAnimationChainList(contentManagerName);
                    sprite.AnimationChains.Name = FlatRedBall.IO.FileManager.Standardize(animationChains.FileName);
                }
                else if (string.IsNullOrEmpty(animationChainsFile) == false)
                {
                    //AnimationChains = FlatRedBall.Content.AnimationChain.AnimationChainListSave.FromFile(AnimationChainsFile);
                    sprite.AnimationChains = FlatRedBallServices.Load <AnimationChainList>(
                        animationChainsFile, contentManagerName);
                }

                if (currentChain != -1)
                {
                    // Now using the CurrentChainName property so it works with IAnimationChainAnimatable
                    sprite.CurrentChainName = sprite.AnimationChains[currentChain].Name;
                    //sprite.SetAnimationChain();
                }
            }
        }
示例#4
0
 public AnimationController(IAnimationChainAnimatable animatable)
 {
     Layers.CollectionChanged += CollectionChanged;
     this.AnimatedObject       = animatable;
 }