Beispiel #1
0
        void SendActiveZombieList(ViewServer sender, ViewServer.Client cl)
        {
            if (sender == null)
            {
                return;
            }

            lock (_activeZombies)
            {
                var list = new List <Viewer.DataZombie>();
                foreach (var zombie in _activeZombies)
                {
                    Vector2i p = WorldToBitmap(zombie.pos);
                    list.Add(new Viewer.DataZombie
                    {
                        id = zombie.id,
                        x  = p.x,
                        y  = p.y,
                    });
                }

                var data = new Viewer.ZombieList();
                data.list = list;

                sender.SendData(cl, Viewer.DataType.ActiveZombies, data);
            }
        }
Beispiel #2
0
 void SendStaticState(ViewServer sender, ViewServer.Client cl)
 {
     lock (sender)
     {
         SendState(sender, cl);
         SendWorldZones(sender, cl);
         SendPOIZones(sender, cl);
     }
 }
Beispiel #3
0
        void SendPlayerZones(ViewServer sender, ViewServer.Client cl)
        {
            if (sender == null)
            {
                return;
            }

            var data = new Viewer.PlayerZones();

            data.zones = _playerZones.GetSerializable(this);
            sender.SendData(cl, Viewer.DataType.PlayerZones, data);
        }
Beispiel #4
0
        void SendWorldZones(ViewServer sender, ViewServer.Client cl)
        {
            if (sender == null)
            {
                return;
            }

            var data = new Viewer.WorldZones()
            {
                zones = _worldZones.GetSerializable(this)
            };

            sender.SendData(cl, Viewer.DataType.WorldZones, data);
        }
Beispiel #5
0
        void SendPOIZones(ViewServer sender, ViewServer.Client cl)
        {
            if (sender == null)
            {
                return;
            }

            var zones = _pois.GetSerializable(this);

            if (zones.Count == 0)
            {
                return;
            }

            var data = new Viewer.POIZones();

            data.zones = zones;
            sender.SendData(cl, Viewer.DataType.POIZones, data);
        }
Beispiel #6
0
        void SendState(ViewServer sender, ViewServer.Client cl)
        {
            if (sender == null)
            {
                return;
            }

            var data = new Viewer.State();

            data.w           = 512;
            data.h           = 512;
            data.mapW        = Utils.Distance(_worldMins.x, _worldMaxs.x);
            data.mapH        = Utils.Distance(_worldMins.z, _worldMaxs.z);
            data.density     = Config.Instance.PopulationDensity;
            data.zombieSpeed = _state.ZombieSpeed;
            data.timescale   = _state.Timescale;

            sender.SendData(cl, Viewer.DataType.Info, data);
        }
Beispiel #7
0
 void OnClientConnected(ViewServer sender, ViewServer.Client cl)
 {
     SendStaticState(sender, cl);
 }