Esempio n. 1
0
		public static List<Vector2D> FindPath(RoomUser User, bool Diag, Gamemap Map, Vector2D Start, Vector2D End)
		{
			List<Vector2D> list = new List<Vector2D>();
			PathFinderNode pathFinderNode = PathFinder.FindPathReversed(User, Diag, Map, Start, End);
			if (pathFinderNode != null)
			{
				list.Add(End);
				while (pathFinderNode.Next != null)
				{
					list.Add(pathFinderNode.Next.Position);
					pathFinderNode = pathFinderNode.Next;
				}
			}
			return list;
		}
Esempio n. 2
0
        internal static List<Point> GeneratePath(RoomUser User, Point Start, Point End, Gamemap Map)
        {
            List<Point> List = new List<Point>();
            if (!Map.validTile(End.X, End.Y))
            {
                return List;
            }

            Point WorkingCoord = Start;
            short[,] Around = new short[8, 2] { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 }, { -1, -1 }, { 1, -1 }, { 1, 1 }, { -1, 1 } };

            while (true)
            {
                var TilesAround = new List<PathfinderNode>();

                for (short i = 0; i < 8; i++)
                {
                    Point NexTile = new Point(WorkingCoord.X + Around[i, 0], WorkingCoord.Y + Around[i, 1]);

                    if (Map.IsValidStep2(User, Start, NexTile, NexTile.X == End.X && NexTile.Y == End.Y, false))
                    {
                        TilesAround.Add(new PathfinderNode(TileDistance(NexTile, End), NexTile));
                    }
                }

                if (TilesAround.Count > 0)
                {
                    var Sorted = (from node in TilesAround orderby node.Distance ascending select node).ToList();

                    WorkingCoord = Sorted[0].Point;

                    List.Add(WorkingCoord);
                    Console.WriteLine(WorkingCoord.X + " - " + WorkingCoord.Y);

                    if (End.X == WorkingCoord.X && End.Y == WorkingCoord.Y)
                    {
                        List.Add(WorkingCoord);
                        return List;
                    }
                }
                else
                {
                    return List;
                }
            }
        }
Esempio n. 3
0
		public static PathFinderNode FindPathReversed(RoomUser User, bool Diag, Gamemap Map, Vector2D Start, Vector2D End)
		{
			MinHeap<PathFinderNode> minHeap = new MinHeap<PathFinderNode>(256);
			PathFinderNode[,] array = new PathFinderNode[Map.Model.MapSizeX, Map.Model.MapSizeY];
			PathFinderNode pathFinderNode = new PathFinderNode(Start);
			pathFinderNode.Cost = 0;
			PathFinderNode breadcrumb = new PathFinderNode(End);
			array[pathFinderNode.Position.X, pathFinderNode.Position.Y] = pathFinderNode;
			minHeap.Add(pathFinderNode);
			checked
			{
				while (minHeap.Count > 0)
				{
					pathFinderNode = minHeap.ExtractFirst();
					pathFinderNode.InClosed = true;
					int num = 0;
					while (Diag ? (num < PathFinder.DiagMovePoints.Length) : (num < PathFinder.NoDiagMovePoints.Length))
					{
						Vector2D vector2D = pathFinderNode.Position + (Diag ? PathFinder.DiagMovePoints[num] : PathFinder.NoDiagMovePoints[num]);
						bool endOfPath = vector2D.X == End.X && vector2D.Y == End.Y;
						if (Map.IsValidStep(User, new Vector2D(pathFinderNode.Position.X, pathFinderNode.Position.Y), vector2D, endOfPath, User.AllowOverride))
						{
							PathFinderNode pathFinderNode2;
							if (array[vector2D.X, vector2D.Y] == null)
							{
								pathFinderNode2 = new PathFinderNode(vector2D);
								array[vector2D.X, vector2D.Y] = pathFinderNode2;
							}
							else
							{
								pathFinderNode2 = array[vector2D.X, vector2D.Y];
							}
							if (!pathFinderNode2.InClosed)
							{
								int num2 = 0;
								if (pathFinderNode.Position.X != pathFinderNode2.Position.X)
								{
									num2++;
								}
								if (pathFinderNode.Position.Y != pathFinderNode2.Position.Y)
								{
									num2++;
								}
								int num3 = pathFinderNode.Cost + num2 + pathFinderNode2.Position.GetDistanceSquared(End);
								if (num3 < pathFinderNode2.Cost)
								{
									pathFinderNode2.Cost = num3;
									pathFinderNode2.Next = pathFinderNode;
								}
								if (!pathFinderNode2.InOpen)
								{
									if (pathFinderNode2.Equals(breadcrumb))
									{
										pathFinderNode2.Next = pathFinderNode;
										return pathFinderNode2;
									}
									pathFinderNode2.InOpen = true;
									minHeap.Add(pathFinderNode2);
								}
							}
						}
						num++;
					}
				}
				return null;
			}
		}
Esempio n. 4
0
        private void Initialize(uint Id, string Name, string Description, string Type, string Owner, int OwnerId, int Category, int State, int TradeState, int UsersMax, string ModelName, int Score, List<string> pTags, int AllowPets, int AllowPetsEating, int AllowWalkthrough, int Hidewall, string Password, string Wallpaper, string Floor, string Landscape, RoomData RoomData, bool RightOverride, int walltickness, int floorthickness, Guild group, int GameId, int chattype, int chatballoon, int chatspeed, int chatmaxdis, int chatprotection, int whomute, int whokick, int whoban, uint groupid, HashSet<Chatlog> Chat, List<string> WordFilter, int WallHeight)
        {
            this.mDisposed = false;
            this.Id = Id;
            this.Name = Name;
            this.Description = Description;
            this.Owner = Owner;
            this.OwnerId = OwnerId;
            this.Category = Category;
            this.Type = Type;
            this.State = State;
            this.TradeState = TradeState;
            this.UsersNow = 0;
            this.UsersMax = UsersMax;
            this.ModelName = ModelName;
            this.Score = Score;
            this.tagCount = 0;
            this.Tags = new ArrayList();
            foreach (string current in pTags)
            {
                this.tagCount++;
                this.Tags.Add(current);
            }
            this.ChatType = chattype;
            this.ChatBalloon = chatballoon;
            this.ChatSpeed = chatspeed;
            this.ChatMaxDistance = chatmaxdis;
            this.ChatFloodProtection = chatprotection;
            this.AllowPets = AllowPets;
            this.AllowPetsEating = AllowPetsEating;
            this.AllowWalkthrough = AllowWalkthrough;
            this.Hidewall = Hidewall;
            this.Group = group;
            this.Password = Password;
            this.Bans = new Dictionary<long, double>();
            this.MutedUsers = new Dictionary<uint, uint>();
            this.Wallpaper = Wallpaper;
            this.Floor = Floor;
            this.Landscape = Landscape;
            this.ActiveTrades = new ArrayList();
            this.MutedBots = false;
            this.mCycleEnded = false;
            this.mRoomData = RoomData;
            this.EveryoneGotRights = RightOverride;
            this.LoadedGroups = new Dictionary<uint, string>();
            this.roomKick = new Queue();
            this.IdleTime = 0;
            this.RoomMuted = false;
            this.WallThickness = walltickness;
            this.FloorThickness = floorthickness;
            this.WallHeight = WallHeight;
            this.gamemap = new Gamemap(this);
            this.roomItemHandling = new RoomItemHandling(this);
            this.roomUserManager = new RoomUserManager(this);
            this.RoomChat = Chat;
            this.WordFilter = WordFilter;
            this.Event = MercuryEnvironment.GetGame().GetRoomEvents().GetEvent(Id);
            this.WhoCanBan = whoban;
            this.WhoCanKick = whokick;
            this.WhoCanBan = whoban;
            this.GroupId = groupid;
            this.LoadRights();
            this.LoadMusic();
            this.LoadBans();
            this.InitUserBots();

            this.RoomThread = new Thread(new ThreadStart(StartRoomProcessing));
            this.RoomThread.Start();
            MercuryEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(this.mRoomData);
        }
Esempio n. 5
0
 internal void ResetGamemap(string newModelName, int wallHeight, int wallThick, int floorThick)
 {
     this.ModelName = newModelName;
     this.mRoomData.ModelName = newModelName;
     this.mRoomData.ResetModel();
     this.mRoomData.WallHeight = wallHeight;
     this.mRoomData.WallThickness = WallThickness;
     this.mRoomData.FloorThickness = floorThick;
     this.gamemap = new Gamemap(this);
 }