Esempio n. 1
0
        public static MGAnimation animationWithFrames(List<MGSpriteFrame> frames)
        {
            MGAnimation pAnimation = new MGAnimation();
            pAnimation.initWithFrames(frames);

            return pAnimation;
        }
Esempio n. 2
0
 public static MGAnimate ActionWithAnimation(MGAnimation anim, bool restoreOriginalFrame)
 {
     return new MGAnimate
                {
                    Anim = anim,
                    _duration = anim.Duration,
                    AnimName = anim.Name,
                    RestoreOriginalFrame = restoreOriginalFrame
                };
 }
Esempio n. 3
0
 public PartInstance(MGNode parent, Part part)
 {
     _part = part;
     StateIdx = -1;
     _frame = 0;
     _time = 0f;
     _preFrameTime = 0f;
     _timeInterval = 0f;
     if (_part.Type == Part.PartType.PartTypeImage)
     {
         _node = new MGSprite(part.Images[0].uniqueID);
         parent.AddChild(_node, part.ZAxis);
         if (part.Images.Count > 1)
         {
             var animation = new MGAnimation("P", 0.5f);
             for (int i = 0; i < part.Images.Count; i++)
             {
                 animation.AddFS(part.Images[i].uniqueID);
             }
             ((MGSprite)_node).AddAnimation(animation);
             return;
         }
     }
     else
     {
         if (_part.Type == Part.PartType.PartTypeButton)
         {
             if (part.Images.Count > 1)
             {
                 _node = MGButton.ButtonWithTextureTwinkle(part.Images[0].uniqueID, part.Images[1].uniqueID);
             }
             else
             {
                 _node = MGButton.ButtonWithToggleTwinkle(part.Images[0].uniqueID);
             }
             if ((_node).Width <= 30f || (_node).Height <= 30f)
             {
                 ((MGUIBase)_node).Bold = 10f;
             }
             parent.AddChild(_node, part.ZAxis);
             return;
         }
         if (_part.Type == Part.PartType.PartTypeCheckBox)
         {
             FrameStruct frameStruct = FrameStruct.FrameStructWithImage(part.Images[0]);
             if (part.Images.Count > 1)
             {
                 _node = MGButton.CheckboxWithTexture(part.Images[0].uniqueID, part.Images[1].uniqueID);
                 parent.AddChild(_node, part.ZAxis);
             }
             if (frameStruct.Width <= 30f || frameStruct.Height <= 30f)
             {
                 ((MGUIBase)_node).Bold = 10f;
                 return;
             }
         }
         else
         {
             if (_part.Type == Part.PartType.PartTypeProgressBar)
             {
                 _node = new MGProgressBar(part.Images[0].uniqueID);
                 string[] array = _part.UniqueID.Split(new[]
                                                           {
                                                               '_'
                                                           });
                 if (array[1] == "L")
                 {
                     ((MGProgressBar)_node).SetType(MGProgressBar.BarType.ProgressBarLeft);
                 }
                 else
                 {
                     ((MGProgressBar)_node).SetType(MGProgressBar.BarType.ProgressBarRight);
                 }
                 ((MGProgressBar)_node).Percent = 0.5;
                 parent.AddChild(_node, part.ZAxis);
                 return;
             }
             if (_part.Type == Part.PartType.PartTypeLabelAtlas)
             {
                 string[] array2 = _part.UniqueID.Split(new[]
                                                            {
                                                                '_'
                                                            });
                 MGLabelAtlas.LabelType type;
                 if (array2[3] == "L")
                 {
                     type = MGLabelAtlas.LabelType.TextAlignmentLeft;
                 }
                 else
                 {
                     if (array2[3] == "C")
                     {
                         type = MGLabelAtlas.LabelType.TextAlignmentCenter;
                     }
                     else
                     {
                         type = MGLabelAtlas.LabelType.TextAlignmentRight;
                     }
                 }
                 int charWidth = Convert.ToInt32(array2[1]);
                 int num = Convert.ToInt32(array2[2]);
                 FrameStruct frameStruct2 = FrameStruct.FrameStructWithImage(part.Images[0]);
                 var itemWidth = (int)(frameStruct2.Width / num);
                 var itemHeight = (int)frameStruct2.Height;
                 _node = new MGLabelAtlas(part.Images[0].uniqueID, type, "000", '0', itemWidth, itemHeight,
                                          charWidth);
                 parent.AddChild(_node, part.ZAxis);
                 return;
             }
             if (_part.Type == Part.PartType.PartTypeLabel)
             {
                 string[] array3 = _part.UniqueID.Split(new[]
                                                            {
                                                                '_'
                                                            });
                 MGLabel.LabelType type2;
                 if (array3[5] == "L")
                 {
                     type2 = MGLabel.LabelType.TextAlignmentLeft;
                 }
                 else
                 {
                     if (array3[5] == "C")
                     {
                         type2 = MGLabel.LabelType.TextAlignmentCenter;
                     }
                     else
                     {
                         type2 = MGLabel.LabelType.TextAlignmentRight;
                     }
                 }
                 Convert.ToInt32(array3[4]);
                 Convert.ToInt32(array3[3]);
                 Convert.ToInt32(array3[2]);
                 string arg_44B_0 = array3[1];
                 _node = new MGLabel(part.Content, type2,
                                     MGDirector.SharedDirector().Content.Load<SpriteFont>("SpriteFont1"));
                 parent.AddChild(_node, part.ZAxis);
             }
         }
     }
 }
Esempio n. 4
0
 public void InitCheckboxWithPrssingTexture(string fsName1, string fsName2, string fsName3, string fsName4)
 {
     if (fsName3 == "" && fsName4 == "")
     {
         var sprite = new MGSprite(fsName1);
         var sprite2 = new MGSprite(fsName2);
         sprite2.Visible = false;
         base.AddChild(sprite, 0);
         base.AddChild(sprite2, 0);
         ButtonElement.Add("ImageOn", sprite);
         ButtonElement.Add("ImageOff", sprite2);
         Width = sprite.Width;
         Height = sprite.Height;
         base.Anchor = new Vector2(Width / 2f, Height / 2f);
         MGAction cDEAction = MGSequence.Actions(new MGAction[]
                                                     {
                                                         new MGToggleVisibility()
                                                     });
         cDEAction.AssignTarget(sprite);
         TouchClickedAction.Add("ImageOn", cDEAction);
         MGAction cDEAction2 = MGSequence.Actions(new MGAction[]
                                                      {
                                                          new MGToggleVisibility()
                                                      });
         cDEAction2.AssignTarget(sprite2);
         TouchClickedAction.Add("ImageOff", cDEAction2);
         return;
     }
     var anim = new MGAnimation("Frame", 0.1f, new[]
                                                   {
                                                       fsName1,
                                                       fsName3
                                                   });
     var anim2 = new MGAnimation("Frame", 0.1f, new[]
                                                    {
                                                        fsName2,
                                                        fsName4
                                                    });
     var cDESprite3 = new MGSprite();
     var cDESprite4 = new MGSprite();
     cDESprite3.AddAnimation(anim);
     cDESprite4.AddAnimation(anim2);
     cDESprite3.SetFrame("Frame", 0);
     cDESprite4.SetFrame("Frame", 0);
     base.AddChild(cDESprite3, 0);
     base.AddChild(cDESprite4, 0);
     cDESprite4.Visible = false;
     ButtonElement.Add("ImageOn", cDESprite3);
     ButtonElement.Add("ImageOff", cDESprite4);
     Width = cDESprite3.Width;
     Height = cDESprite3.Height;
     base.Anchor = new Vector2(Width / 2f, Height / 2f);
     MGAction cDEAction3 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 1)
                                                  });
     cDEAction3.AssignTarget(cDESprite3);
     MGAction cDEAction4 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 0)
                                                  });
     cDEAction4.AssignTarget(cDESprite3);
     MGAction cDEAction5 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      new MGToggleVisibility(),
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 0)
                                                  });
     cDEAction5.AssignTarget(cDESprite3);
     TouchBeganAction.Add("ImageOn", cDEAction3);
     TouchMoveOutAction.Add("ImageOn", cDEAction4);
     TouchClickedAction.Add("ImageOn", cDEAction5);
     MGAction cDEAction6 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 1)
                                                  });
     cDEAction6.AssignTarget(cDESprite4);
     MGAction cDEAction7 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 0)
                                                  });
     cDEAction7.AssignTarget(cDESprite4);
     MGAction cDEAction8 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      new MGToggleVisibility(),
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 0)
                                                  });
     cDEAction8.AssignTarget(cDESprite4);
     TouchBeganAction.Add("ImageOff", cDEAction6);
     TouchMoveOutAction.Add("ImageOff", cDEAction7);
     TouchClickedAction.Add("ImageOff", cDEAction8);
 }
Esempio n. 5
0
 public void InitButtonWithTextureTwinkle(string fsName1, string fsName2)
 {
     FS = DataManager.GetFS(fsName1);
     var anim = new MGAnimation("Frame", 0.1f, new[]
                                                   {
                                                       fsName1,
                                                       fsName2
                                                   });
     var sprite = new MGSprite();
     sprite.AddAnimation(anim);
     sprite.SetFrame("Frame", 0);
     ButtonElement.Add("Image", sprite);
     base.AddChild(sprite, 0);
     Width = sprite.Width;
     Height = sprite.Height;
     base.Anchor = new Vector2(Width / 2f, Height / 2f);
     MGAction action = MGSequence.Actions(new MGAction[]
                                                 {
                                                     MGFrameAction.ActionWithAnimationIndex("Frame", 1)
                                                 });
     action.AssignTarget(sprite);
     MGAction action2 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 0)
                                                  });
     action2.AssignTarget(sprite);
     MGAction action3 = MGSequence.Actions(new MGAction[]
                                                  {
                                                      MGRepeat.Actions(MGAnimate.ActionWithAnimation(anim), 1),
                                                      MGFrameAction.ActionWithAnimationIndex("Frame", 0)
                                                  });
     action3.AssignTarget(sprite);
     TouchBeganAction.Add("Image", action);
     TouchMoveOutAction.Add("Image", action2);
     TouchClickedAction.Add("Image", action3);
 }
Esempio n. 6
0
        private AnimationMgr()
        {
            _num1001Zombie = new List<MGAnimation>();
            _num4001Zombie = new List<MGAnimation>();
            _num3001Zombie = new List<MGAnimation>();
            _num2001Zombie = new List<MGAnimation>();
            _num5001Zombie = new List<MGAnimation>();
            _num6001Zombie = new List<MGAnimation>();

            List<MGSpriteFrame> frames = new List<MGSpriteFrame>();
            var cache = MGSpriteFrameCache.SharedSpriteFrameCache();
            frames.Clear();
            for (int i = 0; i < 10; i++)
            {
                frames.Add(cache.SpriteFrameByName("1001" + i + ".png"));
            }
            var stand1 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            for (int i = 10; i < 26; i++)
            {
                frames.Add(cache.SpriteFrameByName("1001" + i + ".png"));
            }
            var run1 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            for (int i = 26; i < 34; i++)
            {
                frames.Add(cache.SpriteFrameByName("1001" + i + ".png"));
            }
            var die1 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dj1.png"));
            frames.Add(cache.SpriteFrameByName("dj2.png"));
            var dj1 = MGAnimation.animationWithFrames(frames, .1f);
            _num1001Zombie.Add(run1);
            _num1001Zombie.Add(stand1);
            _num1001Zombie.Add(die1);
            _num1001Zombie.Add(dj1);

            frames.Clear();
            for (int i = 0; i < 12; i++)
            {
                frames.Add(cache.SpriteFrameByName("4001" + i + ".png"));
            }
            var stand4 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            for (int i = 12; i < 17; i++)
            {
                frames.Add(cache.SpriteFrameByName("4001" + i + ".png"));
            }
            var run4 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            for (int i = 17; i < 22; i++)
            {
                frames.Add(cache.SpriteFrameByName("4001" + i + ".png"));
            }
            var die4 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dj5.png"));
            frames.Add(cache.SpriteFrameByName("dj6.png"));
            var dj4 = MGAnimation.animationWithFrames(frames, .1f);
            _num4001Zombie.Add(run4);
            _num4001Zombie.Add(stand4);
            _num4001Zombie.Add(die4);
            _num4001Zombie.Add(dj4);

            frames.Clear();
            for (int i = 0; i < 9; i++)
            {
                frames.Add(cache.SpriteFrameByName("2001" + i + ".png"));
            }
            var stand2 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            for (int i = 9; i < 15; i++)
            {
                frames.Add(cache.SpriteFrameByName("2001" + i + ".png"));
            }
            var run2 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            for (int i = 16; i < 21; i++)
            {
                frames.Add(cache.SpriteFrameByName("2001" + i + ".png"));
            }
            var die2 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dj3.png"));
            frames.Add(cache.SpriteFrameByName("dj4.png"));
            var dj2 = MGAnimation.animationWithFrames(frames, .1f);
            _num2001Zombie.Add(run2);
            _num2001Zombie.Add(stand2);
            _num2001Zombie.Add(die2);
            _num2001Zombie.Add(dj2);

            frames.Clear();
            for (int i = 0; i < 9; i++)
            {
                frames.Add(cache.SpriteFrameByName("3001" + i + ".png"));
            }
            var stand3 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            for (int i = 9; i < 20; i++)
            {
                frames.Add(cache.SpriteFrameByName("3001" + i + ".png"));
            }
            var run3 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            for (int i = 20; i < 26; i++)
            {
                frames.Add(cache.SpriteFrameByName("3001" + i + ".png"));
            }
            var die3 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dj7.png"));
            frames.Add(cache.SpriteFrameByName("dj8.png"));
            var dj3 = MGAnimation.animationWithFrames(frames, .1f);

            _num3001Zombie.Add(run3);
            _num3001Zombie.Add(stand3);
            _num3001Zombie.Add(die3);
            _num3001Zombie.Add(dj3);

            frames.Clear();
            for (int i = 0; i < 4; i++)
            {
                frames.Add(cache.SpriteFrameByName("5001" + i + ".png"));
            }
            var run5 = MGAnimation.animationWithFrames(frames, .2f);
            frames.Clear();
            for (int i = 4; i < 9; i++)
            {
                frames.Add(cache.SpriteFrameByName("5001" + i + ".png"));
            }
            var die5 = MGAnimation.animationWithFrames(frames, .2f);
            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dj9.png"));
            frames.Add(cache.SpriteFrameByName("dj10.png"));
            var dj5 = MGAnimation.animationWithFrames(frames, .1f);
            _num5001Zombie.Add(run5);
            _num5001Zombie.Add(dj5);
            _num5001Zombie.Add(die5);

            frames.Clear();
            for (int i = 0; i < 9; i++)
            {
                frames.Add(cache.SpriteFrameByName("6001" + i + ".png"));
            }
            var stand6 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            for (int i = 9; i < 20; i++)
            {
                frames.Add(cache.SpriteFrameByName("6001" + i + ".png"));
            }
            var run6 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            for (int i = 20; i < 26; i++)
            {
                frames.Add(cache.SpriteFrameByName("6001" + i + ".png"));
            }
            var die6 = MGAnimation.animationWithFrames(frames, .1f);
            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dj11.png"));
            frames.Add(cache.SpriteFrameByName("dj12.png"));
            var dj6 = MGAnimation.animationWithFrames(frames, .1f);
            _num6001Zombie.Add(run6);
            _num6001Zombie.Add(stand6);
            _num6001Zombie.Add(die6);
            _num6001Zombie.Add(dj6);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("sd1.png"));
            frames.Add(cache.SpriteFrameByName("sd2.png"));
            _electric = MGAnimation.animationWithFrames(frames, .2f);
            frames.Clear();
            frames.Add(cache.SpriteFrameByName("sd3.png"));
            frames.Add(cache.SpriteFrameByName("sd4.png"));
            _electric2 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("201.png"));
            frames.Add(cache.SpriteFrameByName("202.png"));
            frames.Add(cache.SpriteFrameByName("203.png"));
            _rocket = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("dbing1.png"));
            frames.Add(cache.SpriteFrameByName("dbing2.png"));
            frames.Add(cache.SpriteFrameByName("dbing3.png"));
            frames.Add(cache.SpriteFrameByName("dbing4.png"));
            frames.Add(cache.SpriteFrameByName("dbing5.png"));
            frames.Add(cache.SpriteFrameByName("dbing6.png"));
            _ice = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("xb1.png"));
            frames.Add(cache.SpriteFrameByName("xb2.png"));
            frames.Add(cache.SpriteFrameByName("xb3.png"));
            frames.Add(cache.SpriteFrameByName("xb4.png"));
            frames.Add(cache.SpriteFrameByName("xb5.png"));
            _ice2 = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            for (int i = 1; i < 8; i++)
            {
                frames.Add(cache.SpriteFrameByName("sample" + i + ".png"));
            }
            _bomb = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
            frames.Add(cache.SpriteFrameByName("sk1.png"));
            frames.Add(cache.SpriteFrameByName("sk2.png"));
            frames.Add(cache.SpriteFrameByName("sk3.png"));
            frames.Add(cache.SpriteFrameByName("sk4.png"));
            frames.Add(cache.SpriteFrameByName("sk5.png"));
            _bomb2 = MGAnimation.animationWithFrames(frames, .1f);

            frames.Clear();
            for (int i = 1; i < 5; i++)
            {
                frames.Add(cache.SpriteFrameByName("Cloud_white_0" + i + ".png"));
            }
            _cloud = MGAnimation.animationWithFrames(frames, .2f);

            frames.Clear();
        }