void SpawnPlayerRegistrationComponents(int playerID, GameObject spawnedPlayerRegistrationPuck, NetworkMode networkMode, int localID = -1) { CharacterSelector selector = spawnedPlayerRegistrationPuck.AddComponent <CharacterSelector>(); InputToAction action = spawnedPlayerRegistrationPuck.GetComponent <InputToAction>(); action.rotationEnabled = false; action.movementEnabled = true; Color playerColor; if (registeredPlayers.ContainsKey(playerID)) { playerColor = registeredPlayers[playerID].color; } else if (localID != -1) { playerColor = possiblePlayers[localID].color; } else { playerColor = HSVColor.HSVToRGB(Random.value, 1, 1); } registeredPlayers[playerID] = new Registration(selector, null, RegistrationState.REGISTERING, localID, networkMode, this); selector.gameObject.GetComponentInChildren <Image>().color = selector.gameObject.GetComponent <ParticleSystem>().startColor = registeredPlayers[playerID].color = playerColor; selector.registration = registeredPlayers[playerID]; }
void setHueSprite(float oldHue, float newHue, Sprite sprite) { Rect bounds = sprite.rect; Texture2D tex = sprite.texture; for (int y = Mathf.RoundToInt(bounds.yMin); y < Mathf.RoundToInt(bounds.yMax); y++) { int xMin = Mathf.RoundToInt(bounds.xMin), xMax = Mathf.RoundToInt(bounds.xMax); for (int x = xMin; x < xMax; x++) { Color temp = tex.GetPixel(x, y); float hue, saturation, value; HSVColor.RGBToHSV(temp, out hue, out saturation, out value); temp = HSVColor.HSVToRGB((hue + (newHue - oldHue) + 1) % 1, saturation, value, temp.a); tex.SetPixel(x, y, temp); } } tex.Apply(); }
private Color GetNewBuildingColor() { HSVColor color = new HSVColor(hue, Random.Range(0.4f, 0.6f), Random.Range(0.7f, 0.9f)); return color.HSVToRGB(); }
static Color PerlinColor(Vector2 seed, Vector2 pos) { return(HSVColor.HSVToRGB((Mathf.PerlinNoise(seed.x + pos.x / 17, seed.y + pos.y / 17) + seed.y / 100) % 1, 0.75f, 1)); }
Color getColor(float myHue) { float healthFraction = health / maxHealth; return(HSVColor.HSVToRGB(myHue, healthFraction, 0.5f * healthFraction + 0.5f)); }