} // end startlevel // call this once per level to set all the dynamic colors as a function of depth void updateColors() { short i; for (i = 0; i < RogueH.NUMBER_DYNAMIC_COLORS; i++) { //*(dynamicColors[i,0]) = *(dynamicColors[i,1]); ObjectCopier.CopyFrom(dynamicColors[i, 0], dynamicColors[i, 1]); IO.applyColorAverage(dynamicColors[i, 0], dynamicColors[i, 2], (short)Math.Min(100, Math.Max(0, rogue.depthLevel * 100 / RogueH.AMULET_LEVEL))); } }
} // // Highlight the portion indicated by hiliteCharGrid with the hiliteColor at the hiliteStrength -- both latter arguments are optional. public void hiliteGrid(short[][] grid, color hiliteColor, int hiliteStrength) { playerCharacter rogue = RogueMain.GetInstance().getRogue(); short i, j, x, y; color hCol = new color(); short oldRNG = rogue.RNG; rogue.RNG = RNG_COSMETIC; //assureCosmeticRNG; if (hiliteColor != null) { ObjectCopier.CopyFrom(hCol, hiliteColor); } else { ObjectCopier.CopyFrom(hCol, Global.yellow); } IO.GetInstance().bakeColor(hCol); if (hiliteStrength == 0) { hiliteStrength = 75; } for (i = 0; i < DCOLS; i++) { for (j = 0; j < DROWS; j++) { if (grid[i][j] != 0) { x = (short)IO.GetInstance().mapToWindowX(i); y = (short)IO.GetInstance().mapToWindowY(j); displayBuffer[x, y].needsUpdate = true; displayBuffer[x, y].backColorComponents[0] = (char)Random.clamp(displayBuffer[x, y].backColorComponents[0] + hCol.red * hiliteStrength / 100, 0, 100); displayBuffer[x, y].backColorComponents[1] = (char)Random.clamp(displayBuffer[x, y].backColorComponents[1] + hCol.green * hiliteStrength / 100, 0, 100); displayBuffer[x, y].backColorComponents[2] = (char)Random.clamp(displayBuffer[x, y].backColorComponents[2] + hCol.blue * hiliteStrength / 100, 0, 100); displayBuffer[x, y].foreColorComponents[0] = (char)Random.clamp(displayBuffer[x, y].foreColorComponents[0] + hCol.red * hiliteStrength / 100, 0, 100); displayBuffer[x, y].foreColorComponents[1] = (char)Random.clamp(displayBuffer[x, y].foreColorComponents[1] + hCol.green * hiliteStrength / 100, 0, 100); displayBuffer[x, y].foreColorComponents[2] = (char)Random.clamp(displayBuffer[x, y].foreColorComponents[2] + hCol.blue * hiliteStrength / 100, 0, 100); } } } rogue.RNG = oldRNG; //restoreRNG; }
// Call this when the i'th character of msg is COLOR_ESCAPE. // It will return the encoded color, and will advance i past the color escape sequence. public static short decodeMessageColor(char[] msg, short i, color returnColor) { if (msg[i] != (char)RogueH.COLOR_ESCAPE) { Debug.Log("Asked to decode a color escape that didn't exist!"); ObjectCopier.CopyFrom <color>(returnColor, Global.white); // *returnColor = white; } else { i++; ObjectCopier.CopyFrom <color>(returnColor, Global.black); //*returnColor = black; returnColor.red = (short)(msg[i++] - RogueH.COLOR_VALUE_INTERCEPT); returnColor.green = (short)(msg[i++] - RogueH.COLOR_VALUE_INTERCEPT); returnColor.blue = (short)(msg[i++] - RogueH.COLOR_VALUE_INTERCEPT); returnColor.red = (short)Random.clamp(returnColor.red, 0, 100); returnColor.green = (short)Random.clamp(returnColor.green, 0, 100); returnColor.blue = (short)Random.clamp(returnColor.blue, 0, 100); } return(i); }