예제 #1
0
        public override void Load(ContentManager content)
        {
            #region  INITIALIZE TEXTURE ATLAS AND ANIMATION

            var spriteWidth   = 16;
            var spriteHeight  = 16;
            var objectTexture = content.Load <Texture2D>("Sprites/Player/s_player_overworld_atlas");
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 0, 1 }, frameDuration: 0.2f, isLooping: true));

            #endregion


            objectAnimated = new AnimatedSprite(animationFactory, "idle");
            objectSprite   = objectAnimated;

            base.Load(content);

            objectSprite.Origin = Vector2.Zero + origin;
            //set custom hitbox
            boundingBoxTopLeft     = Vector2.Zero;
            boundingBoxBottomRight = new Vector2(16, 16);
        }
예제 #2
0
        public Entity CreatePlayer(Vector2 position)
        {
            var dudeTexture = _contentManager.Load <Texture2D>("Graphics/hero");
            var dudeAtlas   = TextureAtlas.Create("dudeAtlas", dudeTexture, 16, 16);
            var entity      = _world.CreateEntity();

            var animationFactory = new SpriteSheetAnimationFactory(dudeAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f));
            animationFactory.Add("combat", new SpriteSheetAnimationData(new[] { 25 }, frameDuration: 0.1f, isLooping: false));
            animationFactory.Add("guard", new SpriteSheetAnimationData(new[] { 24 }, frameDuration: 0.3f, isLooping: false));

            entity.Attach(new AnimatedSprite(animationFactory, "idle"));
            entity.Attach(new Transform2(position, 0, Vector2.One * 4));
            entity.Attach(new Body {
                Position = position, Size = new Vector2(40, 96), BodyType = BodyType.Dynamic
            });
            entity.Attach(new Focusable {
                IsFocused = true
            });
            entity.Attach(new Health()
            {
                LifePoints = 3
            });
            entity.Attach(new Player());

            return(entity);
        }
예제 #3
0
        public Entity CreateNecromancer(Vector2 position)
        {
            var necroTexture = _contentManager.Load <Texture2D>("Graphics/YeOldyNecroGuy");
            var necroAtlas   = TextureAtlas.Create("necroAtlas", necroTexture, 28, 28);
            var entity       = _world.CreateEntity();

            var animationFactory = new SpriteSheetAnimationFactory(necroAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f));
            animationFactory.Add("combat", new SpriteSheetAnimationData(new[] { 25 }, frameDuration: 0.1f, isLooping: false));
            entity.Attach(new AnimatedSprite(animationFactory, "idle"));
            entity.Attach(new Transform2(position, 0, Vector2.One * 4));
            entity.Attach(new Body {
                Position = position, Size = new Vector2(40, 96), BodyType = BodyType.Static
            });
            entity.Attach(new Health()
            {
                LifePoints = 3
            });
            entity.Attach(new Enemy()
            {
                Facing = Facing.Left
            });

            return(entity);
        }
예제 #4
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var zombieAnimations = Content.Load <SpriteSheetAnimationFactory>("Animations/zombie-animations");

            _zombie = new Zombie(zombieAnimations)
            {
                Position = new Vector2(100, 100)
            };

            var fireballTexture = Content.Load <Texture2D>("Animations/fireball");
            var fireballAtlas   = TextureAtlas.Create("Animations/fireball-atlas", fireballTexture, 130, 50);

            _animation = new SpriteSheetAnimation("fireballAnimation", fireballAtlas.Regions.ToArray())
            {
                FrameDuration = 0.2f
            };
            _fireballSprite = new Sprite(_animation.CurrentFrame);// { Position = new Vector2(-150, 100) };

            var motwTexture          = Content.Load <Texture2D>("Animations/motw");
            var motwAtlas            = TextureAtlas.Create("Animations/fireball-atlas", motwTexture, 52, 72);
            var motwAnimationFactory = new SpriteSheetAnimationFactory(motwAtlas);

            motwAnimationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            motwAnimationFactory.Add("walkSouth", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }, isLooping: false));
            motwAnimationFactory.Add("walkWest", new SpriteSheetAnimationData(new[] { 12, 13, 14, 13 }, isLooping: false));
            motwAnimationFactory.Add("walkEast", new SpriteSheetAnimationData(new[] { 24, 25, 26, 25 }, isLooping: false));
            motwAnimationFactory.Add("walkNorth", new SpriteSheetAnimationData(new[] { 36, 37, 38, 37 }, isLooping: false));
            _motwSprite = new AnimatedSprite(motwAnimationFactory);// { Position = new Vector2(20, 20) };
            _motwSprite.Play("walkSouth").IsLooping = true;
        }
예제 #5
0
        public override void Load(ContentManager content)
        {
            // initiliaze sprite
            spriteWidth   = 20;
            spriteHeight  = 20;
            objectTexture = content.Load <Texture2D>("Sprites/playerOverworld");
            objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            //create animations from sprite sheet
            animationFactory = new SpriteSheetAnimationFactory(objectAtlas);
            animationFactory.Add("down", new SpriteSheetAnimationData(new[] { 0 }));
            animationFactory.Add("downwalk", new SpriteSheetAnimationData(new[] { 1, 2 }, frameDuration: 0.2f, isLooping: true));

            animationFactory.Add("up", new SpriteSheetAnimationData(new[] { 3 }));
            animationFactory.Add("upwalk", new SpriteSheetAnimationData(new[] { 4, 5 }, frameDuration: 0.2f, isLooping: true));

            animationFactory.Add("right", new SpriteSheetAnimationData(new[] { 6 }));
            animationFactory.Add("rightwalk", new SpriteSheetAnimationData(new[] { 7, 8 }, frameDuration: 0.2f, isLooping: true));

            animationFactory.Add("left", new SpriteSheetAnimationData(new[] { 9 }));
            animationFactory.Add("leftwalk", new SpriteSheetAnimationData(new[] { 10, 11 }, frameDuration: 0.2f, isLooping: true));

            objectAnimated = new AnimatedSprite(animationFactory, "down");
            objectSprite   = objectAnimated;

            objectSprite.Depth = 0.1f;

            base.Load(content);
            boundingBoxWidth  = 16;
            boundingBoxHeight = 16;
            boundingBoxOffset = new Vector2(2, 4);
        }
예제 #6
0
        public Animation(Texture2D texture, SpriteSheetData spriteSheetData, int direction = 0, bool isPlayer = false)
        {
            var spriteWidth   = spriteSheetData.Width;
            var spriteHeight  = spriteSheetData.Height;
            var objectTexture = texture;
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            for (int i = 0; i < spriteSheetData.AnimationName.Count; i++)
            {
                animationFactory.Add(spriteSheetData.AnimationName[i], new SpriteSheetAnimationData(spriteSheetData.FrameArray[i], spriteSheetData.FrameDuration[i], spriteSheetData.IsLooping[i]));
            }

            if (isPlayer)
            {
                objectAnimated = new AnimatedSprite(animationFactory, HUD.PlayerCurrentState.ToString());
            }
            else
            {
                objectAnimated = new AnimatedSprite(animationFactory, "Idle");
            }

            objectSprite        = objectAnimated;
            objectSprite.Origin = Vector2.Zero;

            if (direction == (int)Direction.Right)
            {
                objectAnimated.Effect = SpriteEffects.None;
            }
            else
            {
                objectAnimated.Effect = SpriteEffects.FlipHorizontally;
            }
        }
예제 #7
0
        public static Entity Create(Engine engine, Texture2D texture, Vector2 position)
        {
            Entity entity = engine.CreateEntity();

            entity.AddComponent(new TransformComponent(position));
            entity.AddComponent(new SpriteComponent(texture, Constants.ObjectBounds.EXPLOSION_BOUNDS));
            entity.AddComponent(new ExplosionComponent());

            Dictionary <string, Rectangle> explMap = new Dictionary <string, Rectangle>();

            explMap.Add("Explosion1", new Rectangle(0, 0, 32, 32));
            explMap.Add("Explosion2", new Rectangle(32, 0, 32, 32));
            explMap.Add("Explosion3", new Rectangle(64, 0, 32, 32));
            explMap.Add("Explosion4", new Rectangle(96, 0, 32, 32));
            explMap.Add("Explosion5", new Rectangle(128, 0, 32, 32));
            explMap.Add("Explosion6", new Rectangle(160, 0, 32, 32));
            explMap.Add("Explosion7", new Rectangle(192, 0, 32, 32));
            TextureAtlas explAtlas = new TextureAtlas("explosion", texture, explMap);
            SpriteSheetAnimationFactory explAnimationFactory = new SpriteSheetAnimationFactory(explAtlas);

            explAnimationFactory.Add("default", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 4, 5, 6 }, isLooping: false, frameDuration: 0.1f));
            AnimatedSprite explAnim = new AnimatedSprite(explAnimationFactory);

            entity.AddComponent(new Components.AnimationComponent(explAnimationFactory, new AnimatedSprite[] { explAnim }));
            entity.GetComponent <Components.AnimationComponent>().ActiveAnimationIndex = 0;
            explAnim.Play("default", () =>
            {
                entity.GetComponent <Components.AnimationComponent>().ActiveAnimationIndex = -1;
            });

            return(entity);
        }
예제 #8
0
        public void LoadContent()
        {
            var aliens     = _game.Content.Load <Texture2D>("aliens");
            var alienAtlas = TextureAtlas.Create("aliens",
                                                 aliens,
                                                 16,
                                                 10);

            _animationFactory = new SpriteSheetAnimationFactory(alienAtlas);
            _animationFactory.Add("alien0", new SpriteSheetAnimationData(new[] { 0, 1 }, 0.5f));
            _animationFactory.Add("alien1", new SpriteSheetAnimationData(new[] { 2, 3 }, 0.5f));
            _animationFactory.Add("alien2", new SpriteSheetAnimationData(new[] { 4, 5 }, 0.5f));

            _ship   = _game.Content.Load <Texture2D>("ship");
            _bullet = _game.Content.Load <Texture2D>("bullet");
        }
예제 #9
0
        public static Entity Create(Engine engine, Texture2D texture, Vector2 position)
        {
            Entity entity = engine.CreateEntity();

            entity.AddComponent(new TransformComponent(position));
            entity.AddComponent(new SpriteComponent(texture, Constants.ObjectBounds.KAMIKAZE_SHIP_BOUNDS));
            entity.AddComponent(new RotationComponent(Constants.GamePlay.KAMIKAZE_ROTATION_SPEED));
            entity.AddComponent(new MovementComponent());
            entity.GetComponent <MovementComponent>().speed = Constants.GamePlay.KAMIKAZE_ENEMY_SPEED;
            entity.AddComponent(new EnemyComponent());
            entity.AddComponent(new CollisionComponent(new BoundingRect(0, 0, 21.875f, 21.875f)));
            entity.AddComponent(new KamikazeComponent());

            Dictionary <string, Rectangle> animMap = new Dictionary <string, Rectangle>();

            animMap.Add("2", new Rectangle(0, 0, 32, 32));
            animMap.Add("1", new Rectangle(32, 0, 32, 32));
            TextureAtlas animAtlas = new TextureAtlas("explosion", texture, animMap);
            SpriteSheetAnimationFactory animAnimationFactory = new SpriteSheetAnimationFactory(animAtlas);

            animAnimationFactory.Add("default", new SpriteSheetAnimationData(new[] { 0, 1 }, isLooping: true, frameDuration: 0.4f));
            AnimatedSprite anim = new AnimatedSprite(animAnimationFactory);

            entity.AddComponent(new Components.AnimationComponent(animAnimationFactory, new AnimatedSprite[] { anim }));
            entity.GetComponent <Components.AnimationComponent>().ActiveAnimationIndex = 0;
            anim.Play("default");

            return(entity);
        }
예제 #10
0
        public Character(List <string> data, int x, int y, Location loc) : base(loc)
        {
            drawToolInteractBox      = true;
            interactBoxTexture       = Game1.content.Load <Texture2D>("spriteSheets/simplebox");
            interactToolBoxRectangle = FindInteractToolBoxRectangle();
            interactBoxRectangle     = FindInteractBoxRectangle();

            velocityX = 0;
            velocityY = 0;

            curSprite = "";
            speed     = 0.15f;

            events = new List <Event>();

            spriteFactory = Game1.CreateAnimationFactory(data[2], data[3]);
            float frameDuration = float.Parse(data[4]);

            for (int i = 5; i < data.Count; i++)
            {
                var   indexes         = data[i].Split(',');
                int[] animationFrames = new int[indexes.Count() - 1];
                for (int j = 0; j < indexes.Count() - 1; j++)
                {
                    animationFrames[j] = Int32.Parse(indexes[j + 1]);
                }
                spriteFactory.Add(indexes[0], new SpriteSheetAnimationData(animationFrames, frameDuration, (animationFrames.Count() > 1)));
            }
            curSprite       = "down_idle";
            facingDirection = Direction.Down;
            sprite          = Game1.CreateAnimatedSprite(spriteFactory, curSprite);
            collisionBox    = MakeCollisionBoundingBox();
            posX            = x;
            posY            = y;
        }
예제 #11
0
        public override void Load(ContentManager content)
        {
            // initiliaze sprite
            spriteWidth   = 48;
            spriteHeight  = 32;
            objectTexture = content.Load <Texture2D>("Sprites/player");
            objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            //create animations from sprite sheet
            animationFactory = new SpriteSheetAnimationFactory(objectAtlas);
            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 1, 2, 3, 4 }, frameDuration: 0.1f, isLooping: true));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 3 }));
            animationFactory.Add("attack", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9 }, frameDuration: 0.1f, isLooping: true));
            animationFactory.Add("attackDown", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9 }, frameDuration: 0.1f, isLooping: true));
            animationFactory.Add("hurt", new SpriteSheetAnimationData(new[] { 3 }));
            animationFactory.Add("duck", new SpriteSheetAnimationData(new[] { 10 }, frameDuration: 0.1f, isLooping: true));

            objectAnimated = new AnimatedSprite(animationFactory, "idle");
            objectSprite   = objectAnimated;

            objectSprite.Depth = 0.1f;

            // load sound effects
            jumpSFX   = content.Load <SoundEffect>("Audio/Sound Effects/Jump");
            attackSFX = content.Load <SoundEffect>("Audio/Sound Effects/playerAttack");
            hurtSFX   = content.Load <SoundEffect>("Audio/Sound Effects/playerHurt");
            deadSFX   = content.Load <SoundEffect>("Audio/Sound Effects/playerDeath");

            base.Load(content);
            boundingBoxWidth  = 14;
            boundingBoxHeight = 24;
            boundingBoxOffset = new Vector2(17, 7);
        }
예제 #12
0
        public Entity CreatePlayer(Vector2 position)
        {
            var entity           = _entityComponentSystem.CreateEntity(Entities.Player, position);
            var textureRegion    = _characterTextureAtlas[0];
            var animationFactory = new SpriteSheetAnimationFactory(_characterTextureAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 12, 13 }, 1.0f));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3 }));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 8, 9 }, isLooping: false));

            entity.AttachComponent(new TransformableComponent <Sprite>(new AnimatedSprite(animationFactory)));
            entity.AttachComponent(new BasicCollisionBody(textureRegion.Size, Vector2.One * 0.5f));
            entity.AttachComponent(new PlayerCollisionHandler());
            entity.AttachComponent(new CharacterState());
            entity.Tag = Entities.Player;

            return(entity);
        }
예제 #13
0
        public EfxGenerator(Texture2D texture)
        {
            var spriteWidth  = 32;
            var spriteHeight = 32;

            ObjectTexture = texture;
            var objectAtlas = TextureAtlas.Create("objectAtlas", ObjectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            animationFactory.Add("Init", new SpriteSheetAnimationData(new[] { 0 }, 0.1f, false));
            animationFactory.Add("Death", new SpriteSheetAnimationData(new[] { 1, 2, 3, 4 }, 0.05f, false));
            animationFactory.Add("Smoke", new SpriteSheetAnimationData(new[] { 5, 6, 7, 8, 9, 10 }, 0.12f, false));


            ObjectAnimated      = new AnimatedSprite(animationFactory, "Init");
            ObjectSprite        = ObjectAnimated;
            ObjectSprite.Origin = Vector2.Zero;
        }
예제 #14
0
        public override void LoadContent(ContentManager content)
        {
            _texture = content.Load <Texture2D>("Textures/s_start_screen");

            var spriteWidth   = 480;
            var spriteHeight  = 270;
            var objectTexture = _texture;
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            animationFactory.Add("Fade", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 0.3f, false));
            animationFactory.Add("StartScreen", new SpriteSheetAnimationData(new[] { 10, 11, 12, 13 }, 0.3f));

            ObjectAnimated = new AnimatedSprite(animationFactory, "StartScreen");
            ObjectSprite   = ObjectAnimated;

            ObjectSprite.Origin = Vector2.Zero;
            ObjectAnimated.Play("Fade", () => _canPressStart = true);
        }
예제 #15
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            Content.Load <BitmapFont>("Fonts/courier-new-32");
            _map = Content.Load <TiledMap>("Tilesets/level01");

            _world = new CollisionWorld(new Vector2(0, 900));
            //_world.CreateGrid(_tiledMap.GetLayer<TiledTileLayer>("Tile Layer 1"));

            var zombieAnimations = Content.Load <SpriteSheetAnimationFactory>("Sprites/zombie-animations");

            _zombie = new Zombie(zombieAnimations);
            var zombieActor = _world.CreateActor(_zombie);

            zombieActor.Position = new Vector2(462.5f, 896f);

            var fireballTexture = Content.Load <Texture2D>("Sprites/fireball");
            var fireballAtlas   = TextureAtlas.Create("Sprites/fireball-atlas", fireballTexture, 130, 50);

            _animation = new SpriteSheetAnimation("fireballAnimation", fireballAtlas.Regions.ToArray())
            {
                FrameDuration = 0.2f
            };
            _fireballSprite = new Sprite(_animation.CurrentFrame)
            {
                Position = _zombie.Position
            };

            var motwTexture          = Content.Load <Texture2D>("Sprites/motw");
            var motwAtlas            = TextureAtlas.Create("Sprites/fireball-atlas", motwTexture, 52, 72);
            var motwAnimationFactory = new SpriteSheetAnimationFactory(motwAtlas);

            motwAnimationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            motwAnimationFactory.Add("walkSouth", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }, isLooping: false));
            motwAnimationFactory.Add("walkWest", new SpriteSheetAnimationData(new[] { 12, 13, 14, 13 }, isLooping: false));
            motwAnimationFactory.Add("walkEast", new SpriteSheetAnimationData(new[] { 24, 25, 26, 25 }, isLooping: false));
            motwAnimationFactory.Add("walkNorth", new SpriteSheetAnimationData(new[] { 36, 37, 38, 37 }, isLooping: false));
            _motwSprite          = new AnimatedSprite(motwAnimationFactory);
            _motwSprite.Position = new Vector2(350, 800);
            _motwSprite.Play("walkSouth").IsLooping = true;
        }
예제 #16
0
        private SpriteSheetAnimationFactory LoadAnimationFactory(TextureAtlas atlas, Animation[] animations)
        {
            var animationFactory = new SpriteSheetAnimationFactory(atlas);

            foreach (var animation in animations)
            {
                animationFactory.Add(animation.Name, new SpriteSheetAnimationData(animation.FrameIndices,
                                                                                  animation.FrameDuration, animation.IsLooping));
            }

            return(animationFactory);
        }
예제 #17
0
        public Entity CreateBadGuy(Vector2 position, Size2 size)
        {
            var entity           = _entityComponentSystem.CreateEntity(position);
            var textureRegion    = _characterTextureAtlas[90];
            var animationFactory = new SpriteSheetAnimationFactory(_characterTextureAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 100 }, 1.0f));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 96, 97, 98, 99 }, isPingPong: true));

            entity.AttachComponent(new TransformableComponent <Sprite>(new AnimatedSprite(animationFactory, "walk")));
            entity.AttachComponent(new BasicCollisionBody(textureRegion.Size, Vector2.One * 0.5f)
            {
                Tag = "Deadly"
            });
            entity.AttachComponent(new EnemyCollisionHandler());
            entity.AttachComponent(new CharacterState());
            entity.AttachComponent(new EnemyAi());
            entity.Tag = "BadGuy";

            return(entity);
        }
예제 #18
0
        public Entity CreateBlue(Vector2 position)
        {
            var dudeTexture = _contentManager.Load <Texture2D>("blueguy");
            var dudeAtlas   = TextureAtlas.Create("blueguyAtlas", dudeTexture, 16, 16);

            var entity           = _world.CreateEntity();
            var animationFactory = new SpriteSheetAnimationFactory(dudeAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 2, 1 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 10, 12 }, frameDuration: 1.0f, isLooping: false));
            entity.Attach(new AnimatedSprite(animationFactory, "idle")
            {
                Effect = SpriteEffects.FlipHorizontally
            });
            entity.Attach(new Transform2(position, 0, Vector2.One * 4));
            entity.Attach(new Body {
                Position = position, Size = new Vector2(32, 64), BodyType = BodyType.Dynamic
            });
            entity.Attach(new Enemy());
            return(entity);
        }
예제 #19
0
        private void loadSpriteSheet(ContentManager content)
        {
            Texture2D enemyTexture = content.Load <Texture2D>("Assets/SpriteSheets/Zombie");
            Dictionary <string, Rectangle> characterMap = content.Load <Dictionary <string, Rectangle> >("Assets/SpriteSheets/ZombieMap");
            TextureAtlas zombieAtlas = new TextureAtlas("zombie", enemyTexture, characterMap);
            SpriteSheetAnimationFactory zombieAnimationFactory = new SpriteSheetAnimationFactory(zombieAtlas);

            zombieAnimationFactory.Add("walking", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3 }, isLooping: true, frameDuration: 0.2f));

            this.zombieAnimationFactory = zombieAnimationFactory;

            //AnimatedSprite characterSpriteAnimation = new AnimatedSprite(zombieAnimationFactory, "walking");
            //anim = characterSpriteAnimation;
        }
예제 #20
0
        public override void Load(ContentManager content)
        {
            base.Load(content);
            // initiliaze sprite
            spriteWidth   = spriteHeight = 32;
            objectTexture = content.Load <Texture2D>("Sprites/" + "enemy");
            objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            //create animations from sprite sheet
            animationFactory = new SpriteSheetAnimationFactory(objectAtlas);
            objectAtlas      = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);
            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, frameDuration: 0.1f, isLooping: true));

            objectAnimated = new AnimatedSprite(animationFactory, "walk");

            objectSprite       = objectAnimated;
            objectSprite.Depth = 0.2F;

            boundingBoxWidth  = 14;
            boundingBoxHeight = 21;
            boundingBoxOffset = new Vector2(9, 6);
        }
예제 #21
0
        public Shuriken(Entities entities, GameObject owner, ContentManager content)
        {
            _entities = entities;
            _owner    = owner;
            _texture  = content.Load <Texture2D>("Textures/s_star");

            // create animation sprite
            var spriteWidth  = 9;
            var spriteHeight = 9;
            var objectAtlas  = TextureAtlas.Create("objectAtlas", _texture, spriteWidth, spriteHeight);

            _animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            _animationFactory.Add("Init", new SpriteSheetAnimationData(new[] { 0, 1 }, 0.05f, true));
        }
예제 #22
0
        public FlameStrike(Entities entities, GameObject owner, ContentManager content)
        {
            _entities = entities;
            _owner    = owner;
            _texture  = content.Load <Texture2D>("Textures/s_flame_strike");

            // create animation sprite
            var spriteWidth  = 32;
            var spriteHeight = 32;
            var objectAtlas  = TextureAtlas.Create("objectAtlas", _texture, spriteWidth, spriteHeight);

            _animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            _animationFactory.Add("Init", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3, 4 }, 0.2f, true, false, true));
        }
예제 #23
0
        protected override void LoadContent()
        {
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var characterTexture          = Content.Load <Texture2D>("furret");
            var characterMap              = Content.Load <Dictionary <string, Rectangle> >("furretMap");
            var characterAtlas            = new TextureAtlas("furret", characterTexture, characterMap);
            var characterAnimationFactory = new SpriteSheetAnimationFactory(characterAtlas);

            characterAnimationFactory.Add("idle", new SpriteSheetAnimationData(Enumerable.Range(0, 29).ToArray(), isLooping: true));

            _characterSpriteAnimation = new AnimatedSprite(characterAnimationFactory, "idle");

            // TODO: use this.Content to load your game content here
        }
예제 #24
0
        public void SpawnExplosion(Vector2 position, Vector2 velocity)
        {
            var frames           = new[] { 256, 257, 258, 259, 260, 261, 262, 263, 264 };
            var animationFactory = new SpriteSheetAnimationFactory(frames.Select(f => _tileset.GetTile(f)));

            animationFactory.Add("explode", new SpriteSheetAnimationData(new [] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, isLooping: false, frameDuration: 1f / 32f));
            var entity         = World.CreateEntity();
            var animatedSprite = new AnimatedSprite(animationFactory);

            entity.Attach(animatedSprite);
            entity.Attach(new Transform2(position));
            entity.Attach(new Body {
                Velocity = velocity
            });
            animatedSprite.Play("explode", () => entity.Destroy());
        }
예제 #25
0
        public override void Load(ContentManager content)
        {
            texture = content.Load <Texture2D>("Sprites/Player/s_player_idle");

            damageObject.Load(content);

            #region  INITIALIZE TEXTURE ATLAS AND ANIMATION

            var spriteWidth   = 54;
            var spriteHeight  = 35;
            var objectTexture = content.Load <Texture2D>("Sprites/Player/s_player_atlas");
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 3, 0, 1, 2, }, frameDuration: 0.2f, isLooping: true));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 4 }));
            animationFactory.Add("fall", new SpriteSheetAnimationData(new[] { 5 }));
            animationFactory.Add("duck", new SpriteSheetAnimationData(new[] { 6 }));
            animationFactory.Add("attack", new SpriteSheetAnimationData(new[] { 8, 9, 10 }, frameDuration: 0.1f, isLooping: false));
            animationFactory.Add("duckAttack", new SpriteSheetAnimationData(new[] { 12, 13, 14 }, frameDuration: 0.1f, isLooping: false));
            animationFactory.Add("walljump", new SpriteSheetAnimationData(new[] { 15 }));
            animationFactory.Add("wallAttack", new SpriteSheetAnimationData(new[] { 16, 17, 18 }, frameDuration: 0.1f, isLooping: false));

            #endregion


            objectAnimated = new AnimatedSprite(animationFactory, "idle");
            objectSprite   = objectAnimated;

            attackSFX = content.Load <SoundEffect>("Sounds/sfx/a_attack");

            base.Load(content);

            objectSprite.Origin = Vector2.Zero + origin;
            //set custom hitbox
            boundingBoxTopLeft     = standingBoundingBox;
            boundingBoxBottomRight = new Vector2(33, 35);
        }
예제 #26
0
        public override void Load(ContentManager content)
        {
            objectTexture = content.Load <Texture2D>("Maps/MapObjects/" + platformSize);
            spriteWidth   = objectTexture.Width;
            spriteHeight  = objectTexture.Height;

            objectAtlas      = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);
            animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));
            objectAnimated     = new AnimatedSprite(animationFactory, "idle");
            objectSprite       = objectAnimated;
            objectSprite.Depth = 0.5f;
            base.Load(content);

            boundingBoxWidth  = objectTexture.Width;
            boundingBoxHeight = objectTexture.Height;
        }
예제 #27
0
        public override void LoadContent(ContentManager content)
        {
            _texture = content.Load <Texture2D>("Textures/s_load_screen");
            _font    = content.Load <SpriteFont>("Fonts/f_menu");

            var spriteWidth   = 480;
            var spriteHeight  = 270;
            var objectTexture = _texture;
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);


            animationFactory.Add("LoadScreen", new SpriteSheetAnimationData(new[] { 0 }, 0.3f));

            ObjectAnimated = new AnimatedSprite(animationFactory, "LoadScreen");
            ObjectSprite   = ObjectAnimated;

            ObjectSprite.Origin = Vector2.Zero;
        }
예제 #28
0
파일: NPC.cs 프로젝트: Keatsotic/Animus
        public override void Load(ContentManager content)
        {
            // initiliaze sprite
            spriteWidth   = spriteHeight = 32;
            objectTexture = content.Load <Texture2D>("Sprites/" + NPCName);
            objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            //create animations from sprite sheet
            animationFactory = new SpriteSheetAnimationFactory(objectAtlas);
            objectAtlas      = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);
            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0 }));

            objectAnimated     = new AnimatedSprite(animationFactory, "idle");
            objectSprite       = objectAnimated;
            objectSprite.Depth = 0.2F;

            base.Load(content);
            boundingBoxWidth  = 14;
            boundingBoxHeight = 21;
            boundingBoxOffset = new Vector2(9, 6);
        }
예제 #29
0
파일: Player2.cs 프로젝트: Keatsotic/-mist
        public override void Load(ContentManager content, MapManager _mapManager)
        {
            image = TextureLoader.Load("Textures/Paula", content);

            var spriteWidth   = spriteSheetData.Width;
            var spriteHeight  = spriteSheetData.Height;
            var objectTexture = image;
            var objectAtlas   = TextureAtlas.Create("objectAtlas", objectTexture, spriteWidth, spriteHeight);

            var animationFactory = new SpriteSheetAnimationFactory(objectAtlas);

            for (int i = 0; i < spriteSheetData.AnimationName.Count; i++)
            {
                animationFactory.Add(spriteSheetData.AnimationName[i], new SpriteSheetAnimationData(spriteSheetData.FrameArray[i], spriteSheetData.FrameDuration[i], spriteSheetData.IsLooping[i]));
            }

            animatedSprite = new AnimatedSprite(animationFactory, "Down");

            sprite = animatedSprite;

            animatedSprite.Origin = Vector2.Zero;
        }
예제 #30
0
        public Entity CreatePlayer(Vector2 position)
        {
            var dudeTexture = _contentManager.Load <Texture2D>("hero");
            var dudeAtlas   = TextureAtlas.Create("dudeAtlas", dudeTexture, 16, 16);

            var entity           = _world.CreateEntity();
            var animationFactory = new SpriteSheetAnimationFactory(dudeAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 0, 1, 2, 1 }));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 6, 7, 8, 9, 10, 11 }, frameDuration: 0.1f));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 10, 12 }, frameDuration: 1.0f, isLooping: false));
            animationFactory.Add("fall", new SpriteSheetAnimationData(new[] { 13, 14 }, frameDuration: 1.0f, isLooping: false));
            animationFactory.Add("swim", new SpriteSheetAnimationData(new[] { 18, 19, 20, 21, 22, 23 }));
            animationFactory.Add("kick", new SpriteSheetAnimationData(new[] { 15 }, frameDuration: 0.3f, isLooping: false));
            animationFactory.Add("punch", new SpriteSheetAnimationData(new[] { 26 }, frameDuration: 0.3f, isLooping: false));
            animationFactory.Add("cool", new SpriteSheetAnimationData(new[] { 17 }, frameDuration: 0.3f, isLooping: false));
            entity.Attach(new AnimatedSprite(animationFactory, "idle"));
            entity.Attach(new Transform2(position, 0, Vector2.One * 4));
            entity.Attach(new Body {
                Position = position, Size = new Vector2(32, 64), BodyType = BodyType.Dynamic
            });
            entity.Attach(new Player());
            return(entity);
        }