Пример #1
0
        public void OnDisconnectedPlayer(BasePlayer player)
        {
            int last_finishLineX = this.X + Settings.MapZonesLine;
            int last_startLineX  = this.X - Settings.MapZonesLine;
            int last_finishLineY = this.Y + Settings.MapZonesLine;
            int last_startLineY  = this.Y - Settings.MapZonesLine;

            GameZona lastZona;

            for (int x = last_startLineX; x <= last_finishLineX; x++)
            {
                for (int y = last_startLineY; y <= last_finishLineY; y++)
                {
                    if (ZonaManager.IsInMap(x, y))
                    {
                        lastZona = ZonaManager.GetGameZona(x, y);
                        for (var i = 0; i < lastZona.ListNetworkablesInZona.Count; i++)
                        {
                            if (lastZona.ListNetworkablesInZona[i].ListViewToMe.Contains(player))
                            {
                                lastZona.ListNetworkablesInZona[i].ListViewToMe.Remove(player);
                            }
                        }
                    }
                }
            }

            if (this.ListPlayersInZona.Contains(player))
            {
                this.ListPlayersInZona.Remove(player);
            }
        }
Пример #2
0
        private void Change(BaseNetworkable networkable)
        {
            int changeX = this.X - networkable.CurentGameZona.X;
            int changeY = this.Y - networkable.CurentGameZona.Y;

            if (changeX >= -1 && changeX <= 1 && changeY >= -1 && changeY <= 1)
            {
                if (changeX != 0)
                {
                    int unforward = changeX * -1 * Settings.MapZonesLine + networkable.CurentGameZona.X;
                    if (ZonaManager.IsInMap(unforward, networkable.CurentGameZona.Y))
                    {
                        int finishLine = networkable.CurentGameZona.Y + Settings.MapZonesLine;
                        int startLine  = networkable.CurentGameZona.Y - Settings.MapZonesLine;

                        for (int i = startLine; i <= finishLine; i++)
                        {
                            ZonaManager.GetGameZona(unforward, i)?.UnSubscribe(networkable);
                        }
                    }
                }

                if (changeY != 0)
                {
                    int unforward = changeY * -1 * Settings.MapZonesLine + networkable.CurentGameZona.Y;
                    if (ZonaManager.IsInMap(networkable.CurentGameZona.X, unforward))
                    {
                        GameZona lastView;
                        int      finishLine = networkable.CurentGameZona.X + Settings.MapZonesLine;
                        int      startLine  = networkable.CurentGameZona.X - Settings.MapZonesLine;

                        for (int i = startLine; i <= finishLine; i++)
                        {
                            ZonaManager.GetGameZona(i, unforward)?.UnSubscribe(networkable);
                        }
                    }
                }

                if (changeX != 0)
                {
                    int forward = changeX * Settings.MapZonesLine + this.X;
                    if (ZonaManager.IsInMap(forward, this.Y))
                    {
                        GameZona lastView;
                        int      finishLine = this.Y + Settings.MapZonesLine;
                        int      startLine  = this.Y - Settings.MapZonesLine;

                        for (int i = startLine; i <= finishLine; i++)
                        {
                            ZonaManager.GetGameZona(forward, i)?.Subscribe(networkable);
                        }
                    }
                }

                if (changeY != 0)
                {
                    int forward = changeY * Settings.MapZonesLine + this.Y;
                    if (ZonaManager.IsInMap(this.X, forward))
                    {
                        GameZona lastView;
                        int      finishLine = this.X + Settings.MapZonesLine;
                        int      startLine  = this.X - Settings.MapZonesLine;

                        for (int i = startLine; i <= finishLine; i++)
                        {
                            ZonaManager.GetGameZona(i, forward)?.Subscribe(networkable);
                        }
                    }
                }
            }
            else
            {
                this.Teleportation(networkable);
            }
        }