Пример #1
0
 protected void Update()
 {
     if (this.splitGroups.Count > 0)
     {
         for (int i = 0; i < this.splitGroups.Count; i++)
         {
             SplitGroup group = this.splitGroups[i];
             if (group.elapsedTime < 1f)
             {
                 group.owner.transform.position = Vector3.Lerp(group.center, group.ownerTarget, group.elapsedTime);
                 group.clone.transform.position = Vector3.Lerp(group.center, group.cloneTarget, group.elapsedTime);
                 group.elapsedTime  += Time.deltaTime;
                 this.splitGroups[i] = group;
                 //TODO(Thompson): Test to see if "ref" keyword works.
                 //MovePosition(ref group);
                 //UpdateTime(ref group);
             }
             else
             {
                 if (!this.removeList.Contains(group))
                 {
                     this.removeList.Add(group);
                 }
             }
         }
     }
     if (this.removeList.Count > 0)
     {
         foreach (SplitGroup group in this.removeList)
         {
             if (this.splitGroups.Contains(group))
             {
                 CommonUnit unit = group.owner.GetComponent <CommonUnit>();
                 unit.EnableSelection();
                 unit.SetNotSplitting();
                 unit = group.clone.GetComponent <CommonUnit>();
                 unit.EnableSelection();
                 unit.SetNotSplitting();
                 this.splitGroups.Remove(group);
             }
         }
         this.removeList.Clear();
     }
 }
Пример #2
0
 protected void Update()
 {
     if (this.mergeGroups.Count > 0)
     {
         for (int i = 0; i < this.mergeGroups.Count; i++)
         {
             MergeGroup group = this.mergeGroups[i];
             if (group.elapsedTime < 1f)
             {
                 group.owner.transform.position    = Vector3.Lerp(group.ownerOrigin, group.center, group.elapsedTime);
                 group.merger.transform.position   = Vector3.Lerp(group.mergerOrigin, group.center, group.elapsedTime);
                 group.owner.transform.localScale  = Vector3.Lerp(group.initialLocalScale, group.newLocalScale, group.elapsedTime);
                 group.merger.transform.localScale = Vector3.Lerp(group.initialLocalScale, group.newLocalScale, group.elapsedTime);
                 group.elapsedTime  += Time.deltaTime;
                 this.mergeGroups[i] = group;
             }
             else
             {
                 this.removeList.Add(this.mergeGroups[i]);
             }
         }
     }
     if (this.removeList.Count > 0)
     {
         foreach (MergeGroup group in this.removeList)
         {
             if (this.mergeGroups.Contains(group))
             {
                 CommonUnit unit = group.owner.GetComponent <CommonUnit>();
                 unit.EnableSelection();
                 unit.SetNotMerging();
                 if (this.unitManager.getAllObjects().Contains(group.merger))
                 {
                     this.unitManager.getAllObjects().Remove(group.merger);
                 }
                 GameObject.Destroy(group.merger);
                 this.mergeGroups.Remove(group);
             }
         }
         this.removeList.Clear();
     }
 }