コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: SquareMase.cs プロジェクト: gbahns/MazeGame
			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;
				}
			}
コード例 #3
0
        public Direction FindSite(IMapSite site)
        {
            for (int i = 0; i < (int)Direction._MAXNUM; i++)
            {
                if (_sides[i] == site)
                {
                    return((Direction)i);
                }
            }

            return(Direction.None);
        }
コード例 #4
0
		void Visit (IMapSite site)
		{
			_visited.Add(site);
			_action.Act(site);

			foreach (IMapSite Neighbor in site.Neighbors)
			{
				if (Neighbor != null && !_visited.Contains(Neighbor))
				{
					Visit(Neighbor);
				}
			}
		}
コード例 #5
0
ファイル: Room.cs プロジェクト: PlumpMath/DesignPatterns-234
 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;
     }
 }
コード例 #6
0
        // 玩家移动
        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);
        }
コード例 #7
0
ファイル: SolutionFinder.cs プロジェクト: gbahns/MazeGame
		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;
				}
			}
		}
コード例 #8
0
 public void SetSide(Direction direction, IMapSite side)
 {
     var index = direction.ToString();
     _sides[index] = side;
 }
コード例 #9
0
ファイル: Room.cs プロジェクト: gbahns/MazeGame
		//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);
		}
コード例 #10
0
 public void SetSide(Direction direction, IMapSite site)
 {
     sides[(int)direction] = site;
 }
コード例 #11
0
 public Room Enter(IMapSite srcMapSite)
 {
     return(this);
 }
コード例 #12
0
ファイル: Maze.cs プロジェクト: gbahns/MazeGame
			public void Act (IMapSite site)
			{
				if (site is Room)
					Bounds = RectangleF.Union(Bounds,site.Bounds);
			}
コード例 #13
0
ファイル: MapSiteAction_Draw.cs プロジェクト: gbahns/MazeGame
		public void Act (IMapSite site)
		{
			site.Draw(_context);
		}
コード例 #14
0
 public virtual void SetSide(Direction direction, IMapSite mapSite)
 {
     Sides[(int)direction] = mapSite;
 }
コード例 #15
0
 override public Room Enter(IMapSite srcSite)
 {
     return(null);
 }