コード例 #1
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);
        }
コード例 #2
0
ファイル: DungeonGame.cs プロジェクト: jaenudin86/dwarrowdelf
        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);
        }
コード例 #3
0
ファイル: DungeonGame.cs プロジェクト: jaenudin86/dwarrowdelf
        bool TestStartArea(EnvironmentObject env, IntGrid2Z r)
        {
            foreach (var p in r.Range())
            {
                var td = env.GetTileData(p);

                if (td.IsWalkable)
                {
                    continue;
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
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);
        }