示例#1
0
 internal void AddDoor(Door door)
 {
     SetTile(door);
     _doorsByName.Add(door.name, door);
 }
示例#2
0
        internal void AppendWallsAndDoors(string p)
        {
            for (int x = 0; x < p.Length; x++) {
                if (p[x] == '#') {
                    currentRoom.SetTile(new TileNode(currentRoom, x, yValue, TileType.WALL));
                }
                else if (p[x] == ' ') {
                    currentRoom.SetTile(new TileNode(currentRoom, x, yValue, TileType.FLOOR));
                }
                else if (Regex.IsMatch("" + p[x], "[0-9]")) {
                    Door d = new Door(currentRoom, "door" + p[x], new GameTypes.IntPoint(x, yValue));
                    currentRoom.AddDoor(d);

                    foreach (Room r in _rooms) {
                        Door otherDoor = r.GetDoor(d.name);

                        if (otherDoor != null) {
                            d.target = otherDoor; //door target is set here!
                            otherDoor.target = d;

                            if (!roomHasBeenMoved) {

                                currentRoom.worldPosition = otherDoor.worldPosition - d.localPosition;
                                Console.WriteLine("moving room to " + currentRoom.worldPosition.ToString());
                                roomHasBeenMoved = true;
                            }
                        }
                    }

                }
            }

            yValue++;
        }