Example #1
0
 static void SetArea(EnvironmentObject env, IntGrid3 area, TileData data)
 {
     foreach (var p in area.Range())
     {
         env.SetTileData(p, data);
     }
 }
Example #2
0
        static void ClearFloor(EnvironmentObject env, IntVector3 p)
        {
            var td = env.GetTileData(p);

            if (td.HasFloor == false)
            {
                env.SetTileData(p.Down, TileData.GetNaturalWall(MaterialID.Granite));
                td = env.GetTileData(p);
            }

            if (td.IsGreen)
            {
                td.ID         = TileID.Grass;
                td.MaterialID = GetRandomMaterial(MaterialCategory.Grass);
            }

            if (!td.IsClearFloor)
            {
                throw new Exception();
            }

            env.SetTileData(p, td);
        }
Example #3
0
        public static void CreateWalls(EnvironmentObject env, IntGrid2Z area)
        {
            for (int x = area.X1; x <= area.X2; ++x)
            {
                for (int y = area.Y1; y <= area.Y2; ++y)
                {
                    if (y != area.Y1 && y != area.Y2 && x != area.X1 && x != area.X2)
                    {
                        continue;
                    }

                    var p = new IntVector3(x, y, area.Z);

                    env.SetTileData(p, TileData.GetNaturalWall(MaterialID.Granite));
                }
            }
        }
Example #4
0
        Player CreatePlayer(EnvironmentObject env)
        {
            const int NUM_DWARVES = 1;

            var player = new DungeonPlayer(2, this);

            var startRect = FindStartLocation(env);

            if (!startRect.HasValue)
            {
                throw new Exception();
            }

            var startLocs = startRect.Value.Range().ToArray();

            // clear trees
            foreach (var p in startLocs)
            {
                var td = env.GetTileData(p);
                if (td.HasTree)
                {
                    td.ID         = TileID.Grass;
                    td.MaterialID = MaterialID.RyeGrass;
                    env.SetTileData(p, td);
                }
            }

            var list = new List <LivingObject>();

            for (int i = 0; i < NUM_DWARVES; ++i)
            {
                var p = startLocs[Helpers.GetRandomInt(startLocs.Length - 1)];

                var l = CreateDwarf(i);
                l.Strength = 100;

                l.MoveToMustSucceed(env, p);

                list.Add(l);
            }

            player.AddControllables(list);

            return(player);
        }
Example #5
0
        Player CreatePlayer(int playerNum, EnvironmentObject env)
        {
            const int NUM_DWARVES = 7;

            var player = new FortressPlayer(2 + playerNum, this, env);

            IntVector3 pos;

            switch (playerNum)
            {
            case 0:
                pos = env.StartLocation;
                break;

            case 1:
                pos = env.GetSurfaceLocation(env.Width / 4, env.Height / 4);
                break;

            case 2:
                pos = env.GetSurfaceLocation(env.Width / 4 * 3, env.Height / 4 * 3);
                break;

            default:
                throw new Exception();
            }

            var startRect = FindStartLocation(env, pos);

            if (!startRect.HasValue)
            {
                throw new Exception();
            }

            player.EnvObserver.Add(startRect.Value);

            var startLocs = startRect.Value.Range().ToArray();

            // clear trees
            foreach (var p in startLocs)
            {
                var td = env.GetTileData(p);
                if (td.HasTree)
                {
                    td.ID         = TileID.Grass;
                    td.MaterialID = MaterialID.RyeGrass;
                    env.SetTileData(p, td);
                }
            }

            var list = new List <LivingObject>();

            for (int i = 0; i < NUM_DWARVES; ++i)
            {
                var p = startLocs[Helpers.GetRandomInt(startLocs.Length - 1)];

                var l = CreateDwarf(i);

                l.SetAI(new DwarfAI(l, player.EnvObserver, this.World.PlayerID));

                l.MoveToMustSucceed(env, p);

                list.Add(l);
            }

            player.AddControllables(list);

            return(player);
        }
Example #6
0
 public static void ClearTile(EnvironmentObject env, IntVector3 p)
 {
     env.SetTileData(p, TileData.EmptyTileData);
 }