Pathfinding.RVO.Sampled.Agent.Rainbow C# (CSharp) Method

Rainbow() static private method

static private Rainbow ( float v ) : Color
v float
return UnityEngine.Color
		static Color Rainbow (float v) {
			Color c = new Color(v, 0, 0);

			if (c.r > 1) { c.g = c.r - 1; c.r = 1; }
			if (c.g > 1) { c.b = c.g - 1; c.g = 1; }
			return c;
		}

Usage Example

Beispiel #1
0
        private Vector2 Trace(Agent.VO[] vos, int voCount, Vector2 p, float cutoff, out float score)
        {
            score = 0f;
            float   stepScale = this.simulator.stepScale;
            float   num       = float.PositiveInfinity;
            Vector2 result    = p;

            for (int i = 0; i < 50; i++)
            {
                float num2 = 1f - (float)i / 50f;
                num2 *= stepScale;
                Vector2 vector = Vector2.zero;
                float   num3   = 0f;
                for (int j = 0; j < voCount; j++)
                {
                    float   num4;
                    Vector2 b = vos[j].Sample(p, out num4);
                    vector += b;
                    if (num4 > num3)
                    {
                        num3 = num4;
                    }
                }
                Vector2 a   = new Vector2(this.desiredVelocity.x, this.desiredVelocity.z) - p;
                float   val = a.magnitude * Agent.DesiredVelocityWeight;
                vector += a * Agent.DesiredVelocityScale;
                num3    = Math.Max(num3, val);
                score   = num3;
                if (score < num)
                {
                    num = score;
                }
                result = p;
                if (score <= cutoff && i > 10)
                {
                    break;
                }
                float sqrMagnitude = vector.sqrMagnitude;
                if (sqrMagnitude > 0f)
                {
                    vector *= num3 / Mathf.Sqrt(sqrMagnitude);
                }
                vector *= num2;
                Vector2 p2 = p;
                p += vector;
                if (this.DebugDraw)
                {
                    UnityEngine.Debug.DrawLine(Agent.To3D(p2) + this.position, Agent.To3D(p) + this.position, Agent.Rainbow(0.1f / score) * new Color(1f, 1f, 1f, 0.2f));
                }
            }
            score = num;
            return(result);
        }
All Usage Examples Of Pathfinding.RVO.Sampled.Agent::Rainbow