Ejemplo n.º 1
0
        public Player(World world) : base(world, true)
        {
            this.Bounds = new RectangleF(-0.375F, -0.2F, 0.75F, 0.75F);

            this.animations = new SpriteAnimationGroup();
            // standing
            this.animations.Add(new SpriteAnimation(1, Texture, new Rectangle(0, 8, 8, 8)), () => !this.IsMoving && this.Direction == 0);
            this.animations.Add(new SpriteAnimation(1, Texture, new Rectangle(8, 8, 8, 8)), () => !this.IsMoving && this.Direction == 1);
            this.animations.Add(new SpriteAnimation(1, Texture, new Rectangle(16, 8, 8, 8)), () => !this.IsMoving && this.Direction == 2);
            this.animations.Add(new SpriteAnimation(1, Texture, new Rectangle(24, 8, 8, 8)), () => !this.IsMoving && this.Direction == 3);
            // moving
            const float speed = 0.15F;

            this.animations.Add(new SpriteAnimation(speed, Texture, new Rectangle(0, 8, 8, 8), new Rectangle(0, 16, 8, 8), new Rectangle(0, 24, 8, 8), new Rectangle(0, 32, 8, 8)), () => this.IsMoving && this.Direction == 0);
            this.animations.Add(new SpriteAnimation(speed, Texture, new Rectangle(8, 8, 8, 8), new Rectangle(8, 16, 8, 8), new Rectangle(8, 24, 8, 8), new Rectangle(8, 32, 8, 8)), () => this.IsMoving && this.Direction == 1);
            this.animations.Add(new SpriteAnimation(speed, Texture, new Rectangle(16, 8, 8, 8), new Rectangle(16, 16, 8, 8), new Rectangle(16, 24, 8, 8), new Rectangle(16, 32, 8, 8)), () => this.IsMoving && this.Direction == 2);
            this.animations.Add(new SpriteAnimation(speed, Texture, new Rectangle(24, 8, 8, 8), new Rectangle(24, 16, 8, 8), new Rectangle(24, 24, 8, 8), new Rectangle(24, 32, 8, 8)), () => this.IsMoving && this.Direction == 3);
        }
Ejemplo n.º 2
0
        public Player(Map map) : base(map)
        {
            this.light = new PointLight {
                ShadowType = ShadowType.Occluded,
                Intensity  = 0.8F
            };
            map.Penumbra.Lights.Add(this.light);

            var tex = new UniformTextureAtlas(MlemGame.LoadContent <Texture2D>("Textures/Player"), 4, 4);

            this.animation = new SpriteAnimationGroup();
            this.animation.Add(new SpriteAnimation(1, tex[0, 0]), () => this.Direction == Direction2.Down);
            this.animation.Add(new SpriteAnimation(1, tex[1, 0]), () => this.Direction == Direction2.Up);
            this.animation.Add(new SpriteAnimation(1, tex[2, 0]), () => this.Direction == Direction2.Left);
            this.animation.Add(new SpriteAnimation(1, tex[3, 0]), () => this.Direction == Direction2.Right);
            this.animation.Add(new SpriteAnimation(0.15F, tex[0, 0], tex[0, 1], tex[0, 2], tex[0, 3]), () => this.walkPercentage > 0 && this.Direction == Direction2.Down, 10);
            this.animation.Add(new SpriteAnimation(0.15F, tex[1, 0], tex[1, 1], tex[1, 2], tex[1, 3]), () => this.walkPercentage > 0 && this.Direction == Direction2.Up, 10);
            this.animation.Add(new SpriteAnimation(0.15F, tex[2, 0], tex[2, 1], tex[2, 2], tex[2, 3]), () => this.walkPercentage > 0 && this.Direction == Direction2.Left, 10);
            this.animation.Add(new SpriteAnimation(0.15F, tex[3, 0], tex[3, 1], tex[3, 2], tex[3, 3]), () => this.walkPercentage > 0 && this.Direction == Direction2.Right, 10);
        }