예제 #1
0
        static IntPoint3 GetRandomSurfaceLocation(EnvironmentObject env)
        {
            IntPoint3 p;
            int iter = 0;

            do
            {
                if (iter++ > 10000)
                    throw new Exception();

                int x = Helpers.GetRandomInt(env.Width);
                int y = Helpers.GetRandomInt(env.Height);
                int z = env.GetDepth(new IntPoint2(x, y));

                p = new IntPoint3(x, y, z);
            } while (!EnvironmentHelpers.CanEnter(env, p));

            return p;
        }
예제 #2
0
        IntGrid2Z? FindStartLocation(EnvironmentObject env)
        {
            const int size = 3;

            var center = env.StartLocation;

            foreach (var p in IntPoint2.SquareSpiral(center.ToIntPoint(), env.Width / 2))
            {
                if (env.Size.Plane.Contains(p) == false)
                    continue;

                var z = env.GetDepth(p);

                var r = new IntGrid2Z(p.X - size, p.Y - size, size * 2, size * 2, z);

                if (TestStartArea(env, r))
                    return r;
            }

            return null;
        }
예제 #3
0
        static void CreateWorkbenches(EnvironmentObject env)
        {
            var world = env.World;

            int posx = env.Width / 2 - 10;
            int posy = env.Height / 2 - 10;

            var surface = env.GetDepth(new IntPoint2(posx, posy));

            var floorTile = new TileData()
            {
                TerrainID = TerrainID.NaturalFloor,
                TerrainMaterialID = MaterialID.Granite,
                InteriorID = InteriorID.Empty,
                InteriorMaterialID = MaterialID.Undefined,
            };

            {
                var p = new IntPoint3(posx, posy, surface);
                env.SetTileData(p, floorTile);
                var item = CreateItem(env, ItemID.SmithsWorkbench, MaterialID.Iron, p);
                item.IsInstalled = true;
            }

            posx += 4;

            {
                var p = new IntPoint3(posx, posy, surface);
                env.SetTileData(p, floorTile);
                var item = CreateItem(env, ItemID.CarpentersWorkbench, MaterialID.Oak, p);
                item.IsInstalled = true;
            }

            posx += 4;

            {
                var p = new IntPoint3(posx, posy, surface);
                env.SetTileData(p, floorTile);
                var item = CreateItem(env, ItemID.MasonsWorkbench, MaterialID.Iron, p);
                item.IsInstalled = true;
            }

            posx = env.Width / 2 - 10;

            posy += 4;

            {
                var p = new IntPoint3(posx, posy, surface);
                env.SetTileData(p, floorTile);
                var item = CreateItem(env, ItemID.SmelterWorkbench, MaterialID.Iron, p);
                item.IsInstalled = true;
            }

            posx += 4;

            {
                var p = new IntPoint3(posx, posy, surface);
                env.SetTileData(p, floorTile);
                var item = CreateItem(env, ItemID.GemcuttersWorkbench, MaterialID.Iron, p);
                item.IsInstalled = true;
            }
        }