public virtual Room Enter(IMapSite srcSite) { Room srcRoom = srcSite as Room; if (srcRoom == null || (srcRoom != _room1 && srcRoom != _room2)) { return(null); } // 进入另一侧 return(OtherSideRoom(srcRoom).Enter(this)); }
public RoomPair(IMapSite r1, IMapSite r2) { Room1 = r1.Coordinates; Room2 = r2.Coordinates; if (Room1.X > Room2.X || (Room1.X == Room2.X && Room1.Y > Room2.Y)) { PointF temp = Room1; Room1 = Room2; Room2 = temp; } }
public Direction FindSite(IMapSite site) { for (int i = 0; i < (int)Direction._MAXNUM; i++) { if (_sides[i] == site) { return((Direction)i); } } return(Direction.None); }
void Visit (IMapSite site) { _visited.Add(site); _action.Act(site); foreach (IMapSite Neighbor in site.Neighbors) { if (Neighbor != null && !_visited.Contains(Neighbor)) { Visit(Neighbor); } } }
public void SetSide(Direction dir, IMapSite mapSite) { if (dir == Direction.East) { mEastSide = mapSite; } else if (dir == Direction.West) { mWestSide = mapSite; } else if (dir == Direction.South) { mSorthSide = mapSite; } else if (dir == Direction.North) { mNorthSide = mapSite; } }
// 玩家移动 public bool Move(Direction direction) { Room currentRoom = _maze.GetRoom(_man.GetLocation()); IMapSite dstSite = currentRoom.GetSite(direction); if (dstSite != null && dstSite.EnterAble) { Room dstRoom = dstSite.Enter(currentRoom); var dstLocation = dstRoom.GetLocation(); if (dstLocation - _man.GetLocation() == 1) { // neighbor _man.Move(direction); } else { _man.SetLocation(dstLocation); } return(true); } return(false); }
void Explore (IMapSite fromSite, IMapSite Site) { _visited.Add(Site); foreach (IMapSite Neighbor in Site.Neighbors) { if (Neighbor != null && Neighbor != fromSite) { //try to enter this neighbor Neighbor.Enter(_robot); //check to see if it succeeded if (_robot.Location != Site) { //if it succeeded, but we've already been there once, //then we've found a cycle, otherwise continue exploring //from this neighbor if (_visited.Contains(_robot.Location)) { _cycleFound = true; } else { Explore(Site,_robot.Location); } } //after exploring that neighbor, //reset to this location to explore the other neighbors _robot.Location = Site; //if (_solutionFound) // break; } } }
public void SetSide(Direction direction, IMapSite side) { var index = direction.ToString(); _sides[index] = side; }
//connect this site to the specified site //assume that the specified site is already connected and has valid //coordinates within the map //direction d specifes the direction from "site" to "this" public virtual void Join (IMapSite site, Direction d) { Neighbors[d] = site; site.Neighbors[d.opposite] = this; _coords = site.GetAdjacentCoords(d.opposite); }
public void SetSide(Direction direction, IMapSite site) { sides[(int)direction] = site; }
public Room Enter(IMapSite srcMapSite) { return(this); }
public void Act (IMapSite site) { if (site is Room) Bounds = RectangleF.Union(Bounds,site.Bounds); }
public void Act (IMapSite site) { site.Draw(_context); }
public virtual void SetSide(Direction direction, IMapSite mapSite) { Sides[(int)direction] = mapSite; }
override public Room Enter(IMapSite srcSite) { return(null); }