/// <summary>
        /// Constructor.
        /// </summary>
        public VisualCharacter(Game game, Player player)
        {
            // Assign refrences //
            _player = player;

            // Initialize Members //
            CharacterAnimator = new Animator(game);

            // Load animations //
            CharacterAnimator.AddAnimation(
                @"Content\AnimatedSprites\Player\Dude_Idle_Data.xml",
                @"AnimatedSprites\Player\Dude_Idle_Sprite",
                Animator.Animations.Idle);

            CharacterAnimator.AddAnimation(
                @"Content\AnimatedSprites\Player\Dude_Run_Data.xml",
                @"AnimatedSprites\Player\Dude_Run_Sprite",
                Animator.Animations.Run);

            CharacterAnimator.AddAnimation(
                @"Content\AnimatedSprites\Player\Dude_Attack_Data.xml",
                @"AnimatedSprites\Player\Dude_Attack_Sprite",
                Animator.Animations.Attack);

            CharacterAnimator.SetAnimationSpeed(15);
        }
Beispiel #2
0
        internal virtual void StartAnims(Animator animator)
        {
            Animation animPos = CreateAnimPosition(animator);

            animPos.Start();
            animator.AddAnimation(animPos);

            Animation animAlpha = CreateAnimAlpha(animator);

            animAlpha.Start();
            animator.AddAnimation(animAlpha);

            if (DrawableTex.Angle != ParticleAngle)
            {
                Animation animAngle = CreateAnimAngle(animator);
                animAngle.Start();
                animator.AddAnimation(animAngle);
            }

            if (DrawableTex.Scale != ParticleScale)
            {
                Animation animScale = CreateAnimScale(animator);
                animScale.Start();
                animator.AddAnimation(animScale);
            }
        }
Beispiel #3
0
 private void AnimatorSettings()
 {
     _animator = new Animator(SceneObject as AnimatedSceneObject);
     _animator.AddAnimation(Idle, AnimationManager.Instance.GetAnimationByName(Idle));
     _animator.AddAnimation(Walk, AnimationManager.Instance.GetAnimationByName(Walk));
     _animator.AddAnimation(JumpUp, AnimationManager.Instance.GetAnimationByName(JumpUp));
     _animator.AddAnimation(JumpDown, AnimationManager.Instance.GetAnimationByName(JumpDown));
     _animator.AddRelation(JumpUp, JumpDown);
     _animator.AddRelation(JumpDown, Idle);
 }
Beispiel #4
0
        public override void Initialize(GameObject owner)
        {
            base.Initialize(owner);
            transform = (Transform)GetComponent <Transform>();
            renderer  = (SpriteRenderer)GetComponent <SpriteRenderer>();
            animator  = (Animator)AddComponent <Animator>();

            Animation idle    = new Animation(0, 0, 0);
            Animation hovered = new Animation(0, 0, 1);
            Animation clicked = new Animation(0, 0, 2);

            animator.AddAnimation("Idle", idle);
            animator.AddAnimation("Hovered", hovered);
            animator.AddAnimation("Clicked", clicked);
        }
Beispiel #5
0
        public void AddAnimation(string name, int[] framesArray = null, bool isLoop = true, float frameDuration = 0.25f)
        {
            if (Animator == null)
            {
                Animator = new Animator(this);
            }

            Animator.AddAnimation(new Animation(name, framesArray, isLoop, frameDuration));
        }
Beispiel #6
0
        public Player(Texture2D texture, Vector2 position, Map map, ContentManager contentManager, ScreenManager screenManager, float rotation = 0, Rectangle source = default(Rectangle))
            : base(texture, 32, 32, position, rotation, source)
        {
            this.map           = map;
            this.ScreenManager = screenManager;

            animator = new Animator(32, 32);
            animator.AddAnimation(new Animation(0, 1, 0));   //Idle
            animator.AddAnimation(new Animation(1, 3, 100)); //Running

            playerController = new PlayerController(this);
            playerController.OnControlChanged += ChangeControl;

            WeaponManager = new WeaponManager(this, contentManager);
            var bulletTexture = contentManager.Load <Texture2D>("Sprites/bullet");

            WeaponManager.AddWeapon(new Pistol(bulletTexture, contentManager.Load <Texture2D>("Sprites/pistol"), base.position + Forward));
            WeaponManager.AddWeapon(new AssaultRifle(bulletTexture, contentManager.Load <Texture2D>("Sprites/rifle"), base.position + Forward));
        }
        protected override void OnInitialize(object enterInformation)
        {
            _iconSprite = new Sprite(Game.Content.Load <Texture2D>(ResourceNames.Textures.MonoGameLogo))
            {
                Position = new Vector2(Game.ScreenWidth * 0.5f, Game.ScreenHeight * 0.5f),
                Alpha    = 0.0f
            };

            _iconAnimator = new Animator();
            _iconAnimator.AddAnimation("BlendIn", new DeltaAnimation(1.0f, AnimateBlendIn, false));
            _iconAnimator.AnimationFinished += (s, b) => Game.AddDelayedAction(OnStartTransition, 1.0f);
        }
Beispiel #8
0
        protected override void OnEntered(object enterInformation)
        {
            Game.Cursor.IsActive    = false;
            _gameSession            = (GameSession)enterInformation;
            _stateChangeInformation = StateChangeInformation.Empty;

            //todo: reactivate 3d
            //var rendererType = Settings.Default.GameMode == "3D" ? GameRendererType.ThreeDe : GameRendererType.TwoDe;
            _gameRenderer = GameRendererFactory.CreateGameRenderer(GameRendererType.TwoDe, Game, _gameSession.CurrentLevel);

            _finishSlideAnimator = new Animator();
            _finishSlideAnimator.AddAnimation("RotateText", new DeltaAnimation(1.0f, RotateAndSetAlphaText, false));
            _finishSlideAnimator.AddAnimation("Wait", new WaitAnimation(1.5f));
            _finishSlideAnimator.AddTransition("RotateText", "Wait");
            _finishSlideAnimator.AnimationFinished += OnFinishSlideFinished;

            _finishedSprite = new Sprite(Game.Content.Load <Texture2D>("textures/headings"))
            {
                Position = new Vector2(Game.ScreenWidth * 0.5f, Game.ScreenHeight * 0.5f),
                Alpha    = 0.0f
            };
        }
Beispiel #9
0
        private void AddFrames()
        {
            int total = 0;

            foreach (Animation anim in _animationList)
            {
                FrameAnimation <Sprite> temp = new FrameAnimation <Sprite>();
                for (int i = 0; i < anim.Frames; i++, total++)
                {
                    int tu = (int)((total % (_tSize.X / _size.Y)) * _size.X);
                    int tv = (int)((total / (_tSize.Y / _size.Y)) * _size.Y);
                    temp.AddFrame(1, new IntRect(tu, tv, (int)_size.X, (int)_size.Y));
                }
                _animator.AddAnimation(anim.Name, temp, Time.FromSeconds(0.5f));
            }
        }
Beispiel #10
0
        public XFScrollViewSamplePage()
        {
            InitializeComponent();

            var animatedView = new AnimatedView();

            animatedView.BackgroundColor = Color.Black;
            animatedView.WidthRequest    = 50;
            animatedView.HeightRequest   = 50;

            var scrollView = new AnimatedScrollView();

            scrollView.NumberOfPage = 2;
            scrollView.Content      = new StackLayout
            {
                Children =
                {
                    animatedView
                }
            };

            //Animations
            //var alphaAnimation = new CrossScrollViewAnimations();
            //Animator.Add
            var alphaAnimation = CrossScrollViewAnimations.Current.AlphaAnimation(animatedView, 1);
            var animator       = new Animator();

            animator.AddAnimation(alphaAnimation);

            alphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(1),
                Alpha = 0.0f
            });
            alphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(2),
                Alpha = 1.0f
            });
        }
Beispiel #11
0
 protected TAnimation AddAnimation <TAnimation>(string name, TAnimation animation) where TAnimation : UiAnimation
 {
     animation.Owner = this;
     _animator.AddAnimation(name, animation);
     return(animation);
 }
Beispiel #12
0
        /// <summary>
        /// Creates a new instance of the Enemy class.
        /// </summary>
        public Enemy()
        {
            //Transform.Scale = Vector2.One * 0.5f;
            Name      = "Enemy";
            Tag       = Tag.Enemy;
            MaxHealth = 100;
            Health    = MaxHealth;
            Texture2D spriteSheet = ContentManager.GetTexture("EnemySprites");

            Vector2 origin = new Vector2(55, 0);

            Sprite[] spriteWalk   = Sprite.Slice(spriteSheet, new Rectangle(0, 0, 110, 115), new Point(8, 1), origin);
            Sprite[] spriteAttack = Sprite.Slice(spriteSheet, new Rectangle(0, 115, 110, 115), new Point(7, 1), origin);

            Animation attackAnimation = new Animation(spriteAttack, 1000 / 12)
            {
                Loop = false
            };

            attackAnimation.GetFrame(spriteAttack.Length - 1).Duration = 200;

            Animator animator = new Animator();

            animator.AddAnimation("walk", new Animation(spriteWalk, 1000 / 10));
            animator.AddAnimation("attack", attackAnimation);

            EnemyMovement movement = AddComponent <EnemyMovement>();

            AddComponent(animator);
            AddComponent(new Collider(new Vector2(40, 50))
            {
                Name = "Collider", Offset = new Vector2(36, 62) - origin
            });
            AddComponent(new Collider(new Vector2(53, 20))
            {
                Name = "AttackLeft", Offset = new Vector2(2, 62) - origin, IsTrigger = true, Enabled = false
            }).OnTriggerEnter += movement.OnHit;
            AddComponent(new Collider(new Vector2(53, 20))
            {
                Name = "AttackRight", Offset = new Vector2(55, 62) - origin, IsTrigger = true, Enabled = false
            }).OnTriggerEnter += movement.OnHit;
            AddComponent(new Collider(new Vector2(106, 20))
            {
                Name = "AttackRange", Offset = new Vector2(2, 62) - origin, IsTrigger = true, Enabled = false
            }).OnTrigger += movement.OnPlayerInAttackRange;
            Collider rangeTrigger = AddComponent(new Collider(new Vector2(700, 50))
            {
                Name = "AggroRange", Offset = new Vector2(-300, 62) - origin, IsTrigger = true
            });

            rangeTrigger.OnTriggerEnter += movement.OnPlayerInSight;
            rangeTrigger.OnTriggerExit  += movement.OnPlayerOutOfSight;

            AddComponent(new SpriteRenderer());
            AddComponent(new RigidBody {
                Name = "EnemyRb", Mass = 109.6f, Power = 9000 ^ 9000
            });

            attackAnimation.GetFrame(4).Event += () =>
            {
                if (GetComponent <SpriteRenderer>().SpriteEffect == SpriteEffects.FlipHorizontally)
                {
                    GetComponent("AttackLeft").Enabled = true;
                }
                else
                {
                    GetComponent("AttackRight").Enabled = true;
                }
            };
            attackAnimation.GetFrame(5).Event += () =>
            {
                if (GetComponent <SpriteRenderer>().SpriteEffect == SpriteEffects.FlipHorizontally)
                {
                    GetComponent("AttackLeft").Enabled = false;
                }
                else
                {
                    GetComponent("AttackRight").Enabled = false;
                }
            };
        }
Beispiel #13
0
        protected override void AddAnimations()
        {
            if (PlayerAnimations == null)
            {
                PlayerAnimations = new Dictionary <string, string[]>
                {
                    {
                        "attack1",
                        new string[]
                        {
                            "adventurer-attack1-00.png",
                            "adventurer-attack1-01.png",
                            "adventurer-attack1-02.png",
                            "adventurer-attack1-03.png",
                            "adventurer-attack1-04.png",
                        }
                    },
                    {
                        "attack2",
                        new string[]
                        {
                            "adventurer-attack2-00.png",
                            "adventurer-attack2-01.png",
                            "adventurer-attack2-02.png",
                            "adventurer-attack2-03.png",
                            "adventurer-attack2-04.png",
                            "adventurer-attack2-05.png",
                        }
                    },
                    {
                        "attack3",
                        new string[]
                        {
                            "adventurer-attack3-00.png",
                            "adventurer-attack3-01.png",
                            "adventurer-attack3-02.png",
                            "adventurer-attack3-03.png",
                            "adventurer-attack3-04.png",
                            "adventurer-attack3-05.png",
                        }
                    },
                    {
                        "air-attack1",
                        new string[]
                        {
                            "adventurer-air-attack1-00.png",
                            "adventurer-air-attack1-01.png",
                            "adventurer-air-attack1-02.png",
                            "adventurer-air-attack1-03.png",
                        }
                    },
                    {
                        "air-attack2",
                        new string[]
                        {
                            "adventurer-air-attack2-00.png",
                            "adventurer-air-attack2-01.png",
                            "adventurer-air-attack2-02.png",
                        }
                    },
                    {
                        "air-attack3-end",
                        new string[]
                        {
                            "adventurer-air-attack3-end-00.png",
                            "adventurer-air-attack3-end-01.png",
                            "adventurer-air-attack3-end-02.png",
                        }
                    },
                    {
                        "air-attack3-loop",
                        new string[]
                        {
                            "adventurer-air-attack3-loop-00.png",
                            "adventurer-air-attack3-loop-01.png",
                        }
                    },
                    {
                        "air-attack3-rdy",
                        new string[]
                        {
                            "adventurer-air-attack3-rdy-00.png",
                        }
                    },
                    {
                        "die",
                        new string[]
                        {
                            "adventurer-die-00.png",
                            "adventurer-die-01.png",
                            "adventurer-die-02.png",
                            "adventurer-die-03.png",
                            "adventurer-die-04.png",
                            "adventurer-die-05.png",
                            "adventurer-die-06.png",
                        }
                    },
                    {
                        "fall",
                        new string[]
                        {
                            "adventurer-fall-00.png",
                            "adventurer-fall-01.png",
                        }
                    },
                    {
                        "idle",
                        new string[]
                        {
                            "adventurer-idle-00.png",
                            "adventurer-idle-01.png",
                            "adventurer-idle-02.png",
                            "adventurer-idle-03.png",
                        }
                    },
                    {
                        "jump",
                        new string[]
                        {
                            "adventurer-jump-02.png",
                            "adventurer-jump-03.png",
                        }
                    },
                    {
                        "run",
                        new string[]
                        {
                            "adventurer-run-00.png",
                            "adventurer-run-01.png",
                            "adventurer-run-02.png",
                            "adventurer-run-03.png",
                            "adventurer-run-04.png",
                            "adventurer-run-05.png",
                        }
                    },
                    {
                        "use-item",
                        new string[]
                        {
                            "adventurer-items-00.png",
                            "adventurer-items-01.png",
                            "adventurer-items-02.png",
                        }
                    },
                };
            }
            Animations = PlayerAnimations;

            Animator.AddAnimation("attack1", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack1"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack1"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack1"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack1"][3]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack1"][4]}")),
            }, 10));
            Animator.AddAnimation("attack2", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack2"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack2"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack2"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack2"][3]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack2"][4]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack2"][5]}")),
            }, 10));
            Animator.AddAnimation("attack3", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack3"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack3"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack3"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack3"][3]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack3"][4]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack3"][5]}")),
            }, 10));
            Animator.AddAnimation("air-attack1", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack1"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack1"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack1"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack1"][3]}")),
            }, 10));
            Animator.AddAnimation("air-attack2", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack2"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack2"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack2"][2]}")),
            }, 10));
            Animator.AddAnimation("air-attack3-end", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack3-end"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack3-end"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack3-end"][2]}")),
            }, 10));
            Animator.AddAnimation("air-attack3-loop", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack3-loop"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack3-loop"][1]}")),
            }, 10));
            Animator.AddAnimation("air-attack3-rdy", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["air-attack3-rdy"][0]}")),
            }, 10));
            Animator.AddAnimation("die", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][3]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][4]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][5]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][5]}")),
            }, 5));
            Animator.AddAnimation("fall", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["fall"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["fall"][1]}")),
            }, 10));
            Animator.AddAnimation("idle", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][3]}")),
            }, 5));
            Animator.AddAnimation("jump", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["jump"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["jump"][1]}")),
            }, 10));
            Animator.AddAnimation("run", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["run"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["run"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["run"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["run"][3]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["run"][4]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["run"][5]}")),
            }, 10));
            Animator.AddAnimation("use-item", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["use-item"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["use-item"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["use-item"][2]}")),
            }, 5));
        }
Beispiel #14
0
        protected override void AddAnimations()
        {
            if (SlimeAnimations == null)
            {
                SlimeAnimations = new Dictionary <string, string[]>
                {
                    {
                        "attack",
                        new string[]
                        {
                            "slime-attack-0.png",
                            "slime-attack-1.png",
                            "slime-attack-2.png",
                            "slime-attack-3.png",
                            "slime-attack-4.png",
                        }
                    },
                    {
                        "die",
                        new string[]
                        {
                            "slime-die-0.png",
                            "slime-die-1.png",
                            "slime-die-2.png",
                            "slime-die-3.png",
                        }
                    },
                    {
                        "stunned",
                        new string[]
                        {
                            "slime-hurt-0.png",
                            "slime-hurt-1.png",
                            "slime-hurt-2.png",
                            "slime-hurt-3.png",
                        }
                    },
                    {
                        "idle",
                        new string[]
                        {
                            "slime-idle-0.png",
                            "slime-idle-1.png",
                            "slime-idle-2.png",
                            "slime-idle-3.png",
                        }
                    },
                    {
                        "move",
                        new string[]
                        {
                            "slime-move-0.png",
                            "slime-move-1.png",
                            "slime-move-2.png",
                            "slime-move-3.png",
                        }
                    },
                };
            }
            Animations = SlimeAnimations;

            Animator.AddAnimation("attack", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack"][3]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["attack"][4]}")),
            }, 10));
            Animator.AddAnimation("die", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["die"][3]}")),
            }, 5));
            Animator.AddAnimation("stunned", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["stunned"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["stunned"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["stunned"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["stunned"][3]}")),
            }, 5));
            Animator.AddAnimation("idle", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["idle"][3]}")),
            }, 5));
            Animator.AddAnimation("move", new SpriteAnimation(new Sprite[]
            {
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["move"][0]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["move"][1]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["move"][2]}")),
                new Sprite(Entity.Scene.Content.LoadTexture($"{ContentPath}/{Animations["move"][3]}")),
            }, 5));
        }
 public void SimpleVector2Animation_1000__0_0__100_100()
 {
     animator.AddAnimation(new SimpleVector2Animation(tex, Vector2.Zero, new Vector2(100, 100), 1000), true);
     SimularTempo(TimeSpan.FromMilliseconds(1000));
     Assert.AreEqual(new Vector2(100, 100), tex.Position);
 }
 public void AddAnimation(string animationName, Animation animation)
 {
     _animator.AddAnimation(animationName, animation);
 }
Beispiel #17
0
        /// <summary>
        /// Create a new instance of the Player class.
        /// </summary>
        public Player()
        {
            Name      = "Player";
            Tag       = Tag.Player;
            MaxHealth = 100;
            Health    = MaxHealth;

            Texture2D spriteSheet = ContentManager.GetTexture("Player"); //Load<Texture2D>(@"..\..\..\..\Content\Sprites\Player\Player_spriteSheet");

            Vector2 origin = new Vector2(21, 0);

            Sprite[] spriteWalk   = Sprite.Slice(spriteSheet, new Rectangle(0, 0, 42, 72), new Point(8, 1), origin);
            Sprite[] spriteRun    = Sprite.Slice(spriteSheet, new Rectangle(0, 74, 42, 72), new Point(8, 1), origin);
            Sprite[] spriteIdle   = Sprite.Slice(spriteSheet, new Rectangle(0, 148, 17, 68), new Point(8, 1), new Vector2(8, 0));
            Sprite[] spriteJump   = Sprite.Slice(spriteSheet, new Rectangle(0, 218, 42, 72), new Point(2, 1), origin);
            Sprite[] spriteAttack = Sprite.Slice(spriteSheet, new Rectangle(0, 291, 84, 72), new Point(4, 2), origin);

            Animation attackAnimation = new Animation(spriteAttack, 1000 / 50)
            {
                Loop = false
            };

            Animator animator = new Animator
            {
                Name = "anmimatort"
            };

            animator.AddAnimation("walk", new Animation(spriteWalk, 1000 / 10));
            animator.AddAnimation("run", new Animation(spriteRun, 1000 / 30));
            animator.AddAnimation("idle", new Animation(spriteIdle, 1000 / 7));
            animator.AddAnimation("jump", new Animation(spriteJump, 1000 / 10));
            animator.AddAnimation("attack", attackAnimation);

            AddComponent(animator);
            PlayerMovement movement = AddComponent <PlayerMovement>();

            AddComponent(new Collider(new Vector2(13, 62))
            {
                Name = "Collider", Offset = new Vector2(16, 5) - origin
            }).OnCollision += movement.OnCollision;
            AddComponent(new Collider(new Vector2(30, 23))
            {
                Name = "AttackLeft", Offset = new Vector2(-14, 25) - origin, IsTrigger = true, Enabled = false
            }).OnTriggerEnter += movement.OnTriggerEnter;
            AddComponent(new Collider(new Vector2(30, 23))
            {
                Name = "AttackRight", Offset = new Vector2(29, 25) - origin, IsTrigger = true, Enabled = false
            }).OnTriggerEnter += movement.OnTriggerEnter;
            AddComponent(new SpriteRenderer());
            AddComponent(new RigidBody
            {
                Name  = "Rb",
                Mass  = 78.6f,
                Power = 9001 ^ 9001 // OMG OVER 9000
            });

            attackAnimation.GetFrame(2).Event += () =>
            {
                if (GetComponent <SpriteRenderer>().SpriteEffect == SpriteEffects.FlipHorizontally)
                {
                    GetComponent("AttackLeft").Enabled = true;
                }
                else
                {
                    GetComponent("AttackRight").Enabled = true;
                }
            };
            attackAnimation.GetFrame(5).Event += () =>
            {
                if (GetComponent <SpriteRenderer>().SpriteEffect == SpriteEffects.FlipHorizontally)
                {
                    GetComponent("AttackLeft").Enabled = false;
                }
                else
                {
                    GetComponent("AttackRight").Enabled = false;
                }
            };
        }
Beispiel #18
0
        private void ConfigureAnimation()
        {
            Single dy = 240;
            // apply a 3D zoom animation to the first label
            Transform3DAnimation labelTransform = new Transform3DAnimation(FirstLabel, 0.3f);
            Transform3D          tt1            = new Transform3D()
            {
                M34 = 0.03f
            };
            Transform3D tt2 = new Transform3D()
            {
                M34 = 0.3f
            };

            tt2.Rotate = new Transform3DRotate {
                Angle = Convert.ToSingle(Math.PI), X = 1, Y = 0, Z = 0
            };
            tt2.Translate = new Transform3DTranslate()
            {
                Tx = 320, Ty = 150, Tz = -50
            };
            tt2.Scale = new Transform3DScale()
            {
                Sx = 1.0f, Sy = 1.0f, Sz = 1.0f
            };
            labelTransform.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(0),
                Alpha = 1.0f
            });
            labelTransform.AddKeyFrame(new AnimationFrame()
            {
                Time      = TimeForPage(1),
                Transform = tt1
            });
            labelTransform.AddKeyFrame(new AnimationFrame()
            {
                Time      = TimeForPage(1.5f),
                Transform = tt2
            });
            //	        labelTransform.AddKeyFrame(new AnimationKeyFrame()
            //	        {
            //	            Time = TimeForPage(1.5f) + 1,
            //	            Alpha = 0.0f
            //	        });
            Animator.AddAnimation(labelTransform);

            // let's animate the wordmark
            var wordmarkFrameAnimation = new FrameAnimation(Wordmark);

            Animator.AddAnimation(wordmarkFrameAnimation);

            var newAnimaitons = new List <AnimationFrameBase> ();

            var temp1 = Wordmark.Frame;

            temp1.Offset(new CGPoint(200, 0));

            newAnimaitons.Add(new AnimationFrame()
            {
                Time  = TimeForPage(1),
                Frame = temp1
            });

            newAnimaitons.Add(new AnimationFrame()
            {
                Time = TimeForPage(2), Frame = Wordmark.Frame
            });


            var temp2 = Wordmark.Frame;

            temp2.Offset(new CGPoint((float)View.Frame.Width, dy));

            newAnimaitons.Add(new AnimationFrame()
            {
                Time  = TimeForPage(3),
                Frame = temp2
            });

            var temp3 = Wordmark.Frame;

            temp3.Offset(new CGPoint(0, dy));

            newAnimaitons.Add(new AnimationFrame()
            {
                Time  = TimeForPage(4),
                Frame = temp3
            });

            wordmarkFrameAnimation.AddKeyFrames(newAnimaitons);

            //Rotate a full circle from page 2 to 3
            var wordmarkRotationAnimation = new AngleAnimation(Wordmark);

            Animator.AddAnimation(wordmarkRotationAnimation);
            wordmarkRotationAnimation.AddKeyFrames(
                new List <AnimationFrameBase>()
            {
                new AnimationFrame()
                {
                    Time  = TimeForPage(2),
                    Angle = 0.0f
                },
                new AnimationFrame()
                {
                    Time  = TimeForPage(3),
                    Angle = Convert.ToSingle(2 * Math.PI)
                }
            });

            // now, we animate the unicorn
            FrameAnimation unicornFrameAnimation = new FrameAnimation(Unicorn);

            Animator.AddAnimation(unicornFrameAnimation);

            float ds = 50f;

            // move down and to the right, and shrink between pages 2 and 3
            unicornFrameAnimation.AddKeyFrame(new AnimationFrame {
                Time  = TimeForPage(2),
                Frame = Unicorn.Frame
            });

            Unicorn.Frame = CGRect.Inflate(Unicorn.Frame, -ds, -ds);


            var uTemp1 = Unicorn.Frame;

            uTemp1.Offset(TimeForPage(2), dy);
            Unicorn.Frame = uTemp1;

            var animKeyFrame = new AnimationFrame
            {
                Time  = TimeForPage(3),
                Frame = Unicorn.Frame
            };

            unicornFrameAnimation.AddKeyFrame(animKeyFrame);

            // fade the unicorn in on page 2 and out on page 4
            AlphaAnimation unicornAlphaAnimation = new AlphaAnimation(Unicorn);

            Animator.AddAnimation(unicornAlphaAnimation);

            unicornAlphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(1),
                Alpha = 0.0f
            });
            unicornAlphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(2),
                Alpha = 1.0f
            });
            unicornAlphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(3),
                Alpha = 1.0f
            });
            unicornAlphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(4),
                Alpha = 0.0f
            });

            // Fade out the label by dragging on the last page
            AlphaAnimation labelAlphaAnimation = new AlphaAnimation(this.LastLabel);

            labelAlphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(4),
                Alpha = 1.0f
            });
            labelAlphaAnimation.AddKeyFrame(new AnimationFrame()
            {
                Time  = TimeForPage(4.35f),
                Alpha = 0.0f
            });
            Animator.AddAnimation(labelAlphaAnimation);
        }