Beispiel #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);
            }
        }
Beispiel #2
0
        private void Teleportation(BaseNetworkable networkable)
        {
            //TODO: Need rewrite tihs method... Need dont use EntityDestroy if new zona view this Entity =( By ~ TheRyuzaki

            if (networkable.CurentGameZona != null)
            {
                int last_finishLineX = networkable.CurentGameZona.X + Settings.MapZonesLine;
                int last_startLineX  = networkable.CurentGameZona.X - Settings.MapZonesLine;
                int last_finishLineY = networkable.CurentGameZona.Y + Settings.MapZonesLine;
                int last_startLineY  = networkable.CurentGameZona.Y - Settings.MapZonesLine;

                for (int x = last_startLineX; x <= last_finishLineX; x++)
                {
                    for (int y = last_startLineY; y <= last_finishLineY; y++)
                    {
                        ZonaManager.GetGameZona(x, y)?.UnSubscribe(networkable);
                    }
                }
            }

            int finishLineX = this.X + Settings.MapZonesLine;
            int startLineX  = this.X - Settings.MapZonesLine;
            int finishLineY = this.Y + Settings.MapZonesLine;
            int startLineY  = this.Y - Settings.MapZonesLine;

            for (int x = startLineX; x <= finishLineX; x++)
            {
                for (int y = startLineY; y <= finishLineY; y++)
                {
                    ZonaManager.GetGameZona(x, y)?.Subscribe(networkable);
                }
            }
        }
Beispiel #3
0
        public void OnReceivingNetworkablesFromView(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 gameZona;

            for (int x = last_startLineX; x <= last_finishLineX; x++)
            {
                for (int y = last_startLineY; y <= last_finishLineY; y++)
                {
                    gameZona = ZonaManager.GetGameZona(x, y);
                    if (gameZona != null)
                    {
                        for (var i = 0; i < gameZona.ListNetworkablesInZona.Count; i++)
                        {
                            if (gameZona.ListNetworkablesInZona[i].ListViewToMe.Contains(player) == false && gameZona.ListNetworkablesInZona[i] != player)
                            {
                                gameZona.ListNetworkablesInZona[i].ListViewToMe.Add(player);
                                gameZona.ListNetworkablesInZona[i].SendNetworkUpdate(new SendInfo(player.Network.NetConnection));
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
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);
            }
        }