public void Initialize(Enemy enemy, Player player, Texture2D barrierTexture, Texture2D collectableTexture, Level level) { this.enemy = enemy; this.player = player; this.barrierTexture = barrierTexture; this.collectableTexture = collectableTexture; this.level = level; enemyChar = 5; playerChar = 5; GameState = STATE.Connecting; connection = new HubConnection("http://localhost:9685"); //connection = new HubConnection("http://2dgameserver.azurewebsites.net/"); proxy = connection.CreateHubProxy("GameHub"); ServicePointManager.DefaultConnectionLimit = 10; //connection.Received += Connection_Received; Action<float, float> EnemyPosReceived = received_enemy_position; proxy.On("sendPosition", EnemyPosReceived); Action EnemyActiveReceived = received_enemy_active; proxy.On("sendActive", EnemyActiveReceived); Action<int> enemyShoot = received_enemy_shoot; proxy.On("sendShoot", enemyShoot); Action<List<Vector2>, List<int>> getCollectables = received_collectables; proxy.On("sendCollectables", getCollectables); Action<List<Vector2>, List<int>> getBarriers = received_barriers; proxy.On("sendBarriers", getBarriers); Action<float, int, int, float, int> enemyVariables = received_enemy_variables; proxy.On("sendVariables", enemyVariables); Action<int> playerConnecteds = conected_players; proxy.On("playerConnecteds", playerConnecteds); Action<int> otherPlayerChar = received_enemy_char; proxy.On("otherPlayerChar", otherPlayerChar); Console.WriteLine("SERVER: Waiting for connection"); try { connection.Start().Wait(); } catch (Exception ex) { Console.WriteLine(ex); } if (connection.State == ConnectionState.Connected) { Console.WriteLine("--SERVER: CONNECTED--"); } }
public override void Initialize(List<Texture2D> charactersTexture, GraphicsDevice graphicsDevice, ConnectionTest con, Enemy enemy, int playerChar) { character = new Character(); character.Initialize(charactersTexture, playerChar, graphicsDevice); Position = new Vector2(graphicsDevice.Viewport.TitleSafeArea.X + character.Width / 2, graphicsDevice.Viewport.TitleSafeArea.Y + character.Height / 2 + graphicsDevice.Viewport.TitleSafeArea.Height / 2); previousPosition = Position; Active = true; shootDirection = 0; Health = character.Health; //Init projectile projectileTexture = charactersTexture.ElementAt(0); projectiles = new List<Projectile>(); this.enemy = enemy; oldState = Keyboard.GetState(); base.Initialize(charactersTexture, graphicsDevice, con, enemy, playerChar); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here bgColor = new Color(0, 167, 254); //State of the game. GameState = STATE.InitialMenu; playerChar = 0; //Create the two players player = new Player(); enemy = new Enemy(); level = new Level(); //Create the menu initMenu = new InitialMenu(); charMenu = new CharacterSelection(); waitingMenu = new WaitingPlayersMenu(); //List for barriers; Helpers for spawning new barriers each .5 seconds barriers = new List<Barrier>(); previousBarrierSpawnTime = TimeSpan.Zero; barrierSpawnTime = TimeSpan.FromSeconds(.5f); //Barreir position bPo = new Vector2(8, 8); //Random number for the position of the new barriers (not using now) random = new Random(); //New camera object _camera = new Camera(GraphicsDevice.Viewport); //Create a connection with the server (actual: localhost) con = new ConnectionTest(); base.Initialize(); }
// Initialize for Player public virtual void Initialize(List<Texture2D> charactersTexture, GraphicsDevice graphicsDevice, ConnectionTest con, Enemy enemy, int playerChar) { this.graphicsDevice = graphicsDevice; this.con = con; this.score = 0; }