Ejemplo n.º 1
0
        public override void Initialize(IResolver resolver)
        {
            this.Width  = 56;
            this.Height = 56;
            var visual = new Sprite(Color.Red * .25f, (int)this.Width, (int)this.Height);

            visual.CenterObject();
            visual.IsVisible = false;
            this.Components.Add(visual);

            this.spriteIdle = new MovementSprite("player_walk", TimeSpan.FromSeconds(1.5f))
            {
                Scale = 3f
            };
            this.spriteWalk = new MovementSprite("player_walk", TimeSpan.FromSeconds(.5f))
            {
                Scale = 3f
            };
            this.Components.Add(this.spriteIdle);
            this.Components.Add(this.spriteWalk);
            this.spriteIdle.Start();

            this.spriteDeath = new SpriteSheet <int>
            {
                Regions = new SpriteRegions <int>
                {
                    { 0, new SpriteFrame("player_dies", new Rectangle(0, 0, 48, 48)) },
                    { 1, new SpriteFrame("player_dies", new Rectangle(48, 0, 48, 48)) },
                    { 2, new SpriteFrame("player_dies", new Rectangle(96, 0, 48, 48)) },
                },
                IsVisible = false,
                Scale     = new Vector2(3f)
            };
            this.spriteDeath.CenterObject();
            this.Components.Add(this.spriteDeath);

            this.speedReducer = new EventValueAnimator(TimeSpan.FromSeconds(5));
            this.speedReducer.ValueUpdated += (s, perc) =>
            {
                var halfSpeed = this.topSpeed / 2f;
                this.MaxMovement = halfSpeed + halfSpeed * (1 - perc);
            };
            this.Components.Add(this.speedReducer);

            this.speedReducer.Start();

            base.Initialize(resolver);

            this.Direction = World.Movement.Down;
            this.EquipShoe(this.ViewModel.ShoeType);
        }
Ejemplo n.º 2
0
        public override void Initialize(IResolver resolver)
        {
            this.Width  = 72;
            this.Height = 72;
            var visual = new Sprite(Color.GreenYellow * .25f, (int)this.Width, (int)this.Height);

            visual.CenterObject();
            this.Components.Add(visual);
            visual.IsVisible = false;

            this.spriteWalk = new MovementSprite("npc_walk", TimeSpan.FromSeconds(.5f));
            this.spriteWalk.Start();
            this.Components.Add(this.spriteWalk);

            this.hasSeenPlayer = false;

            base.Initialize(resolver);
        }