/// <summary>
        /// Construct self from a model and active animation name.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="animName"></param>
        public ModelAnim(FBXModel model, string animName)
        {
            ActiveAnimation = new AnimatorList(model);
            if (ActiveAnimation.NotEmpty)
            {
                AnimationInstance sample = ActiveAnimation.Sample;
                ActiveController = SimpleController.TryMake(sample, animName, sample.FirstAnimationName);

                if (ActiveController != null)
                {
                    ActiveAnimation.ApplyController(ActiveController);

                    IdleAnimation = new AnimatorList(model);
                    Debug.Assert(IdleAnimation.NotEmpty, "Could make active but not idle?");
                    sample         = IdleAnimation.Sample;
                    IdleController = SimpleController.TryMake(sample, "idle", null);
                    if (IdleController != null)
                    {
                        IdleAnimation.ApplyController(IdleController);
                    }
                    else
                    {
                        IdleAnimation = null;
                    }
                }
                else
                {
                    ActiveAnimation = null;
                }
            }
        }
Exemple #2
0
        public Pacman()
        {
            this.listedKey           = true;
            this.Properties.isRotate = true;
            Image stillImage = ImageLoader.LoadImage(Mariopath + "pacman.png");

            Still.AddFrame(stillImage, "", new SizeF(80f, 52f));
            AnimatorList.Add(Still);
            setAnimation(0);
            this.Properties.Direction          = SpriteProperties.Directions.Left;
            this.Properties.CollisionRect.Size = AnimatorList[0].AnimSize;
            this.Properties.RotateAngle        = 20;
        }
        public override void InitDeviceResources(GraphicsDevice device)
        {
            base.InitDeviceResources(device);
            _animators = new AnimatorList(StaticActor.Model);
            /// All animators in the stack should have the same set of animations.
            AnimationInstance animator = _animators.Sample;

            // TODO (****)  Do we need this check???
            if (animator.HasAnimation("full_running"))
            {
                // Add individual animations to blend controller.
                idleController = SimpleController.TryMake(animator, "full_running");
                SetAnimation(idleController);
            }
        }
Exemple #4
0
 public ClassicChar()
 {
     this.Properties.GravityValue = 0.28f;
     listedKey = true;
     AnimatorList.AddRange(new Core.Animation.Animator[] {
         idle, idleSmallKick, idleNormalKick, idleBigKick, idleSmallPunch, idleNormalPunch, idleBigPunch,
         next, nextSmallKick, nextNormalKick, nextBigKick, nextSmallPunch, nextNormalPunch, nextBigPunch,
         back, backSmallKick, backNormalKick, backBigKick, backSmallPunch, backNormalPunch, backBigPunch,
         crouch, crouchSmallKick, crouchNormalKick, crouchBigKick, crouchSmallPunch, crouchNormalPunch, crouchBigPunch,
         jump, jumpSmallKick, jumpNormalKick, jumpBigKick, jumpSmallPunch, jumpNormalPunch, jumpBigPunch,
         jumpnext, jumpnextSmallKick, jumpnextNormalKick, jumpnextBigKick, jumpnextSmallPunch, jumpnextNormalPunch, jumpnextBigPunch,
         jumpback, jumpbackSmallKick, jumpbackNormalKick, jumpbackBigKick, jumpbackSmallPunch, jumpbackNormalPunch, jumpbackBigPunch,
         jumpProtect, crouchProtect, NormalProtect,
         jumpHit, crouchHit, NormalHit
     });
     this.setAnimation((int)Animations.idle);
     this.Properties.CollisionRect.Size = this.currentAnimator.AnimSize;
 }
Exemple #5
0
        public RotatingBlock()
        {
            this.Properties.isTile = true;
            Image[] image = new Image[] { ImageLoader.LoadImage(Itempath + "Rotating_Block_Hit_1.png"),
                                          ImageLoader.LoadImage(Itempath + "Rotating_Block_Hit_2.png"),
                                          ImageLoader.LoadImage(Itempath + "Rotating_Block_Hit_3.png") };
            for (int i = 0; i < image.Length; i++)
            {
                animator.AddFrame(image[i], @"", new SizeF(32, 32));
            }
            Image stillImage = ImageLoader.LoadImage(Itempath + "Rotating_Block_Still.png");

            stillanimator.AddFrame(stillImage, @"", new SizeF(32, 32));
            AnimatorList.Add(stillanimator);
            animator.RePlay += new MethodInvoker(animFinish);
            AnimatorList.Add(animator);
            setAnimation(0);
            this.Properties.CollisionRect.Size = AnimatorList[0].AnimSize;
        }
        /// <summary>
        /// Load up our animations and bind to the given model.
        /// </summary>
        /// <param name="sro"></param>
        private void LoadAnimations(FBXModel sro)
        {
            Debug.Assert(SharedAnim != null, "Must set SharedAnim to class's shared animation in constructor.");
            if (SharedAnim.ActiveAnimator == null)
            {
                SharedAnim.ActiveAnimator = new AnimatorList(sro);
            }
            _animators = SharedAnim.ActiveAnimator;
            AnimatorList      animList = SharedAnim.ActiveAnimator;
            AnimationInstance animator = animList.Sample;

            if (animator != null && animator.HasAnimation(SharedAnim.ActiveName))
            {
                if (SharedAnim.ActiveController == null)
                {
                    SharedAnim.ActiveController = SimpleController.TryMake(animator, SharedAnim.ActiveName);
                    AnimActive();
                }
            }
            else
            {
                animList.ApplyController(null);
            }
            if (SharedAnim.IdleAnimator == null)
            {
                SharedAnim.IdleAnimator = new AnimatorList(sro);
                AnimationInstance sharedIdle = SharedAnim.IdleAnimator.Sample;
                if ((sharedIdle != null) && sharedIdle.HasAnimation(SharedAnim.IdleName))
                {
                    SharedAnim.IdleController = SimpleController.TryMake(
                        sharedIdle,
                        SharedAnim.IdleName);
                }
                if (SharedAnim.IdleController != null)
                {
                    AnimIdle();
                }
                else
                {
                    SharedAnim.IdleAnimator = null;
                }
            }
        }
        public QuestionBlock()
        {
            this.Properties.isTile = true;
            Image[] image = new Image[] { ImageLoader.LoadImage(Itempath + "Question_Block_0.png"),
                                          ImageLoader.LoadImage(Itempath + "Question_Block_1.png"),
                                          ImageLoader.LoadImage(Itempath + "Question_Block_2.png"),
                                          ImageLoader.LoadImage(Itempath + "Question_Block_3.png") };
            for (int i = 0; i < image.Length; i++)
            {
                animator.AddFrame(image[i], @"", new SizeF(32, 32));
            }
            Image deadImage = ImageLoader.LoadImage(Itempath + "Question_Block_Dead.png");

            diedanimator.AddFrame(deadImage, @"", new SizeF(32, 32));
            AnimatorList.Add(animator);
            AnimatorList.Add(diedanimator);
            setAnimation(0);
            this.Properties.CollisionRect.Size = AnimatorList[0].AnimSize;
        }
Exemple #8
0
        public Mario()
        {
            this.listedKey = true;
            this.Properties.GravityValue = .28f;
            Image crouchImage = ImageLoader.LoadImage(Mariopath + "Mario_Big_Crouch.png");
            Image stillImage  = ImageLoader.LoadImage(Mariopath + "Mario_Big_Still.png");
            Image step1Image  = ImageLoader.LoadImage(Mariopath + "Mario_Big_Step1.png");
            Image step2Image  = ImageLoader.LoadImage(Mariopath + "Mario_Big_Step2.png");
            Image jumpImage   = ImageLoader.LoadImage(Mariopath + "Mario_Big_Jump.png");
            Image run1Image   = ImageLoader.LoadImage(Mariopath + "Mario_Big_Run1.png");
            Image run2Image   = ImageLoader.LoadImage(Mariopath + "Mario_Big_Run2.png");
            Image slopeImage  = ImageLoader.LoadImage(Mariopath + "Mario_Slope.png");

            Crouchanim.AddFrame(crouchImage, "", new SizeF(24, 32));
            Stillanim.AddFrame(stillImage, "", new SizeF(32, 52));
            Stepanim.AddFrame(step1Image, @"", new SizeF(32, 52));
            Stepanim.AddFrame(step2Image, @"", new SizeF(32, 52));
            Jumpanim.AddFrame(jumpImage, @"", new SizeF(32, 52));
            Runanim.AddFrame(run1Image, @"", new SizeF(38, 52));
            Runanim.AddFrame(run2Image, @"", new SizeF(38, 52));
            Slopeanim.AddFrame(slopeImage, @"", new SizeF(32, 52));

            AnimatorList.Add(Stillanim);
            AnimatorList.Add(Stepanim);
            AnimatorList.Add(Crouchanim);
            AnimatorList.Add(Jumpanim);
            AnimatorList.Add(Runanim);
            AnimatorList.Add(Slopeanim);
            crouchImage.Dispose();
            stillImage.Dispose();
            step1Image.Dispose();
            step2Image.Dispose();
            jumpImage.Dispose();
            run1Image.Dispose();
            run2Image.Dispose();
            slopeImage.Dispose();
            setAnimation(0);
            this.Properties.Direction          = SpriteProperties.Directions.Left;
            this.Properties.CollisionRect.Size = AnimatorList[0].AnimSize;
        }