/// <summary> /// Starts a new game session, setting all game states to initial values. /// </summary> public virtual void Start() { Ball b = ballManager.CreateDefaultBall(new Vector2(240, 400), new Vector2(200, 200)); bottomPaddle.Texture = defaultBottomPaddleTexture; bottomPaddle.Position = new Vector2(((screenRightBound - screenLeftBound) / 2) - bottomPaddle.Width / 2, screenBottomBound - (bottomPaddle.Height + paddleTouchBufferSize)); bottomPaddle.UpdateShape(); topPaddle.Texture = defaultTopPaddleTexture; topPaddle.Position = new Vector2(((screenRightBound - screenLeftBound) / 2) - topPaddle.Width / 2, 0); topPaddle.UpdateShape(); DefaultWall w1 = new DefaultWall(); DefaultWall w2 = new DefaultWall(); w1.shape = new PongClasses.PongShapes.Rectangle( new PongClasses.PongShapes.Coordinate(screenLeftBound, screenTopBound), 1, screenBottomBound - screenTopBound, Math.PI); w2.shape = new PongClasses.PongShapes.Rectangle( new PongClasses.PongShapes.Coordinate(screenRightBound, screenTopBound), 1, screenBottomBound - screenTopBound, 0); CollisionManager.AddObject("Wall", w1); CollisionManager.AddObject("Wall", w2); CollisionManager.AddObject("Paddle", bottomPaddle); CollisionManager.AddObject("Paddle", topPaddle); RegisterCallbackFunctions(); }
/// <summary> /// Converts characters to their corresponding Entities. /// </summary> /// <param name="character">The character to convert.</param> /// <returns>The corresponding Entity.</returns> private Entity ConvertTiles(char character) { switch (character) { case '-': case '$': case '%': DefaultPlatform defaultPlatform = new DefaultPlatform(); if(character == '$') { defaultPlatform.Velocity.X = 100F; } else if(character == '%') { defaultPlatform.Velocity.X = -100F; } return defaultPlatform; case '+': case '&': case '(': HotPlatform hotPlatform = new HotPlatform(); if (character == '&') { hotPlatform.Velocity.X = 100F; } else if (character == '(') { hotPlatform.Velocity.X = -100F; } return hotPlatform; case '@': case '!': case '~': IcePlatform icePlatform = new IcePlatform(); if (character == '!') { icePlatform.Velocity.X = 100F; } else if (character == '~') { icePlatform.Velocity.X = -100F; } return icePlatform; case 'X': return new GoalTile(); case 'W': return new WaterTile(); case '1': return new PlayerCreature(); case '#': case '/': case '>': DefaultWall defaultWall = new DefaultWall(); if (character == '/') { defaultWall.Velocity.X = 100F; } else if (character == '>') { defaultWall.Velocity.X = -100F; } return defaultWall; case '^': case '<': case '\\': HotWall hotWall = new HotWall(); if (character == '<') { hotWall.Velocity.X = 100F; } else if (character == '\\') { hotWall.Velocity.X = -100F; } return hotWall; case '*': case '[': case ']': IceWall iceWall = new IceWall(); if (character == '[') { iceWall.Velocity.X = 100F; } else if (character == ']') { iceWall.Velocity.X = -100F; } return iceWall; case 'T': return new TurtleCreature(); case 'R': RocketCreature rocketLeft = new RocketCreature(); rocketLeft.MoveSpeed = new Vector2(-600F, 0F); return rocketLeft; case 'r': RocketCreature rocketRight = new RocketCreature(); rocketRight.MoveSpeed = new Vector2(600F, 0F); return rocketRight; case 'S': return new SparkyCreature(); case 'A': return new WildFlame(); case 'B': return new StalkerFlame(); case 'C': return new FlameCreature(); case 'k': return new ShieldTile(); case 'z': return new BananaTile(); default: TileEntity tile = new TileEntity(); tile.CanCollide = false; return tile; } }