private void CreateEntities() { // TODO: This should be passed in from the lobby, most likely just have the Player object contain the color // These would _normally_ be CVars, but this will be okay for now because it will give us an excuse to move // these to the lobby menu. Color[] colors = new Color[] { Color.White, Color.Blue, Color.Orange, Color.Magenta }; for (int p = 0; p < Players.Length; p++) { SpawnPlayer(Players[p], ComputePlayerShipSpawnPosition(p, Players.Length), colors[p]); } EdgeEntity.Create(SharedState.Engine, new Vector2(0, CVars.Get <float>("play_field_height") / 2), new Vector2(CVars.Get <float>("play_field_width"), 5), new Vector2(0, -1)); EdgeEntity.Create(SharedState.Engine, new Vector2(-CVars.Get <float>("play_field_width") / 2, 0), new Vector2(5, CVars.Get <float>("play_field_height")), new Vector2(1, 0)); EdgeEntity.Create(SharedState.Engine, new Vector2(0, -CVars.Get <float>("play_field_height") / 2), new Vector2(CVars.Get <float>("play_field_width"), 5), new Vector2(0, 1)); EdgeEntity.Create(SharedState.Engine, new Vector2(CVars.Get <float>("play_field_width") / 2, 0), new Vector2(5, CVars.Get <float>("play_field_height")), new Vector2(-1, 0)); }
void CreateEntities() { Entity playerShipEntity = PlayerShipEntity.Create(Engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PLAYER_SHIP), new Vector2(0, 0)); Entity playerShieldEntity = PlayerShieldEntity.Create(Engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PLAYER_SHIELD), playerShipEntity); playerShipEntity.GetComponent <PlayerShipComponent>().shipShield = playerShieldEntity; playerShieldEntity.AddComponent(new PlayerComponent(Player)); Entity topEdge = EdgeEntity.Create(Engine, new Vector2(0, Constants.Global.WINDOW_HEIGHT / 2), new Vector2(Constants.Global.WINDOW_WIDTH, 1), new Vector2(0, -1)); Entity leftEdge = EdgeEntity.Create(Engine, new Vector2(-Constants.Global.WINDOW_WIDTH / 2, 0), new Vector2(1, Constants.Global.WINDOW_HEIGHT), new Vector2(1, 0)); Entity bottomEdge = EdgeEntity.Create(Engine, new Vector2(0, -Constants.Global.WINDOW_HEIGHT / 2), new Vector2(Constants.Global.WINDOW_WIDTH, 1), new Vector2(0, 1)); Entity rightEdge = EdgeEntity.Create(Engine, new Vector2(Constants.Global.WINDOW_WIDTH / 2, 0), new Vector2(1, Constants.Global.WINDOW_HEIGHT), new Vector2(-1, 0)); }
public AIInputMethod() { engine = new Engine(); ballSystem = new BallMovementSystem(engine); ball = engine.CreateEntity(); ballTransform = new TransformComponent(); ballComponent = new BallComponent(0); ball.AddComponent(ballTransform); ball.AddComponent(ballComponent); // Edges EdgeEntity.Create(engine, null, new Vector2(0, Constants.Pong.PLAYFIELD_HEIGHT / 2), new Vector2(0, -1)); EdgeEntity.Create(engine, null, new Vector2(0, -Constants.Pong.PLAYFIELD_HEIGHT / 2), new Vector2(0, 1)); }
void CreateEntities() { EdgeEntity.Create(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_EDGE), new Vector2(0, Constants.Pong.PLAYFIELD_HEIGHT / 2), new Vector2(0, -1)); // Top edge points down EdgeEntity.Create(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_EDGE), new Vector2(0, -Constants.Pong.PLAYFIELD_HEIGHT / 2), new Vector2(0, 1)); // Bottom edge points up // Field background FieldBackgroundEntity.Create(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_FIELD_BACKGROUND)); // Player 1 goal GoalEntity.Create(_engine, _player1, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_GOAL), new Vector2(-Constants.Pong.PLAYFIELD_WIDTH / 2 + Constants.Pong.GOAL_WIDTH / 2, 0)); // Player 2 goal GoalEntity.Create(_engine, _player2, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_GOAL), new Vector2(Constants.Pong.PLAYFIELD_WIDTH / 2 - Constants.Pong.GOAL_WIDTH / 2, 0)); Entity paddle1 = PaddleEntity.Create(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_PADDLE), new Vector2(-Constants.Pong.PADDLE_STARTING_X, Constants.Pong.PADDLE_STARTING_Y), new Vector2(1, 0)); // Left paddle normal points right Entity paddle2 = PaddleEntity.Create(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_PADDLE), new Vector2(Constants.Pong.PADDLE_STARTING_X, Constants.Pong.PADDLE_STARTING_Y), new Vector2(-1, 0)); // Right paddle normal points left paddle1.AddComponent(new PlayerComponent(_player1)); paddle2.AddComponent(new PlayerComponent(_player2)); if (Player1 is AIPlayer) { paddle1.AddComponent(new AIComponent(Player1 as AIPlayer)); } if (Player2 is AIPlayer) { paddle2.AddComponent(new AIComponent(Player2 as AIPlayer)); } // Lives LivesEntity.Create(_engine, Content.Load <BitmapFont>(Constants.Resources.FONT_PONG_LIVES), new Vector2(Constants.Pong.LIVES_LEFT_POSITION_X, Constants.Pong.LIVES_POSITION_Y), _player1, Constants.Pong.LIVES_COUNT); BallEntity.CreateWithoutBehavior(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_BALL), new Vector2(Constants.Pong.LIVES_ICON_LEFT_POSITION_X, Constants.Pong.LIVES_POSITION_Y), 2); LivesEntity.Create(_engine, Content.Load <BitmapFont>(Constants.Resources.FONT_PONG_LIVES), new Vector2(Constants.Pong.LIVES_RIGHT_POSITION_X, Constants.Pong.LIVES_POSITION_Y), _player2, Constants.Pong.LIVES_COUNT); BallEntity.CreateWithoutBehavior(_engine, Content.Load <Texture2D>(Constants.Resources.TEXTURE_PONG_BALL), new Vector2(Constants.Pong.LIVES_ICON_RIGHT_POSITION_X, Constants.Pong.LIVES_POSITION_Y), 2); }