GetAreaColor() public static method

public static GetAreaColor ( int area ) : Color
area int
return UnityEngine.Color
Ejemplo n.º 1
0
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
            Color result = AstarColor.NodeConnection;
            bool  flag   = false;

            if (node == null)
            {
                return(AstarColor.NodeConnection);
            }
            GraphDebugMode debugMode = AstarPath.active.debugMode;

            switch (debugMode)
            {
            case GraphDebugMode.Penalty:
                result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (node.Penalty - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                flag   = true;
                goto IL_A9;

            case GraphDebugMode.Connections:
IL_33:
                if (debugMode != GraphDebugMode.Areas)
                {
                    goto IL_A9;
                }
                result = AstarColor.GetAreaColor(node.Area);
                flag   = true;
                goto IL_A9;

            case GraphDebugMode.Tags:
                result = AstarMath.IntToColor((int)node.Tag, 0.5f);
                flag   = true;
                goto IL_A9;
            }
            goto IL_33;
IL_A9:
            if (!flag)
            {
                if (data == null)
                {
                    return(AstarColor.NodeConnection);
                }
                PathNode pathNode = data.GetPathNode(node);
                switch (AstarPath.active.debugMode)
                {
                case GraphDebugMode.G:
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (pathNode.G - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;

                case GraphDebugMode.H:
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (pathNode.H - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;

                case GraphDebugMode.F:
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (pathNode.F - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;
                }
            }
            result.a *= 0.5f;
            return(result);
        }
Ejemplo n.º 2
0
        /** Color to use for gizmos.
         * Returns a color to be used for the specified node with the current debug settings (editor only).
         *
         * \version Since 3.6.1 this method will not handle null nodes
         */
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
            Color color;

            var mode = AstarPath.active.debugMode;

            switch (mode)
            {
            case GraphDebugMode.Areas:
                color = AstarColor.GetAreaColor(node.Area);
                break;

            case GraphDebugMode.Penalty:
                color = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, ((float)node.Penalty - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                break;

            case GraphDebugMode.Tags:
                color = AstarColor.GetAreaColor(node.Tag);
                break;

            case GraphDebugMode.Connections:
                color = AstarColor.NodeConnection;
                break;

            default:
                if (data == null)
                {
                    return(AstarColor.NodeConnection);
                }

                PathNode pathNode = data.GetPathNode(node);
                float    value;
                if (mode == GraphDebugMode.G)
                {
                    value = pathNode.G;
                }
                else if (mode == GraphDebugMode.H)
                {
                    value = pathNode.H;
                }
                else
                {
                    // mode == F
                    value = pathNode.F;
                }

                color = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (value - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                break;
            }

            color.a *= 0.5F;
            return(color);
        }
Ejemplo n.º 3
0
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
            GraphDebugMode debugMode = AstarPath.active.debugMode;
            Color          result;

            switch (debugMode)
            {
            case GraphDebugMode.Penalty:
                result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (node.Penalty - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                break;

            case GraphDebugMode.Connections:
                result = AstarColor.NodeConnection;
                break;

            case GraphDebugMode.Tags:
                result = AstarColor.GetAreaColor(node.Tag);
                break;

            default:
                if (debugMode != GraphDebugMode.Areas)
                {
                    if (data == null)
                    {
                        return(AstarColor.NodeConnection);
                    }
                    PathNode pathNode = data.GetPathNode(node);
                    float    num;
                    if (debugMode == GraphDebugMode.G)
                    {
                        num = pathNode.G;
                    }
                    else if (debugMode == GraphDebugMode.H)
                    {
                        num = pathNode.H;
                    }
                    else
                    {
                        num = pathNode.F;
                    }
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (num - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                }
                else
                {
                    result = AstarColor.GetAreaColor(node.Area);
                }
                break;
            }
            result.a *= 0.5f;
            return(result);
        }
Ejemplo n.º 4
0
        /* Color to use for gizmos.
         * Returns a color to be used for the specified node with the current debug settings (editor only).
         *
         * \version Since 3.6.1 this method will not handle null nodes
         */
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
        #if !PhotonImplementation
            Color c = AstarColor.NodeConnection;

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

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

            case GraphDebugMode.Tags:
                c = AstarMath.IntToColor((int)node.Tag, 0.5F);
                break;

            default:
                if (data == null)
                {
                    return(AstarColor.NodeConnection);
                }

                PathNode nodeR = data.GetPathNode(node);

                switch (AstarPath.active.debugMode)
                {
                case GraphDebugMode.G:
                    c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, ((float)nodeR.G - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;

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

                case GraphDebugMode.F:
                    c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, ((float)nodeR.F - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;
                }
                break;
            }

            c.a *= 0.5F;
            return(c);
        #else
            return(new Color(1, 1, 1));
        #endif
        }
Ejemplo n.º 5
0
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
            Color          result    = AstarColor.NodeConnection;
            GraphDebugMode debugMode = AstarPath.active.debugMode;

            switch (debugMode)
            {
            case GraphDebugMode.Penalty:
                result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (node.Penalty - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                goto IL_187;

            case GraphDebugMode.Connections:
            {
IL_25:
                if (debugMode == GraphDebugMode.Areas)
                {
                    result = AstarColor.GetAreaColor(node.Area);
                    goto IL_187;
                }
                if (data == null)
                {
                    return(AstarColor.NodeConnection);
                }
                PathNode pathNode = data.GetPathNode(node);
                switch (AstarPath.active.debugMode)
                {
                case GraphDebugMode.G:
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (pathNode.G - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;

                case GraphDebugMode.H:
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (pathNode.H - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;

                case GraphDebugMode.F:
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (pathNode.F - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;
                }
                goto IL_187;
            }

            case GraphDebugMode.Tags:
                result = AstarColor.GetAreaColor(node.Tag);
                goto IL_187;
            }
            goto IL_25;
IL_187:
            result.a *= 0.5f;
            return(result);
        }
Ejemplo n.º 6
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)
        {
            Color c = Color.white;

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

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

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

            case GraphDebugMode.F:
                c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (float)node.f / (float)AstarPath.active.debugRoof);
                break;

            case GraphDebugMode.Penalty:
                c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, (float)node.penalty / (float)AstarPath.active.debugRoof);
                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;
                 */
            }
            c.a *= 0.5F;
            return(c);
        }
Ejemplo n.º 7
0
        /* Color to use for gizmos.
         * Returns a color to be used for the specified node with the current debug settings (editor only)
         */
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
            var c      = AstarColor.NodeConnection;
            var 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 - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                colSet = true;
                break;

            case GraphDebugMode.Tags:
                c      = AstarMath.IntToColor((int)node.Tag, 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);
                }

                var nodeR = data.GetPathNode(node);

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

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

                case GraphDebugMode.F:
                    c = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, ((float)nodeR.F - AstarPath.active.debugFloor) / (AstarPath.active.debugRoof - AstarPath.active.debugFloor));
                    break;
                }
            }
            c.a *= 0.5F;
            return(c);
        }
Ejemplo n.º 8
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
        }
Ejemplo n.º 9
0
        // Token: 0x06000429 RID: 1065 RVA: 0x00021630 File Offset: 0x0001FA30
        public virtual Color NodeColor(GraphNode node, PathHandler data)
        {
            Color result = AstarColor.NodeConnection;
            bool  flag   = false;

            if (node == null)
            {
                return(AstarColor.NodeConnection);
            }
            GraphDebugMode debugMode = AstarPath.active.debugMode;

            if (debugMode != GraphDebugMode.Areas)
            {
                if (debugMode != GraphDebugMode.Penalty)
                {
                    if (debugMode == GraphDebugMode.Tags)
                    {
                        result = AstarMath.IntToColor((int)node.Tag, 0.5f);
                        flag   = true;
                    }
                }
                else
                {
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, node.Penalty / AstarPath.active.debugRoof);
                    flag   = true;
                }
            }
            else
            {
                result = AstarColor.GetAreaColor(node.Area);
                flag   = true;
            }
            if (!flag)
            {
                if (data == null)
                {
                    return(AstarColor.NodeConnection);
                }
                PathNode       pathNode   = data.GetPathNode(node);
                GraphDebugMode debugMode2 = AstarPath.active.debugMode;
                if (debugMode2 != GraphDebugMode.G)
                {
                    if (debugMode2 != GraphDebugMode.H)
                    {
                        if (debugMode2 == GraphDebugMode.F)
                        {
                            result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, pathNode.F / AstarPath.active.debugRoof);
                        }
                    }
                    else
                    {
                        result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, pathNode.H / AstarPath.active.debugRoof);
                    }
                }
                else
                {
                    result = Color.Lerp(AstarColor.ConnectionLowLerp, AstarColor.ConnectionHighLerp, pathNode.G / AstarPath.active.debugRoof);
                }
            }
            result.a *= 0.5f;
            return(result);
        }
Ejemplo n.º 10
0
        /** Creates an outline of the navmesh for use in OnDrawGizmos in the editor */
        static Mesh CreateNavmeshOutlineVisualization(RecastGraph.NavmeshTile tile)
        {
            var sharedEdges = new bool[3];

            var mesh = new Mesh();

            mesh.hideFlags = HideFlags.DontSave;

            var colorList = ListPool <Color32> .Claim();

            var edgeList = ListPool <Int3> .Claim();

            for (int j = 0; j < tile.nodes.Length; j++)
            {
                sharedEdges[0] = sharedEdges[1] = sharedEdges[2] = false;

                var node = tile.nodes[j];
                for (int c = 0; c < node.connections.Length; c++)
                {
                    var other = node.connections[c] as TriangleMeshNode;

                    // Loop throgh neighbours to figure
                    // out which edges are shared
                    if (other != null && other.GraphIndex == node.GraphIndex)
                    {
                        for (int v = 0; v < 3; v++)
                        {
                            for (int v2 = 0; v2 < 3; v2++)
                            {
                                if (node.GetVertexIndex(v) == other.GetVertexIndex((v2 + 1) % 3) && node.GetVertexIndex((v + 1) % 3) == other.GetVertexIndex(v2))
                                {
                                    // Found a shared edge with the other node
                                    sharedEdges[v] = true;
                                    v = 3;
                                    break;
                                }
                            }
                        }
                    }
                }

                for (int v = 0; v < 3; v++)
                {
                    if (!sharedEdges[v])
                    {
                        edgeList.Add(node.GetVertex(v));
                        edgeList.Add(node.GetVertex((v + 1) % 3));
                        var color = (Color32)AstarColor.GetAreaColor(node.Area);
                        colorList.Add(color);
                        colorList.Add(color);
                    }
                }
            }

            // Use pooled lists to avoid excessive allocations
            var vertices = ListPool <Vector3> .Claim(edgeList.Count *2);

            var colors = ListPool <Color32> .Claim(edgeList.Count *2);

            var normals = ListPool <Vector3> .Claim(edgeList.Count *2);

            var tris = ListPool <int> .Claim(edgeList.Count *3);

            // Loop through each endpoint of the lines
            // and add 2 vertices for each
            for (int j = 0; j < edgeList.Count; j++)
            {
                var vertex = (Vector3)edgeList[j];
                vertices.Add(vertex);
                vertices.Add(vertex);

                // Encode the side of the line
                // in the alpha component
                var color = colorList[j];
                colors.Add(new Color32(color.r, color.g, color.b, 0));
                colors.Add(new Color32(color.r, color.g, color.b, 255));
            }

            // Loop through each line and add
            // one normal for each vertex
            for (int j = 0; j < edgeList.Count; j += 2)
            {
                var lineDir = (Vector3)(edgeList[j + 1] - edgeList[j]);
                lineDir.Normalize();

                // Store the line direction in the normals
                // A line consists of 4 vertices
                // The line direction will be used to
                // offset the vertices to create a
                // line with a fixed pixel thickness
                normals.Add(lineDir);
                normals.Add(lineDir);
                normals.Add(lineDir);
                normals.Add(lineDir);
            }

            // Setup triangle indices
            // A triangle consists of 3 indices
            // A line (4 vertices) consists of 2 triangles, so 6 triangle indices
            for (int j = 0, v = 0; j < edgeList.Count * 3; j += 6, v += 4)
            {
                // First triangle
                tris.Add(v + 0);
                tris.Add(v + 1);
                tris.Add(v + 2);

                // Second triangle
                tris.Add(v + 1);
                tris.Add(v + 3);
                tris.Add(v + 2);
            }

            // Set all data on the mesh
            mesh.SetVertices(vertices);
            mesh.SetTriangles(tris, 0);
            mesh.SetColors(colors);
            mesh.SetNormals(normals);

            // Upload all data and mark the mesh as unreadable
            mesh.UploadMeshData(true);

            // Release the lists back to the pool
            ListPool <Color32> .Release(colorList);

            ListPool <Int3> .Release(edgeList);

            ListPool <Vector3> .Release(vertices);

            ListPool <Color32> .Release(colors);

            ListPool <Vector3> .Release(normals);

            ListPool <int> .Release(tris);

            return(mesh);
        }