//Character attributes public BasicGroundEnemy(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, //GameObject attributes WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, //PhysicalObject attributes double runSpeed, double maxSpeed) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed) { Stompable = true; }
//Just pass on the constructor stuff to base public Character(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, double runSpeed, double maxSpeed) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons) { CurrentSprite.PlayAnimation("stand", true); MaxSpeed = maxSpeed; RunSpeed = runSpeed; }
public PhysicalObject(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons) : base(game, position, velocity, sprites, defaultSprite, controller, boundingPolygons) { this.worldPhysics = worldPhysics; this.objectPhysics = objectPhysics; this.friction = objectPhysics.Friction*worldPhysics.GroundFrictionFactor; inAirTimer.Start(); }
public Player(Game game, Vector position, Vector velocity, Dictionary<string, Sprite> sprites, string defaultSprite, IController controller, //GameObject attributes WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> boundingPolygons, //PhysicalObject attributes double runSpeed, double maxSpeed, //Character attributes PlayerState state) : base(game, position, velocity, sprites, defaultSprite, controller, worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed) { oldFriction = objectPhysics.Friction; PlayerState = state; invincibleTimer.Start(); }
public Mushroom(Game game, Vector position, Dictionary<string, Sprite> sprites, string defaultSprite, WorldPhysics worldPhysics, ObjectPhysics objectPhysics, Dictionary<string, BoundingPolygon> polygons, ItemType itemType) : base(game, position, new Vector(0,0), sprites, defaultSprite, new DumbGroundAI(), worldPhysics, objectPhysics, polygons) { CurrentSprite.PlayAnimation(Sprite.DEFAULT_ANIMATION, true); MushroomType = itemType; }
public GameObject Spawn(string objectName, Vector position, Vector velocity, WorldPhysics worldPhysics) { ObjectDescriptor obj = game.Resources.GetObjectDescriptor(objectName); Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>(); foreach (var s in obj.Sprites) { SpriteDescriptor spriteDesc = game.Resources.GetSpriteDescriptor(s.Value); sprites[s.Key] = new Sprite(spriteDesc, game.Resources); sprites[s.Key].PlayAnimation(spriteDesc.DefaultAnimation, false); } //Sprite sprites = (string.IsNullOrEmpty(obj.Sprite) ? null : new Sprite(game.Resources.GetSpriteDescriptor(obj.Sprite), game.Resources)); ObjectPhysics objectPhysics = ObjectPhysics.DefaultObjectPhysics; double runSpeed = double.PositiveInfinity, maxSpeed = double.PositiveInfinity; //Get any physical attributes for this object objectPhysics.Elasticity = TryGetDoubleProperty(obj, "elasticity"); objectPhysics.Friction = TryGetDoubleProperty(obj, "friction"); runSpeed = TryGetDoubleProperty(obj, "run-speed"); maxSpeed = TryGetDoubleProperty(obj, "max-speed"); //Clone the bounding polygon dictionary Dictionary<string, BoundingPolygon> boundingPolygons = new Dictionary<string, BoundingPolygon>(); foreach (var key in obj.BoundingPolygons.Keys) { boundingPolygons[key] = (BoundingPolygon)obj.BoundingPolygons[key].Clone(); } switch (obj.Type) { case "player": return new Player(game, position, velocity, sprites, obj.DefaultSprite, new PlayerController(game.Input), worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed, state.PlayerState); //return new Player(position, velocity, sprite, game.Display.Renderer, new PlayerController(game.Input), worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed, state.PlayerState); case "enemy": switch (obj.Name) { case "goomba": return new BasicGroundEnemy(game, position, velocity, sprites, obj.DefaultSprite, new DumbGroundAI(), worldPhysics, objectPhysics, boundingPolygons, runSpeed, maxSpeed); default: Log.Write("Unknown enemy object name: " + obj.Name, Log.WARNING); break; } break; case "coin": return new Coin(game, position, sprites, obj.DefaultSprite, boundingPolygons); case "mushroom": Mushroom.ItemType itemType = Mushroom.ItemType.RedMushroom; switch (obj.Name) { case "mushroom-red": itemType = Mushroom.ItemType.RedMushroom; break; case "mushroom-green": itemType = Mushroom.ItemType.GreenMushroom; break; } return new Mushroom(game, position, sprites, obj.DefaultSprite, worldPhysics, objectPhysics, boundingPolygons, itemType); default: Log.Write("Unknown object type: " + obj.Type, Log.WARNING); break; } return null; }