Esempio n. 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()
                {
                    list = list
                };

                sender.SendData(cl, Viewer.DataType.ActiveZombies, data);
            }
        }
Esempio n. 2
0
 void SendStaticState(ViewServer sender, ViewServer.Client cl)
 {
     lock (sender)
     {
         SendState(sender, cl);
         SendWorldZones(sender, cl);
         SendPOIZones(sender, cl);
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 5
0
        void SendInactiveZombieList(ViewServer sender, ViewServer.Client?cl)
        {
            if (sender == null)
            {
                return;
            }

            lock (_inactiveZombies)
            {
                if (_inactiveZombies.Count == 0)
                {
                    return;
                }

                var waiting  = new List <Viewer.DataZombie>();
                var inactive = new List <Viewer.DataZombie>();
                foreach (var zombie in _inactiveZombies)
                {
                    Vector2i p    = WorldToBitmap(zombie.pos);
                    var      list = zombie.state == ZombieAgent.State.Waiting ? waiting : inactive;
                    list.Add(new Viewer.DataZombie
                    {
                        id = zombie.id,
                        x  = p.x,
                        y  = p.y,
                    });
                }

                var inactiveData = new Viewer.ZombieList()
                {
                    list = inactive
                };

                sender.SendData(cl, Viewer.DataType.InactiveZombies, inactiveData);

                var waitingData = new Viewer.ZombieList()
                {
                    list = waiting
                };

                sender.SendData(cl, Viewer.DataType.WaitingZombies, waitingData);
            }
        }
Esempio n. 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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        void SendSoundEvent(ViewServer sender, Vector3 pos, float radius)
        {
            if (sender == null)
            {
                return;
            }

            var p    = WorldToBitmap(pos);
            var data = new Viewer.WorldEventSound();

            data.x = p.x;
            data.y = p.y;
            // FIXME: This is only remapped in one direction.

            var worldSize = Utils.Distance(_worldMins.x, _worldMaxs.x);
            var rescaled  = (radius / worldSize) * 512.0f;

            data.distance = (int)rescaled;

            Logger.Info("Distance {0}, Scaled: {1}", radius, data.distance);

            sender.Broadcast(Viewer.DataType.WorldEventSound, data);
        }
Esempio n. 9
0
 void OnClientConnected(ViewServer sender, ViewServer.Client cl)
 {
     SendStaticState(sender, cl);
 }