/* * Assign a color to the player's index in array and dict, * and add increment readyPlayers */ public void selectColor(PLAYER_COLORS color, short index) { selectedColorsDict[color] = true; playersColors[index] = color; readyPlayers++; // quickDebug(); }
/* * Function will deselect the given player's color from array and dictionary. * If it was selected before, * this will mean the player is not ready, and thus decrease the number of ready * players. */ public void removeColor(PLAYER_COLORS color, short index) { // since PLAYER_COLOR.NONE is not in the dictionary, if the sent color // is it, we bail out immediately, knowing it was already Empty if (selectedColorsDict.ContainsKey(color) && selectedColorsDict[color] == true) { readyPlayers--; } playersColors[index] = PLAYER_COLORS.NONE; selectedColorsDict[color] = false; // quickDebug(); }
public void registerPlayerColor(int index, PLAYER_COLORS playerColor) { // playerStruct.index = (short)index; if (!gameInfoManager.ColorIsAlreadyChosen(playerColor)) { if (currenColor != PLAYER_COLORS.NONE) { gameInfoManager.removeColor(currenColor, (short)playerIndex); } gameInfoManager.selectColor(playerColor, (short)playerIndex); setTexture(playerColorsImages[playerColor]); currenColor = playerColor; } else if (playerColor == currenColor) { gameInfoManager.removeColor(currenColor, (short)playerIndex); currenColor = PLAYER_COLORS.NONE; removeAlltextures(); } }
/* * Players need different colors. If a color was already selected by another * player, function will return true. */ public bool ColorIsAlreadyChosen(PLAYER_COLORS color) { // print(selectedColorsDict[color]); return(selectedColorsDict[color]); }
public static void changeMyRendererColor(Renderer renderer, PLAYER_COLORS color) { renderer.sharedMaterial = materialsDict[color]; }
public void setCurrentColor(PLAYER_COLORS color) { currenColor = color; }