// updates the global valid move list protected void UpdateValidMoves() { // update all valid moves List <int> ValidMovesWhite = new List <int>(); List <int> ValidMovesBlack = new List <int>(); // iterate through all pieces of the right color for (int idx = 0; idx < GameData.g_CurrentGameState.Length; idx++) { if (GameData.g_CurrentGameState[idx] != null && GameData.g_CurrentGameState[idx].GetColor() == PColor.White) { // if it's the right color add it's attacking squares to the list ValidMovesWhite.AddRange(GameData.g_CurrentGameState[idx].GetValidMoves()); } if (GameData.g_CurrentGameState[idx] != null && GameData.g_CurrentGameState[idx].GetColor() == PColor.Black) { // if it's the right color add it's attacking squares to the list ValidMovesBlack.AddRange(GameData.g_CurrentGameState[idx].GetValidMoves()); } } // remove duplicates from the list ValidMovesWhite = Etc.RemoveDuplicatesFromList(ValidMovesWhite); ValidMovesBlack = Etc.RemoveDuplicatesFromList(ValidMovesBlack); // update global list GameData.g_ValidMovesWhite.Clear(); GameData.g_ValidMovesWhite.AddRange(ValidMovesWhite); GameData.g_ValidMovesBlack.Clear(); GameData.g_ValidMovesBlack.AddRange(ValidMovesBlack); }