void Update() { // Toggle labels if (Input.GetKeyDown(KeyCode.Space)) { textMesh.GetComponent <Renderer>().enabled = !textMesh.GetComponent <Renderer>().enabled; shouldDrawGrid = textMesh.GetComponent <Renderer>().enabled; Shader.SetGlobalFloat("_LightRatio", textMesh.GetComponent <Renderer>().enabled ? 0.5f : 1f); } if (Input.anyKey) { UpdateText(); } textColorRatio = textColorRatio + Time.deltaTime * 5f; SetColor(Color.Lerp(textColor, textColorNext, Mathf.Clamp(textColorRatio, 0f, 1f))); if (textColorRatio > 1f) { textColorRatio = 0f; textColor = textColorNext; textColorHue = (textColorHue + 10f) % 360f; textColorNext = ColorHSV.GetColor(textColorHue, 1, 1); } }
public Bonus(Vector2 pos) : base(pos) { // sprite.GetComponent<Renderer>().material.mainTexture = TextureLoader.GetRandomBonus(); switch (Random.Range(0, 3)) { case 0: { color = ColorHSV.GetColor(Random.Range(340f, 380f) % 360f, 1f, 1f); spriteMaterial.color = color; spriteMaterial.mainTexture = TextureLoader.GetHeart(); type = BonusType.Heart; break; } case 1: { color = ColorHSV.GetColor(Random.Range(80f, 140f), 1f, 1f); spriteMaterial.color = color; spriteMaterial.mainTexture = TextureLoader.GetClover(); type = BonusType.Clover; break; } case 2: { color = ColorHSV.GetColor(Random.Range(0f, 140f), 1f, 1f); spriteMaterial.color = color; spriteMaterial.mainTexture = TextureLoader.GetApple(); type = BonusType.Apple; break; } } size = Random.Range(Grid.cellSize, Grid.cellSize * 2f); collisionRadius = size / 4f * Game.height; }
public void UpdateRainbow() { textColorRatio = textColorRatio + Time.deltaTime * 2f; SetColor(Color.Lerp(textColor, textColorNext, Mathf.Clamp(textColorRatio, 0f, 1f))); if (textColorRatio > 1f) { textColorRatio = 0f; textColor = textColorNext; textColorHue = (textColorHue + 30f) % 360f; textColorNext = ColorHSV.GetColor(textColorHue, 1, 1); } }