Пример #1
0
 private void MergeInput()
 {
     if (Input.GetKeyDown(KeyCode.D) && this.ownerSelectable.isSelected && !(this.ownerAttackable.isReadyToAttack || this.ownerAttackable.isAttacking))
     {
         Analytics.Instance.AddEvent("D key pressed to merge " + Selectable.selectedObjects.Count.ToString() + " units.");
         this.ownerSelectable.Deselect();
         //this.ownerSelectable.DisableSelection();
         if (this.playerNetworkView != null)
         {
             foreach (Selectable sel in Selectable.selectedObjects)
             {
                 sel.Deselect();
                 sel.isBoxSelected = false;
             }
             int count      = Selectable.selectedObjects.Count;
             int countCheck = count;
             int index      = 0;
             while (count >= 2 && countCheck > 0)
             {
                 Selectable firstSelectable  = Selectable.selectedObjects[index];
                 Selectable secondSelectable = Selectable.selectedObjects[index + 1];
                 if (firstSelectable != null && secondSelectable != null)
                 {
                     Level levelFirst  = firstSelectable.gameObject.GetComponent <Level>();
                     Level levelSecond = secondSelectable.gameObject.GetComponent <Level>();
                     if (levelFirst != null && levelSecond != null && (levelFirst.Compare(levelSecond) == Level.EQUALS))
                     {
                         NetworkView firstNetworkView  = firstSelectable.GetComponent <NetworkView>();
                         NetworkView secondNetworkView = secondSelectable.GetComponent <NetworkView>();
                         this.playerNetworkView.RPC("RPC_AddPair", RPCMode.AllBuffered, firstNetworkView.viewID, secondNetworkView.viewID);
                         firstSelectable.DisableSelection();
                         secondSelectable.DisableSelection();
                         Selectable.selectedObjects.Remove(firstSelectable);
                         Selectable.selectedObjects.Remove(secondSelectable);
                     }
                     else
                     {
                         Selectable.selectedObjects.Remove(firstSelectable);
                         Selectable.selectedObjects.Add(firstSelectable);
                         countCheck--;
                         continue;
                     }
                 }
                 else
                 {
                     index++;
                     if (index > count)
                     {
                         break;
                     }
                     countCheck = count;
                     continue;
                 }
                 count     -= 2;
                 countCheck = count;
             }
             Selectable.selectedObjects.Clear();
         }
     }
 }