Example #1
0
 public void Recycle(INetIncomingMessage msg)
 {
 }
Example #2
0
 /// <summary>
 /// Reads a pending message from any connection, if any.
 /// Returns true if message was read, otherwise false.
 /// </summary>
 /// <returns>True, if message was read.</returns>
 public bool ReadMessage(out INetIncomingMessage message)
 {
     message = ReadMessage();
     return message != null;
 }
Example #3
0
 public bool ReadMessage(out INetIncomingMessage message)
 {
     message = Messages.Dequeue();
     return Messages.Count <= 0;
 }
Example #4
0
        private void HandleData(INetIncomingMessage msg)
        {
            ServerMessage data = NetworkHelper.ReadMessage<ServerMessage>(msg);
            bool outOfDate = data.LocalSendTime <= _lastTimestamp;
            if (!outOfDate)
            {
                _lastTimestamp = data.LocalSendTime;
            }

            foreach (WallAdded added in data.WallsAdded)
            {
                added.WallCreate(Scene);
            }

            if (!outOfDate)
            {
                Scene.Time = data.SceneTime;

                foreach (TankData tankData in data.TankData)
                {
                    Tank tank;
                    Tanks.TryGetValue(tankData.OwnerId, out tank);

                    if (tank == null)
                    {
                        tank = tank ?? new Tank(Scene);
                        Tanks.Add(tankData.OwnerId, tank);

                        if (tankData.OwnerId == ServerId)
                        {
                            _tankCamera.SetTank(tank);
                        }
                    }

                    tankData.UpdateTank(tank);

                    _sceneUpdated = true;
                }

                foreach (BulletData bulletData in data.BulletData)
                {
                    Bullet bullet = (Bullet)Scene.GetAll().OfType<INetObject>().FirstOrDefault(item => item.ServerId == bulletData.ServerId);
                    if (bullet == null)
                    {
                        bullet = new Bullet(Scene, new Vector2(), new Vector2());
                    }
                    bulletData.UpdateBullet(bullet);
                }
            }

            PortalCommon.UpdateWorldTransform(Scene, true);
        }