public AnimationObject(Vector2 pos, Vector2 hitbox, Vector2 velocity, PhysicalAnimation[] animations, float gravity) : base(null, Vector2.Zero, pos, hitbox, velocity, gravity) { this.animations = animations; current_animation_index = 1; SetAnimation(0); }
public void SetAnimation(int index) { if (!untilFinished && !untilTick) { if (index != current_animation_index) { current_animation_index = index; current_animation = animations[index]; current_animation.Play(); CheckHitbox(); } } }
public GameState(ContentManager Content, GraphicsDevice device, Tile[][] map) { this.spriteSheet = Content.Load<Texture2D>("sheet"); this.map = map; global_tick = 0; renderTarget = new RenderTarget2D(device, 196, 196); players = new List<PlayerObject>(); npcs = new List<HealthObject>(); upgrades = new List<PhysicalObject>(); PhysicalAnimation[] animations = new PhysicalAnimation[] { XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/idle.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/crouch.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/running.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/jump.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/idle_doot.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/crouch_doot.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/running_doot.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("playeranimations/jump_doot.xml") }; foreach (PhysicalAnimation ani in animations) ani.Prepare(); doot_ani = XmlSerializerHelper.Deserialize<PhysicalAnimation>("doot.xml"); doot_ani.Prepare(); players.Add(new PlayerObject(new Vector2(8,16), new Vector2(14f / 16f, 32f / 16f), Vector2.Zero, animations)); PhysicalAnimation[] goomba_animations = new PhysicalAnimation[] { XmlSerializerHelper.Deserialize<PhysicalAnimation>("goomba/walk.xml"), XmlSerializerHelper.Deserialize<PhysicalAnimation>("goomba/dead.xml"), }; foreach (PhysicalAnimation ani in goomba_animations) ani.Prepare(); npcs.Add(new Goomba(new Vector2(30, 5), new Vector2(14f / 16f, 16f / 16f), -1, goomba_animations)); npcs.Add(new Goomba(new Vector2(26, 11), new Vector2(14f / 16f, 16f / 16f), 1, goomba_animations)); }
public void SetSyncAnimation(int index) { if (!untilFinished && !untilTick) { if (index != current_animation_index) { int ani_pos = current_animation.Counter; current_animation_index = index; current_animation = animations[index]; current_animation.Play(); //set the new animations counter to the old (to sync it up) current_animation.Counter = ani_pos; CheckHitbox(); } } }
public PlayerObject(Vector2 pos, Vector2 hitbox, Vector2 velocity, PhysicalAnimation[] animations) : base(pos, hitbox, velocity, animations) { cam_Y = pos.Y; }
public HealthObject(Vector2 pos, Vector2 hitbox, Vector2 velocity, PhysicalAnimation[] animations, int health) : base(pos, hitbox, velocity, animations) { this.health = health; }
public Goomba(Vector2 pos, Vector2 hitbox, int direction, PhysicalAnimation[] animations) : base(pos, hitbox, new Vector2(direction * speed, 0), animations, 1) { SetAnimation(walk); }
public DootObject(Vector2 pos, Vector2 hitbox, Vector2 velocity, PhysicalAnimation[] animations) : base(pos, hitbox, velocity, animations) { start_vel = velocity; gravity = 0; }
public void StartAnimation(int index) { if (!untilFinished && !untilTick) { current_animation_index = index; current_animation = animations[index]; current_animation.Play(); } }