コード例 #1
0
        public void Import()
        {
            string[] l = File.ReadAllLines("map.ini");

            WorldMapCell active = default(WorldMapCell);

            foreach (var li in l)
            {
                if (li.Substring(0, 5) == "[Cell")
                {
                    string[] cellData = li.Split("_".ToCharArray());
                    active = new WorldMapCell(int.Parse(cellData[1]), int.Parse(cellData[2]));
                    lock (cells)
                    {
                        cells.Add(active);
                    }
                }
                else
                {
                    string[] pointData = li.Split(",".ToCharArray());
                    lock (active.points)
                    {
                        active.points.Add(new WorldMapPoint(float.Parse(pointData[0]), float.Parse(pointData[1]),
                                                            float.Parse(pointData[2])));
                    }
                }
            }
        }
コード例 #2
0
        public WorldMapCell LookupCell(float x, float z)
        {
            WorldMapCell c     = default(WorldMapCell);
            var          cellX = (int)(x / 512);
            var          cellZ = (int)(z / 512);

            lock (cells)
            {
                if (cells.Any(d => d.X == cellX && d.Z == cellZ))
                {
                    return(cells.FirstOrDefault(d => d.X == cellX && d.Z == cellZ));
                }

                Debug.WriteLine("Created cell " + cellX + "," + cellZ);
                c = new WorldMapCell(cellX, cellZ);
                cells.Add(c);
            }
            return(c);
        }
コード例 #3
0
ファイル: WorldMapper.cs プロジェクト: nlhans/SimShift
        public void Import()
        {
            string[] l = File.ReadAllLines("map.ini");

            WorldMapCell active = default(WorldMapCell);
            foreach (var li in l)
            {
                if (li.Substring(0, 5) == "[Cell")
                {
                    string[] cellData = li.Split("_".ToCharArray());
                    active = new WorldMapCell(int.Parse(cellData[1]), int.Parse(cellData[2]));
                    lock (cells)
                    {
                        cells.Add(active);
                    }
                }
                else
                {
                    string[] pointData = li.Split(",".ToCharArray());
                    lock (active.points)
                    {
                        active.points.Add(new WorldMapPoint(float.Parse(pointData[0]), float.Parse(pointData[1]),
                                                            float.Parse(pointData[2])));
                    }
                }
            }
        }
コード例 #4
0
ファイル: WorldMapper.cs プロジェクト: nlhans/SimShift
        public WorldMapCell LookupCell(float x, float z)
        {
            WorldMapCell c = default(WorldMapCell);
            var cellX = (int) (x / 512);
            var cellZ = (int)(z / 512);
            lock (cells)
            {
                if (cells.Any(d => d.X == cellX && d.Z == cellZ))
                    return cells.FirstOrDefault(d => d.X == cellX && d.Z == cellZ);

                Debug.WriteLine("Created cell " + cellX + "," + cellZ);
                c = new WorldMapCell(cellX, cellZ);
                cells.Add(c);
            }
            return c;
        }