Example #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);
            }
        }
Example #2
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);
            }
        }