private void OnMouseExit() { //prepare to shut it down! glowState = GlowState.shuttingOff; currentTime = stopGlowTime * currentInterpolationFactor; }
private void OnMouseOver() { //prepare to light it up! glowState = GlowState.initializing; currentTime = startGlowTime * currentInterpolationFactor; }
private void Update() { if (glowState == GlowState.initializing) { currentTime += Time.deltaTime; currentInterpolationFactor = currentTime / startGlowTime; material.SetColor("_EmissionColor", Color.Lerp(Color.black, glowColor, currentInterpolationFactor)); if (currentInterpolationFactor >= 1f) { glowState = GlowState.idle; currentInterpolationFactor = 1f; } } else if (glowState == GlowState.shuttingOff) { currentTime -= Time.deltaTime; currentInterpolationFactor = currentTime / stopGlowTime; material.SetColor("_EmissionColor", Color.Lerp(Color.black, glowColor, currentInterpolationFactor)); if (currentInterpolationFactor <= 0f) { glowState = GlowState.idle; currentInterpolationFactor = 0f; } } }
public void aaUpdate() { if (RythmController.s.current_step == RythmController.s.step_glow_in && my_state != GlowState.FadeIn) { mySprite.color = new Color(1, 1, 1, my_fade_out_value); mySprite.DOFade(1f, GD.s.GlowInTime); my_state = GlowState.FadeIn; //Debug.Log("(( FLOOR GLOW IN! " + Time.time); } else if (RythmController.s.current_step == RythmController.s.step_glow_static && my_state != GlowState.Static) { my_state = GlowState.Static; //Debug.Log("(( FLOOR GLOW STATIC! " + Time.time); } else if (RythmController.s.current_step == RythmController.s.step_glow_out && my_state != GlowState.FadeOut) { mySprite.color = new Color(1, 1, 1, 1f); mySprite.DOFade(my_fade_out_value, GD.s.GlowOutTime); my_state = GlowState.FadeOut; //Debug.Log("(( FLOOR GLOW OUT " + Time.time); } }
public void FadeOut() { mySprite.color = new Color(1, 1, 1, 1f); mySprite.DOFade(my_fade_out_value, GD.s.GlowOutTime); my_state = GlowState.FadeOut; }
// Update is called once per frame public void FadeIn() { mySprite.color = new Color(1, 1, 1, my_fade_out_value); mySprite.DOFade(1f, GD.s.GlowInTime); my_state = GlowState.FadeIn; }
/// <summary> /// Figure out what color and intensity the border glow should be, /// based on changes to the game's total cost (frac). /// </summary> /// <param name="frac"></param> private void SetBorderGlowColor(float frac) { float maxIntensity = 1.0f; if (lastFrac >= 0) { if (lastFrac < frac) { /// climbing /// color = red borderIntensityGoal = maxIntensity; borderColorGoal = new Vector3(1.0f, 0.0f, 0.0f); state = GlowState.Climbing; } else if (lastFrac > frac) { /// falling /// color = green /// intensity climbs quickly borderIntensityGoal = maxIntensity; borderColorGoal = new Vector3(0.0f, 1.0f, 0.0f); state = GlowState.Climbing; } lastFrac = frac; } else { lastFrac = frac; state = GlowState.Idle; } float climbRate = maxIntensity / 0.2f; float fallRate = maxIntensity / 0.55f; switch (state) { case GlowState.Climbing: borderIntensity = InterpToward(borderIntensity, borderIntensityGoal, climbRate); if (borderIntensity == borderIntensityGoal) { state = GlowState.Holding; holdTimer = 0.0f; } break; case GlowState.Holding: holdTimer += Time.WallClockFrameSeconds; float holdTime = 0.15f; if (holdTimer >= holdTime) { state = GlowState.Falling; borderIntensityGoal = 0.0f; } break; case GlowState.Falling: borderIntensity = InterpToward(borderIntensity, borderIntensityGoal, fallRate); if (borderIntensity == borderIntensityGoal) { state = GlowState.Idle; } break; case GlowState.Idle: break; } ; float colorRate = 1.0f / 0.1f; borderColor = InterpToward(borderColor, borderColorGoal, colorRate); }