IntToColor() public static method

public static IntToColor ( int i, float a ) : Color
i int
a float
return Color
Exemplo 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);
        }
Exemplo n.º 2
0
        void OnDrawGizmos(int boxi, int depth)
        {
            BBTreeBox box = arr[boxi];

            var min = (Vector3) new Int3(box.rect.xmin, 0, box.rect.ymin);
            var max = (Vector3) new Int3(box.rect.xmax, 0, box.rect.ymax);

            Vector3 center = (min + max) * 0.5F;
            Vector3 size   = (max - center) * 2;

            size      = new Vector3(size.x, 1, size.z);
            center.y += depth * 2;

            Gizmos.color = AstarMath.IntToColor(depth, 1f);             //new Color (0,0,0,0.2F);
            Gizmos.DrawCube(center, size);

            if (box.node != null)
            {
            }
            else
            {
                OnDrawGizmos(box.left, depth + 1);
                OnDrawGizmos(box.right, depth + 1);
            }
        }
Exemplo n.º 3
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(uint area)
 {
     if (AreaColors == null || area >= AreaColors.Length)
     {
         return(AstarMath.IntToColor((int)area, 1F));
     }
     return(AreaColors[(int)area]);
 }
Exemplo n.º 4
0
 public static Color GetAreaColor(uint area)
 {
     if (AstarColor.AreaColors == null || (ulong)area >= (ulong)((long)AstarColor.AreaColors.Length))
     {
         return(AstarMath.IntToColor((int)area, 1f));
     }
     return(AstarColor.AreaColors[(int)area]);
 }
Exemplo n.º 5
0
 public static Color GetAreaColor(uint area)
 {
     if ((AreaColors != null) && (area < AreaColors.Length))
     {
         return(AreaColors[area]);
     }
     return(AstarMath.IntToColor((int)area, 1f));
 }
Exemplo n.º 6
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
        }
Exemplo n.º 7
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_18C;

            case GraphDebugMode.Connections:
            {
IL_25:
                if (debugMode == GraphDebugMode.Areas)
                {
                    result = AstarColor.GetAreaColor(node.Area);
                    goto IL_18C;
                }
                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_18C;
            }

            case GraphDebugMode.Tags:
                result = AstarMath.IntToColor((int)node.Tag, 0.5f);
                goto IL_18C;
            }
            goto IL_25;
IL_18C:
            result.a *= 0.5f;
            return(result);
        }
Exemplo n.º 8
0
        private void OnDrawGizmos(int boxi, int depth)
        {
            BBTree.BBTreeBox bBTreeBox = this.arr[boxi];
            Vector3          a         = new Vector3(bBTreeBox.rect.xMin, 0f, bBTreeBox.rect.yMin);
            Vector3          vector    = new Vector3(bBTreeBox.rect.xMax, 0f, bBTreeBox.rect.yMax);
            Vector3          vector2   = (a + vector) * 0.5f;
            Vector3          size      = (vector - vector2) * 2f;

            vector2.y   += (float)depth * 0.2f;
            Gizmos.color = AstarMath.IntToColor(depth, 0.05f);
            Gizmos.DrawCube(vector2, size);
            if (bBTreeBox.node == null)
            {
                this.OnDrawGizmos(bBTreeBox.left, depth + 1);
                this.OnDrawGizmos(bBTreeBox.right, depth + 1);
            }
        }
Exemplo n.º 9
0
        private void OnDrawGizmos(int boxi, int depth)
        {
            BBTreeBox box     = this.arr[boxi];
            Vector3   vector  = new Vector3(box.rect.xMin, 0f, box.rect.yMin);
            Vector3   vector2 = new Vector3(box.rect.xMax, 0f, box.rect.yMax);
            Vector3   center  = (Vector3)((vector + vector2) * 0.5f);
            Vector3   size    = (Vector3)((vector2 - center) * 2f);

            center.y    += depth * 0.2f;
            Gizmos.color = AstarMath.IntToColor(depth, 0.05f);
            Gizmos.DrawCube(center, size);
            if (box.node == null)
            {
                this.OnDrawGizmos(box.left, depth + 1);
                this.OnDrawGizmos(box.right, depth + 1);
            }
        }
Exemplo n.º 10
0
        private void OnDrawGizmos(int boxi, int depth)
        {
            BBTree.BBTreeBox bbtreeBox = this.tree[boxi];
            Vector3          a         = (Vector3) new Int3(bbtreeBox.rect.xmin, 0, bbtreeBox.rect.ymin);
            Vector3          vector    = (Vector3) new Int3(bbtreeBox.rect.xmax, 0, bbtreeBox.rect.ymax);
            Vector3          vector2   = (a + vector) * 0.5f;
            Vector3          size      = (vector - vector2) * 2f;

            size         = new Vector3(size.x, 1f, size.z);
            vector2.y   += (float)(depth * 2);
            Gizmos.color = AstarMath.IntToColor(depth, 1f);
            Gizmos.DrawCube(vector2, size);
            if (!bbtreeBox.IsLeaf)
            {
                this.OnDrawGizmos(bbtreeBox.left, depth + 1);
                this.OnDrawGizmos(bbtreeBox.right, depth + 1);
            }
        }
Exemplo n.º 11
0
        private void OnDrawGizmos(int boxi, int depth)
        {
            BBTreeBox box     = this.arr[boxi];
            Vector3   vector  = (Vector3) new Int3(box.rect.xmin, 0, box.rect.ymin);
            Vector3   vector2 = (Vector3) new Int3(box.rect.xmax, 0, box.rect.ymax);
            Vector3   center  = (Vector3)((vector + vector2) * 0.5f);
            Vector3   size    = (Vector3)((vector2 - center) * 2f);

            size         = new Vector3(size.x, 1f, size.z);
            center.y    += depth * 2;
            Gizmos.color = AstarMath.IntToColor(depth, 1f);
            Gizmos.DrawCube(center, size);
            if (box.node == null)
            {
                this.OnDrawGizmos(box.left, depth + 1);
                this.OnDrawGizmos(box.right, depth + 1);
            }
        }
Exemplo n.º 12
0
        private void OnDrawGizmos(int boxi, int depth)
        {
            BBTree.BBTreeBox bbtreeBox = this.arr[boxi];
            Vector3          vector;

            vector..ctor(bbtreeBox.rect.xMin, 0f, bbtreeBox.rect.yMin);
            Vector3 vector2;

            vector2..ctor(bbtreeBox.rect.xMax, 0f, bbtreeBox.rect.yMax);
            Vector3 vector3 = (vector + vector2) * 0.5f;
            Vector3 vector4 = (vector2 - vector3) * 2f;

            vector3.y   += (float)depth * 0.2f;
            Gizmos.color = AstarMath.IntToColor(depth, 0.05f);
            Gizmos.DrawCube(vector3, vector4);
            if (bbtreeBox.node == null)
            {
                this.OnDrawGizmos(bbtreeBox.left, depth + 1);
                this.OnDrawGizmos(bbtreeBox.right, depth + 1);
            }
        }
Exemplo n.º 13
0
        void OnDrawGizmos(int boxi, int depth)
        {
            BBTreeBox box = tree[boxi];

            var min = (Vector3) new VInt3(box.rect.xmin, 0, box.rect.ymin);
            var max = (Vector3) new VInt3(box.rect.xmax, 0, box.rect.ymax);

            Vector3 center = (min + max) * 0.5F;
            Vector3 size   = (max - center) * 2;

            size      = new Vector3(size.x, 1, size.z);
            center.y += depth * 2;

            Gizmos.color = AstarMath.IntToColor(depth, 1f);
            Gizmos.DrawCube(center, size);

            if (!box.IsLeaf)
            {
                OnDrawGizmos(box.left, depth + 1);
                OnDrawGizmos(box.right, depth + 1);
            }
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
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);
        }