/* Update returns null until all players have readied. When all players * are ready, it returns a list containing their custom Input_Handlers */ public void Update(GameTime gameTime) { // update the input states kb = Keyboard.GetState(); //gp = GamePad.GetState(); // Count how many players are ready int count = 0; foreach (int r in ready) { if (r == 1) { count++; } } for (int i = 0; i < 4; i++) { if (inputs[i].isActive) { loadouts[i].Update(gameTime); } } // Is everyone ready to start? if (totalPlayers != 0 && count == totalPlayers) { equipment = new Item[4][];//new Item[4], new Item[4], new Item[4], new Item[4] }; //Contents of arrays are passed by value, unlike the array itself. so we must pass back the values for (int i = 0; i < 4; i++) { if (inputs[i].isActive) { equipment[i] = new Item[4]; for (int j = 0; j < 4; j++) { equipment[i][j] = loadouts[i].equipment[j]; // Let the manager know we're done here. //if(inputs[i].isActive) //state_man.equipment[i, j] = loadouts[i].equipment[j]; } } } state_man.OnStateComplete("LoadOut"); for (int i = 0; i < ready.Length; i++) { ready[i] = -1; } } }
// Handles input from first player. public void HandleInput(int playerIndex, KeyPressed key) { // If you select accept, tell the manager we're done. if (key == KeyPressed.Attack1 && menu.entries[menu.index] == "Accept") { manager.OnStateComplete("Settings"); } else { // let the menu handle it menu.ChangeIndex(playerIndex, key); } }
/* Update returns null until all players have readied. When all players * are ready, it returns a list containing their custom Input_Handlers */ public override void Update(GameTime gameTime) { if (loadTimer > 0) { loadTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds; } // Count how many players are ready int count = 0; foreach (bool r in ready) { if (r) { count++; } } // Is everyone ready to start? if (totalPlayers != 0 && count == totalPlayers) { // Get the colors for (int i = 0; i < 4; i++) { if (playerAdded[i]) { playerColors[i] = menus[i].selection.color; inputs[i].isActive = true; } else { playerColors[i] = Color.Transparent; } } manager.OnStateComplete("PlayerSelect"); /*if (OnReady != null) * { * OnReady(playerColors); * }*/ } }