コード例 #1
0
        public void AddHit(MissionLogEventHit e)
        {
            if (e == null)
            {
                return;
            }

            if (e.TargetObject != null)
            {
                e.TargetObject.AddHit((object)e.AttackerPlayer ?? e.AttackerObject, e);
            }
            else if (e.TargetPlayer != null)
            {
                e.TargetPlayer.AddHit((object)e.AttackerPlayer ?? e.AttackerObject, e);
            }

            if (e.AttackerPlayer != null)
            {
                e.AttackerPlayer.Hits++;
            }
        }
コード例 #2
0
ファイル: ActionScriptBase.cs プロジェクト: xedoc/IL2CDR
 /// <summary>
 /// Hit, ammo/explosion. For live events only. Doesn't run on history events
 /// </summary>
 /// <param name="data"></param>
 virtual public void OnHit(MissionLogEventHit data)
 {
 }
コード例 #3
0
ファイル: GameObjectBase.cs プロジェクト: xedoc/IL2CDR
        public void AddHit(object source, MissionLogEventHit e)
        {
            if (source == null || e == null || String.IsNullOrWhiteSpace(e.AmmoName))
            {
                return;
            }

            if (source is GameObject)
            {
                var existing = HitsSources.FirstOrDefault(o =>
                                                          o != null &&
                                                          o.Hits != null &&
                                                          o.Object != null &&
                                                          o.Object.Id == (source as GameObject).Id);

                if (existing == null)
                {
                    existing = new HitsSource()
                    {
                        Object = source as GameObject,
                    };

                    HitsSources.Add(existing);
                }
                var hits = existing.Hits[e.AmmoName];
                if (hits == null)
                {
                    existing.Hits[e.AmmoName] = new Hit(e.AmmoName)
                    {
                        HitCount = 1
                    }
                }
                ;
                else
                {
                    existing.Hits[e.AmmoName].HitCount++;
                }
            }
            else if (source is Player)
            {
                var existing = HitsSources.FirstOrDefault(o =>
                                                          o != null &&
                                                          o.Hits != null &&
                                                          o.Player != null &&
                                                          o.Player.Id == (source as Player).Id
                                                          );

                if (existing == null)
                {
                    existing = new HitsSource()
                    {
                        Player = source as Player,
                    };

                    HitsSources.Add(existing);
                }
                var hits = existing.Hits[e.AmmoName];
                if (hits == null)
                {
                    existing.Hits[e.AmmoName] = new Hit(e.AmmoName)
                    {
                        HitCount = 1
                    }
                }
                ;
                else
                {
                    existing.Hits[e.AmmoName].HitCount++;
                }
            }
        }