示例#1
0
        public IEnumerable <T> ObjectsFromCoord(Coord coord)
        {
            int counter = 0;

            foreach (Coord c in coord.DistanceArea(20000))             //to infinity
            {
                int aax = c.x >= 0? c.x:-c.x; int aaz = c.z >= 0? c.z :-c.z;
                int hash = (c.x >= 0? 0x40000000:0) | (c.z >= 0? 0x20000000:0) | ((aax & 0x3FFF) << 14) | (aaz & 0x3FFF);
                if (grid.ContainsKey(hash))
                {
                    yield return(grid[hash]);

                    counter++;
                }
                if (counter >= grid.Count)
                {
                    break;
                }
            }
        }
示例#2
0
        public void DrawGizmo()
        {
            Coord center = new Coord(3, 3);

            for (int dist = 0; dist < 5; dist++)
            {
                Gizmos.color = new Color(1f * dist / 5, 1 - 1f * dist / 5, 0, 1);
                for (int i = 0; i < dist; i++)
                {
                    foreach (Coord c in center.DistanceStep(i, dist))
                    {
                        if (cells.rect.CheckInRange(c))
                        {
                            cells[c].rect.DrawGizmo();
                        }
                    }
                }
            }


            foreach (Coord c in center.DistanceArea(cells.rect))
            {
                //	Gizmos.color = new Color(1f*counter/cells.count, 1-1f*counter/cells.count, 0, 1);
                //	cells[c].rect.DrawGizmo();
                //	counter++;
            }

            for (int x = 0; x < resolution; x++)
            {
                for (int z = 0; z < resolution; z++)
                {
                    //Gizmos.color = new Color(1f*c/cells.Length, 1-1f*c/cells.Length, 0, 1);
                    //cells[x,z].rect.DrawGizmo();
                }
            }
        }