public PlaneEquipmentAddedLogItem(Timestamp timestamp, Plane plane, PlaneEquipment equipment)
     : base(timestamp)
 {
     PlaneId               = plane.Id.Value;
     Equipment             = equipment;
     EquipmentRelativeInfo = plane.GetEquipmentRelativeInfo(equipment);
 }
Exemple #2
0
        /// <summary>
        /// Applies mutable information recieved from client (e.g. exepts plane health).
        /// <para>This function should be invoked on server-side.</para>
        /// </summary>
        public void ApplyToPlayerPlaneOnServer(Plane ownPlane)
        {
            base.Apply(ownPlane);

            //m_healthPrivateFieldAccessor.SetValue(obj, Health);

            foreach (var equipmentMutable in EquipmentMutableInformation)
            {
                PlaneEquipment equipment = ((IHaveEquipment <PlaneEquipment>)ownPlane).AllEquipment.Single(e => e.Id == equipmentMutable.Id);

                equipmentMutable.Apply(equipment);
            }
        }
Exemple #3
0
        public override void Apply(object obj)
        {
            base.Apply(obj);

            m_healthPrivateFieldAccessor.SetValue(obj, Health);

            foreach (var equipmentMutable in EquipmentMutableInformation)
            {
                PlaneEquipment equipment = ((IHaveEquipment <PlaneEquipment>)obj).AllEquipment.Single(e => e.Id == equipmentMutable.Id);

                equipmentMutable.Apply(equipment);
            }
        }
Exemple #4
0
 public PlaneEquipmentRemovedLogItem(Timestamp timestamp, Plane plane, PlaneEquipment equipment)
     : base(timestamp)
 {
     PlaneId     = plane.Id.Value;
     EquipmentId = equipment.Id;
 }
Exemple #5
0
        public void Draw(SpriteBatch spriteBatch, Rectangle position, Color backgroundColor, Color color, Color textColor, PlaneEquipment equipment)
        {
            ++m_drawCount;

            Draw(
                spriteBatch,
                position,
                equipment.Charge / equipment.MaximumCharge,
                backgroundColor,
                color,
                equipment.Info,
                textColor);

            if (equipment.IsLowCharge)
            {
                const float lowChargeMarkIndention = 4;
                float       lowChargreMarkHeight   = position.Height - 2 * lowChargeMarkIndention;
                float       scale = lowChargreMarkHeight / m_lowChargeTexture.Height;

                Vector2 center = new Vector2(m_lowChargeTexture.Width / 2.0f, m_lowChargeTexture.Height / 2.0f);

                spriteBatch.Draw(
                    m_lowChargeTexture,
                    new Vector2(lowChargeMarkIndention + position.X + center.X * scale, lowChargeMarkIndention + position.Y + +center.Y * scale),
                    null,
                    Color.White * 0.8f,
                    0,
                    center,
                    scale * (float)(1f + Math.Sin(m_drawCount / 50.0) / 10f),
                    SpriteEffects.None,
                    0);
            }
        }
Exemple #6
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);
            }
        }