Exemple #1
0
        private void ProcessServerEvent(GameEventsLogItem logItem)
        {
            if (logItem is GameObjectAddedLogItem)
            {
                var item = logItem as GameObjectAddedLogItem;

                // preventing repeated game objects adding (e.g. own plane or any another commited objects such as bullets)
                if (!m_clientWorld.ContainsGameObjectWithId(item.GameObject.Id.Value))
                {
                    UpdateMaxId(item.GameObject.Id.Value);

                    IntegrityDataHelper.ProcessRecieved(item.GameObject, m_clientWorld);

                    m_clientWorld.AddGameObject(item.GameObject);
                }
            }
            else if (logItem is GameObjectDeletedLogItem)
            {
                var item = logItem as GameObjectDeletedLogItem;

                m_deleteIdsQueue.Add(new Tuple <DateTime, int>(DateTime.Now, item.GameObjectId));
            }
            else if (logItem is BonusAppliedLogItem)
            {
                var item = logItem as BonusAppliedLogItem;

                Bonus bonus = (Bonus)m_clientWorld.GetObjectById(item.BonusId);
                Plane plane = (Plane)m_clientWorld.GetObjectById(item.PlaneId);

                if (bonus != null && plane != null)
                {
                    m_clientWorld.RaiseBonusAppliedEvent(bonus, plane);
                }
            }
            else if (logItem is GameObjectExplodedLogItem)
            {
                var item = logItem as GameObjectExplodedLogItem;

                GameObject exploded = m_clientWorld.GetObjectById(item.GameObjectId);

                if (exploded != null)
                {
                    m_clientWorld.RaiseExplosionEvent(exploded);
                }
            }
            else if (logItem is PlaneEquipmentAddedLogItem)
            {
                var item = logItem as PlaneEquipmentAddedLogItem;

                Plane plane = (Plane)m_clientWorld.GetObjectById(item.PlaneId);

                plane.AddEquipment(item.Equipment, item.EquipmentRelativeInfo);
            }
            else if (logItem is PlaneEquipmentRemovedLogItem)
            {
                var item = logItem as PlaneEquipmentRemovedLogItem;

                Plane          plane = (Plane)m_clientWorld.GetObjectById(item.PlaneId);
                PlaneEquipment equip = plane.GetEquipmentById(item.EquipmentId);

                plane.RemoveEquipment(equip);
            }
        }