コード例 #1
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);
        }
コード例 #2
0
ファイル: DungeonGame.cs プロジェクト: tomba/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;
        }