当前位置: 首页>>代码示例>>C#>>正文


C# Room.Connect方法代码示例

本文整理汇总了C#中Room.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Room.Connect方法的具体用法?C# Room.Connect怎么用?C# Room.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Room的用法示例。


在下文中一共展示了Room.Connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init()
        {
            w = new World(loadingfile);
            Room bank = new Room(w, "the bank",
            @"Long room. Allong the sides are many cosics with
            tellers sleeping behind their desks. At at the north
            end is a row of tall, narrow, plain wooden doors
            leading outside, at the south end a big, itricately
            carved wooden door") {w.player};
            Room sidewalk = new Room(w, "The sidewalk",
                @"Long line of rought stone tiles allong a street")
                {
                    new Item("golden candlestick","elegant white-golden candlestick",new string[] {"golden","white-golden","elagent"},new string[] {"candlestick","stick"})
                };
            Room safe = new Room(w, "The safe",
                @"inside of a big metal cube. This safe is no longer in use, but some left over coins still lie on the floor.") {
                new Item("teddy bear","Small furry creature, staring at you with its glassy eyes...",new string[] {"teddy","furry"},
                    new string[] {"creature","bear"},new CantPickUp("The bear appears to be glued to the floor.")),
                new Item("plastic fish","Hideous yellow blob, bought cheaply from some low-level toy shop",new string[] {"plastic","yellow"},new string[] {"fish","blob"},
                    new MessageBeforeAndAfter())
            };

            safe.Connect(bank,direction.North);
            sidewalk.Connect(bank, direction.South);
        }
开发者ID:mousetail,项目名称:MousetailsAdventure,代码行数:25,代码来源:Game.cs

示例2: ConnectRooms

 public static void ConnectRooms(Room a, Room b)
 {
     a.Connect (b);
     b.Connect (a);
 }
开发者ID:AntonVandeghinste,项目名称:Dungeon-Surviver,代码行数:5,代码来源:Room.cs

示例3: GenerateTiles

    private void GenerateTiles()
    {
        for (int i = 0; i< this.tiles.Length; i++) {
            Tile tile = new Tile();
            tile.SetPosition(new Position(i % this.width, i / this.width));
            tiles[i] = tile;
        }

        for(int i=0; i<1000 && rooms.Count <= this.roomCount; i++)
        {
            int x = Random.Range(1, this.width - Room.MAX_SIZE - 1);
            int w = Random.Range(Room.MIN_SIZE, Room.MAX_SIZE);
            int y = Random.Range(1, this.height - Room.MAX_SIZE - 1);
            int h = Random.Range(Room.MIN_SIZE, Room.MAX_SIZE);
            Room room = new Room (this, x, x + w, y, y + h);
            room.Digging ();
        }

        for (int y=1; y<height-1; y++) {
            for (int x=1; x<width-1; x++) {
                if(1 == x%2 && 1 == y%2 && 0 == GetTileGroupID(x, y)) {
                    Maze maze = new Maze (this);
                    maze.Digging (Maze.DirectionType.West, x, y);
                }
            }
        }

        foreach (Room room in rooms) {
            room.Connect();
        }

        bool delete = true;
        while(delete) {
            delete = false;
            for (int y=1; y<height-1; y++) {
                for (int x=1; x<width-1; x++) {
                    if(0 != GetTileGroupID(x, y))
                    {
                        int count = 0;
                        for (int dy = -1; dy <= 1; dy += 2)
                        {
                            if (0 == GetTileGroupID(x, y + dy))
                            {
                                count++;
                            }
                        }
                        for (int dx = -1; dx <= 1; dx += 2)
                        {
                            if (0 == GetTileGroupID(x + dx, y))
                            {
                                count++;
                            }
                        }

                        if(3 <= count)
                        {
                            tiles_[x + y * width] = 0;
                            delete = true;
                        }
                    }
                }
            }
        }

        for (int y=0; y<height; y++) {
            for (int x=0; x<width; x++) {
                if(0 == this.GetTileGroupID(x, y))
                {
                    int count = 0;
                    count += GetTileGroupID(x-1, y-1);
                    count += GetTileGroupID(x, y-1);
                    count += GetTileGroupID(x+1, y-1);
                    count += GetTileGroupID(x+1, y);
                    count += GetTileGroupID(x+1, y+1);
                    count += GetTileGroupID(x, y+1);
                    count += GetTileGroupID(x-1, y+1);
                    count += GetTileGroupID(x-1, y);

                    if(0 != count)
                    {
                        Wall wall = new Wall();
                        wall.SetPosition(new Position(x, y));
                    }
                }
            }
        }

        start = rooms [root ["start_room"].AsInt].GetRandomPosition ();
    }
开发者ID:ChoiIngon,项目名称:Rpg1994,代码行数:89,代码来源:Dungeon.cs

示例4: ConnectTwoRooms

		private void ConnectTwoRooms(Room _room1, Room _room2, IDictionary<Point, EDirections> _forbid, IDictionary<Point, Connector> _connectors, params Point[] _points)
		{
			var rnd = new Random(m_mazeBlocks[_room1.BlockId].RandomSeed);
			var pnt = _points[0];
			var defEmpty = DefaultEmptySpaces.ToArray();
			Point point = null;
			for (var i = 1; i < _points.Length; ++i)
			{
				var line = pnt.GetLineToPoints(_points[i]).ToArray();
				var border = Util.GetDirection(pnt, _points[i]).GetBorders().ToArray();
				for (var index = 0; index < line.Length; index++)
				{
					if (point == line[index]) continue;
					point = line[index];

					Connector connector;
					if (_connectors.TryGetValue(point, out connector))
					{
						_room1.Connect(connector.Rooms.ToArray());
						connector.Rooms.Add(_room1);

						if (_room2 != null)
						{
							ConnectTwoRooms(_room2, null, _forbid, _connectors, _points.Reverse().ToArray());
						}
						return;
					}
					if (_room2 != null)
					{
						_connectors.Add(point, new Connector(_room1, _room2));
					}
					else
					{
						_connectors.Add(point, new Connector(_room1));
					}
					var inBlock = BaseMapBlock.GetInBlockCoords(point);
					var blockId = BaseMapBlock.GetBlockId(point);

					BaseMapBlock block;
					if (!m_mazeBlocks.TryGetValue(blockId, out block))
					{
						block = new MapBlock(blockId);
						MapBlockHelper.Clear(block, rnd, this, DefaultWalls);
						m_mazeBlocks[blockId] = block;
					}
					block.Map[inBlock.X, inBlock.Y] = defEmpty.RandomItem(rnd);

					if (index != 0 && index < line.Length - 1)
					{
						foreach (var delta in border)
						{
							var borderPnt = point + delta.Key;

							EDirections dir;
							if (!_forbid.TryGetValue(borderPnt, out dir))
							{
								dir = EDirections.DOWN | EDirections.UP | EDirections.LEFT | EDirections.RIGHT;
							}
							_forbid[borderPnt] = dir & delta.Value;
						}
					}
				}
				pnt = _points[i];
			}
			_room1.Connect(_room2);
		}
开发者ID:Foxbow74,项目名称:my-busycator,代码行数:66,代码来源:TreeMazeDungeonLayer.cs


注:本文中的Room.Connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。