Ejemplo n.º 1
0
 /** Returns an color for an area, uses both user set ones and calculated.
  * If the user has set a color for the area, it is used, but otherwise the color is calculated using Mathfx::IntToColor
  * \see #AreaColors */
 public static Color GetAreaColor(int area)
 {
     if (AreaColors == null || area >= AreaColors.Length)
     {
         return(Mathfx.IntToColor(area, 1F));
     }
     return(AreaColors[area]);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a color to be used for the specified node with the current debug settings (editor only)
        /// </summary>
        /// <param name="node">
        /// A <see cref="Node"/>
        /// </param>
        /// <returns>
        /// A <see cref="Color"/>
        /// </returns>
        public virtual Color NodeColor(Node node, NodeRunData data)
        {
        #if !PhotonImplementation
            Color c      = AstarColor.NodeConnection;
            bool  colSet = false;

            if (node == null)
            {
                return(AstarColor.NodeConnection);
            }

            switch (AstarPath.active.debugMode)
            {
            case GraphDebugMode.Areas:
                c      = AstarColor.GetAreaColor(node.area);
                colSet = true;
                break;

            case GraphDebugMode.Penalty:
                c      = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (float)node.penalty / (float)AstarPath.active.debugRoof);
                colSet = true;
                break;

            case GraphDebugMode.Tags:
                c      = Mathfx.IntToColor(node.tags, 0.5F);
                colSet = true;
                break;

                /* Wasn't really usefull
                 * case GraphDebugMode.Position:
                 *      float r = Mathf.PingPong (node.position.x/10000F,1F) + Mathf.PingPong (node.position.x/300000F,1F);
                 *      float g = Mathf.PingPong (node.position.y/10000F,1F) + Mathf.PingPong (node.position.y/200000F,1F);
                 *      float b = Mathf.PingPong (node.position.z/10000F,1F) + Mathf.PingPong (node.position.z/100000F,1F);
                 *
                 *
                 *      c = new Color (r,g,b);
                 *      break;
                 */
            }

            if (!colSet)
            {
                if (data == null)
                {
                    return(AstarColor.NodeConnection);
                }

                NodeRun nodeR = node.GetNodeRun(data);

                if (nodeR == null)
                {
                    return(AstarColor.NodeConnection);
                }

                switch (AstarPath.active.debugMode)
                {
                case GraphDebugMode.G:
                    //c = Mathfx.IntToColor (node.g,0.5F);
                    c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (float)nodeR.g / (float)AstarPath.active.debugRoof);
                    break;

                case GraphDebugMode.H:
                    c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (float)nodeR.h / (float)AstarPath.active.debugRoof);
                    break;

                case GraphDebugMode.F:
                    c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (float)nodeR.f / (float)AstarPath.active.debugRoof);
                    break;
                }
            }
            c.a *= 0.5F;
            return(c);
        #else
            return(new Color(1, 1, 1));
        #endif
        }