Exemplo n.º 1
0
 public void SetDetectedGroup()
 {
     if (RefersToUnit == null)
     {
         return;
     }
     if (string.IsNullOrEmpty(RefersToUnit.GroupId))
     {
         return;
     }
     foreach (var det in OwnerPlayer.DetectedUnits)
     {
         if (!det.IsMarkedForDeletion && det.Id != this.Id && det.RefersToUnit != null)
         {
             if ((!string.IsNullOrEmpty(det.RefersToUnit.GroupId)) &&
                 det.RefersToUnit.GroupId == this.RefersToUnit.GroupId)
             {
                 var detGroup = det.GetDetectedGroup();
                 if (detGroup != null)
                 {
                     detGroup.AddUnit(this);
                     detGroup.IsMarkedForDeletion = false;
                 }
                 else
                 {
                     detGroup = new DetectedGroup();
                     detGroup.AddUnit(det);
                     detGroup.AddUnit(this);
                     OwnerPlayer.DetectedGroups.Add(detGroup);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 public DetectedGroup GetDetectedGroup()
 {
     if (!string.IsNullOrEmpty(DetectedGroupId))
     {
         try
         {
             DetectedGroup det = this.OwnerPlayer.DetectedGroups.Find(d => !d.IsMarkedForDeletion && d.Id == this.DetectedGroupId);
             return(det);
         }
         catch (Exception)
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }