Exemple #1
0
        public static List<Vector2D> FindPath(RoomUser User, bool Diag, Gamemap Map, Vector2D Start, Vector2D End)
        {
            List<Vector2D> Path = new List<Vector2D>();

            PathFinderNode Nodes = FindPathReversed(User, Diag, Map, Start, End);

            if (Nodes != null)
            {
                Path.Add(End);

                while (Nodes.Next != null)
                {
                    Path.Add(Nodes.Next.Position);
                    Nodes = Nodes.Next;
                }
            }

            return Path;
        }
Exemple #2
0
        private void Initialize(UInt32 Id, string Name, string Description, string Type, string Owner, int OwnerId, int Category,
            int State, 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, Group group, int GameId, int chattype,
            int chatballoon, int chatspeed, int chatmaxdis, int chatprotection, int whomute, int whokick, int whoban, uint groupid, List<Chatlog> Chat)
        {
            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.UsersNow = 0;
            this.UsersMax = UsersMax;
            this.ModelName = ModelName;
            this.Score = Score;
            tagCount = 0;
            this.Tags = new ArrayList();
            foreach (string tag in pTags)
            {
                tagCount++;
                Tags.Add(tag);
            }

            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<Int64, double>();
            this.MutedUsers = new Dictionary<uint, uint>();
            this.Wallpaper = Wallpaper;
            this.Floor = Floor;
            this.Landscape = Landscape;
            this.ActiveTrades = new ArrayList();

            this.MutedPets = false;
            this.MutedBots = false;
            this.mCycleEnded = false;

            this.mRoomData = RoomData;
            this.EveryoneGotRights = RightOverride;

            this.roomMessages = new Queue();
            this.chatMessageQueue = new Queue();
            this.LoadedGroups = new Dictionary<uint, String>();

            this.roomMessages = new Queue();
            this.roomAlerts = new Queue();
            this.roomBadge = new Queue();
            this.roomKick = new Queue();
            this.roomServerMessages = new Queue();
            //this.DiceQueue = new Queue();
            this.IdleTime = 0;
            this.RoomMuted = false;
            this.WallThickness = walltickness;
            this.FloorThickness = floorthickness;

            this.gamemap = new Gamemap(this);
            if (roomItemHandling == null)
                this.roomItemHandling = new RoomItemHandling(this);
            this.roomUserManager = new RoomUserManager(this);
            this.RoomChat = Chat;
            this.ForSale = false;
            this.SalePrice = 0;
            this.Event = SilverwaveEnvironment.GetGame().GetRoomEvents().GetEvent(Id);
            this.GameId = GameId;
            this.WhoCanBan = whoban;
            this.WhoCanKick = whokick;
            this.WhoCanBan = whoban;
            this.GroupId = groupid;

            LoadRights();
            GetRoomItemHandler().LoadFurniture();
            GetGameMap().GenerateMaps();
            LoadMusic();
            LoadBans();
            InitUserBots();
            this.Added = new List<Chatlog>();
            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("UPDATE rooms SET users_now=1 WHERE id=" + Id + " LIMIT 1");
            }
            SilverwaveEnvironment.GetGame().GetRoomManager().QueueActiveRoomAdd(mRoomData);
        }
Exemple #3
0
        public static PathFinderNode FindPathReversed(RoomUser User, bool Diag, Gamemap Map, Vector2D Start, Vector2D End)
        {
            MinHeap<PathFinderNode> OpenList = new MinHeap<PathFinderNode>(256);

            PathFinderNode[,] PfMap = new PathFinderNode[Map.Model.MapSizeX, Map.Model.MapSizeY];
            PathFinderNode Node;
            Vector2D Tmp;
            int Cost;
            int Diff;

            PathFinderNode Current = new PathFinderNode(Start);
            Current.Cost = 0;

            PathFinderNode Finish = new PathFinderNode(End);
            PfMap[Current.Position.X, Current.Position.Y] = Current;
            OpenList.Add(Current);

            while (OpenList.Count > 0)
            {
                Current = OpenList.ExtractFirst();
                Current.InClosed = true;

                for (int i = 0; Diag ? i < DiagMovePoints.Length : i < NoDiagMovePoints.Length; i++)
                {
                    Tmp = Current.Position + (Diag ? DiagMovePoints[i] : NoDiagMovePoints[i]);
                    bool IsFinalMove = (Tmp.X == End.X && Tmp.Y == End.Y);

                    if (Map.IsValidStep(new Vector2D(Current.Position.X, Current.Position.Y), Tmp, IsFinalMove, User.AllowOverride))
                    {
                        if (PfMap[Tmp.X, Tmp.Y] == null)
                        {
                            Node = new PathFinderNode(Tmp);
                            PfMap[Tmp.X, Tmp.Y] = Node;
                        }
                        else
                        {
                            Node = PfMap[Tmp.X, Tmp.Y];
                        }

                        if (!Node.InClosed)
                        {
                            Diff = 0;

                            if (Current.Position.X != Node.Position.X)
                            {
                                Diff += 1;
                            }

                            if (Current.Position.Y != Node.Position.Y)
                            {
                                Diff += 1;
                            }

                            Cost = Current.Cost + Diff + Node.Position.GetDistanceSquared(End);

                            if (Cost < Node.Cost)
                            {
                                Node.Cost = Cost;
                                Node.Next = Current;
                            }

                            if (!Node.InOpen)
                            {
                                if (Node.Equals(Finish))
                                {
                                    Node.Next = Current;
                                    return Node;
                                }

                                Node.InOpen = true;
                                OpenList.Add(Node);
                            }
                        }
                    }
                }
            }

            return null;
        }