public void Setup() { // Add the dragon _dragon = new Dragon(_content, _spriteBatch, _gameInput) { Position = new Vector2(WorldWidth / 2f, WorldHeight - 16 - 16) }; // Setup walls _walls.Add(new Wall(_content, _spriteBatch, new Rectangle(0, 0, WorldWidth, 16))); _walls.Add(new Wall(_content, _spriteBatch, new Rectangle(0, 0, 16, WorldHeight))); _walls.Add(new Wall(_content, _spriteBatch, new Rectangle(0, WorldHeight - 16, WorldWidth, 16))); _walls.Add(new Wall(_content, _spriteBatch, new Rectangle(WorldWidth - 16, 0, 16, WorldHeight))); CreateBackgroudTexture(); SetupCamera(); }
public static Bubble CreateBubble(GameWorld gameWorld, Dragon dragon) { var bubbleType = Rnd.Next(0, 6); Bubble bubble; float startImpulse = 20; switch (bubbleType) { case 5: bubble = new RockBubble(gameWorld); startImpulse = 60; break; case 4: case 3: bubble = new ExplodingBubble(gameWorld); break; case 2: case 1: case 0: bubble = new Bubble(gameWorld); break; default: throw new InvalidOperationException("Bubble type: " + bubbleType); } bubble.Position = dragon.Position; if (dragon.LookDirection == LookDirection.Right) { bubble.Position += new Vector2(Dragon.Width, 0); bubble.Body.ApplyLinearImpulse(new Vector2(startImpulse, 0)); } else { bubble.Position -= new Vector2(Dragon.Width, 0); bubble.Body.ApplyLinearImpulse(new Vector2(-startImpulse, 0)); } return(bubble); }