/// <summary> /// Calculates the current color, using transition colors. /// </summary> /// <param name="fraction">Fraction between 0.0 and 1.0</param> /// <returns>The current color</returns> public Color4 GetCurrentColor(float fraction) { if(enableColorTransitions) { TransitionColor low = new TransitionColor(0f, baseColor); TransitionColor high = new TransitionColor(1f, baseColor); foreach(TransitionColor t in transitionColors) { if(t.fraction >= low.fraction && t.fraction <= fraction) { low.fraction = t.fraction; low = t; } if(t.fraction <= high.fraction && t.fraction >= fraction) { high.fraction = t.fraction; high = t; } } float highDelta = (fraction - low.fraction) / (high.fraction - low.fraction); float lowDelta = (high.fraction - fraction) / (high.fraction - low.fraction); return new Color4( (low.color.R * lowDelta) + (high.color.R * (highDelta)), (low.color.G * lowDelta) + (high.color.G * (highDelta)), (low.color.B * lowDelta) + (high.color.B * (highDelta)), (low.color.A * lowDelta) + (high.color.A * (highDelta))); } return baseColor; }
public void ColorArrow(TransitionColor t) { if (hasDuplicate) return; switch(t) { case TransitionColor.blue: myTransitionColor = TransitionColor.blue; arrowRenderer.color = new Color(.0f, 0.3f, .9f, 1f); break; case TransitionColor.yellow: myTransitionColor = TransitionColor.yellow; arrowRenderer.color = new Color(.8f, 0.7f, .3f, 1f); break; } }
public void Initialize(State s, State e, TransitionColor t, bool isOffset) { start = s; end = e; myTransitionColor = t; this.isOffset = isOffset; s.myTransitionsFrom.Add(this); e.myTransitionsTo.Add(this); arrowRenderer = this.gameObject.GetComponent ("SpriteRenderer") as SpriteRenderer; ColorArrow (t); this.hasDuplicate = isOffset; UpdateArrow (); }