public DKTeleporter() { BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(150, 150), Dimensions = dimensions, Type = BodyType.Static }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Interactive; filter.Mask = (byte)Filter.Categories.Player; bodyDef.Filter = filter; Body = PhysicsWorld.Instance.CreateBody(bodyDef); Body.UserData = this; }
public IBody CreateBody(BodyDefinition bodyDef) { IBody body = BodyFromDef(bodyDef); bodies.Add(body); if (body.Type == BodyType.Dynamic) { collisionEngine.DynamicBodies.Add(body); } else { collisionEngine.NonDynamicBodies.Add(body); } return(body); }
public LevelBlock(Vector2 position, Vector2 size) { sprite = ItemSpriteFactory.Instance.CreateLevelBlockSprite(); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = position, Dimensions = sprite.Dimensions }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.LevelBlock; filter.Mask = (byte)Filter.Categories.Player + (byte)Filter.Categories.Enemy + (byte)Filter.Categories.Projectile + (byte)Filter.Categories.Throwable; bodyDef.Filter = filter; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; }
public DKPlayerBarrel() { state = new DKPlayerBarrelIdleState(this); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(725, 150), Dimensions = sprite.Dimensions, Type = BodyType.Kinematic }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Collectible; filter.Mask = (byte)Filter.Categories.Player; bodyDef.Filter = filter; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; }
public DKThrownBarrel() { state = new DKThrownBarrelRollState(this); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(575, 150), Type = BodyType.Dynamic, Dimensions = sprite.Dimensions }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Throwable; filter.Mask = (byte)Filter.Categories.Enemy + (byte)Filter.Categories.Projectile + (byte)Filter.Categories.LevelBlock; bodyDef.Filter = filter; bodyDef.Mass = 1; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; }
public DKExitSign() { sprite = ItemSpriteFactory.Instance.CreateDKBalloonSprite(); state = new DKExitSignIdleState(this); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(150, 150), Dimensions = sprite.Dimensions }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Collectible; filter.Mask = (byte)Filter.Categories.Player; bodyDef.Filter = filter; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; }
public DKKongTileG() { kongTileLetter = DKKongTileType.G; sprite = ItemSpriteFactory.Instance.CreateDKKongTileSprite(kongTileLetter); state = new DKKongTileIdleState(this); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(225, 150), Dimensions = sprite.Dimensions, Type = BodyType.Kinematic }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Collectible; filter.Mask = (byte)Filter.Categories.Player; bodyDef.Filter = filter; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; }
public DKRambiCrate() { state = new DKRambiCrateIdleState(this); Vector2 rambiBB = new Vector2(41, 40); //For sprint 3 Rambi crate bounding box is based on open crate, causes collisions outside its sprite. BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(650, 150), Dimensions = rambiBB }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Interactive; filter.Mask = (byte)Filter.Categories.Player; bodyDef.Filter = filter; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; }
public Rambi() { sprite = ItemSpriteFactory.Instance.CreateDKRambiIdleSprite(); state = new RambiIdleState(this); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(150, 150), Dimensions = sprite.Dimensions }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Interactive; filter.Mask = (byte)Filter.Categories.Player; bodyDef.Filter = filter; body = PhysicsWorld.Instance.CreateBody(bodyDef); //body.Dimensions = sprite.Dimensions; body.UserData = this; }
public Necky() { sprite = EnemySpriteFactory.Instance.CreateDKNeckySprite(); BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(425, 300), Type = BodyType.Dynamic, Dimensions = sprite.Dimensions }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Enemy; filter.Mask = (byte)Filter.Categories.Player + (byte)Filter.Categories.LevelBlock + (byte)Filter.Categories.Throwable; bodyDef.Filter = filter; bodyDef.Mass = MASS; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.UserData = this; state = new EnemyIdleState(this); PhysicsWorld.Instance.OnContact += OnContact; }
public Player() { facingRight = true; BodyDefinition bodyDef = new BodyDefinition() { BottomCenter = new Vector2(150, 300), Type = BodyType.Dynamic, Dimensions = Vector2.Zero }; Filter filter = new Filter(); filter.Category = (byte)Filter.Categories.Player; filter.Mask = (byte)Filter.Categories.Enemy + (byte)Filter.Categories.Projectile + (byte)Filter.Categories.LevelBlock + (byte)Filter.Categories.Collectible + (byte)Filter.Categories.Interactive; bodyDef.Filter = filter; bodyDef.Mass = MASS; body = PhysicsWorld.Instance.CreateBody(bodyDef); body.LinearDamping = LINEAR_DAMPING; body.UserData = this; PhysicsWorld.Instance.OnContact += OnContact; state = new DKIdleState(this); }
private IBody BodyFromDef(BodyDefinition bodyDef) { Body body = new Body(bodyDef.BottomCenter, bodyDef.Type); body.Dimensions = bodyDef.Dimensions; body.Filter = bodyDef.Filter; if (body.Type == BodyType.Dynamic) { body.Mass = bodyDef.Mass; body.InverseMass = 1.0f / bodyDef.Mass; } else if (body.Type == BodyType.Static) { body.InverseMass = 0; } else { body.Mass = 0; } return(body); }