Пример #1
0
 public void subUnitFromArray(TossedGarbage triggerUnit)
 {
     if(CollectedTrash != null) {
         TossedGarbage[] CollectedTrashBuffer;
         if(CollectedTrash.Length == 1) {
             CollectedTrash = null;
         } else {
             int i = 0; int offset = 0; int nulls = 0;
             CollectedTrashBuffer = null;
             CollectedTrashBuffer = new TossedGarbage[CollectedTrash.Length];
             for(i = 0; i < CollectedTrash.Length;i++){
                 //modified to exclude the specified unit as well as any null values
                 if(CollectedTrash[i] == null || CollectedTrash[i] == triggerUnit){
                     nulls += 1;
                 } else {
                     CollectedTrashBuffer[i-nulls] = CollectedTrash[i];
                 }
             }
             CollectedTrash = null;
             CollectedTrash = new TossedGarbage[i-nulls];
             for(i = 0; i < CollectedTrashBuffer.Length-nulls;i++){
                 if(CollectedTrashBuffer[i] == triggerUnit) { //this should ALWAYS return false due to the previous for loop's conditions
                     offset -= 1;
                 } else {
                     CollectedTrash[i+offset] = CollectedTrashBuffer[i];
                 }
             }
         }
     }
 }
Пример #2
0
 public void addUnitToArray(TossedGarbage triggerUnit)
 {
     clearVoidsFromArray();
     bool duplicate = false;
     TossedGarbage[] CollectedTrashBuffer;
     if(CollectedTrash == null) {
         CollectedTrash = new TossedGarbage[1];
         CollectedTrash[0] = triggerUnit;
         //Debug.Log ("LeadUnit[" + triggerUnit.GetComponent<minimapDotScript>().team + "] " + triggerUnit.name);
     } else {
         int i = 0;
         CollectedTrashBuffer = null;
         CollectedTrashBuffer = new TossedGarbage[CollectedTrash.Length];
         for(i = 0; i < CollectedTrash.Length;i++){
             CollectedTrashBuffer[i] = CollectedTrash[i];
             if(CollectedTrash[i] == triggerUnit) { duplicate = true;
                 //Debug.Log ("Duplicate Unit!!");
             }
         }
         if(duplicate == false) {
             CollectedTrash = null;
             CollectedTrash = new TossedGarbage[CollectedTrashBuffer.Length + 1];
             //--  --//
             for(i = 0; i < CollectedTrashBuffer.Length;i++){
                 CollectedTrash[i] = CollectedTrashBuffer[i];
                 //Debug.Log ("Unit " + i + " " + CollectedTrash[i].name);
             }
             CollectedTrash[i] = triggerUnit;
             //Debug.Log ("AddedUnit[" + triggerUnit.GetComponent<minimapDotScript>().team + "] " + triggerUnit.name);
             //Debug.Log ("Unit " + i + " " + CollectedTrash[i].name);
         }
         //Debug.Log ("Duplicate Unit!! Can not add to array!");
     }
 }
Пример #3
0
 //--The next 150 lines or so were ripped from another project by C T to use for managing an array inside a trigger area.--//
 // A list might have been simpler... or just a function to return all overlapping actors.
 public GameObject getTargetSelected(int forTeam)
 {
     clearVoidsFromArray();
     if(CollectedTrash == null) return null;
     targetSelected = null;
     for(int i = 0; i < CollectedTrash.Length;i++){
         //if(CollectedTrash[i].teamNumber != forTeam){
             //if(CollectedTrash[i].checkTargetable(targeting)){
                 targetSelected = CollectedTrash[i];
             //}
         //}
     }
     if(targetSelected == null) {
         return null;
     } else {
         return targetSelected.transform.parent.gameObject;
     }
 }
Пример #4
0
 private void clearVoidsFromArray()
 {
     if(CollectedTrash != null) {
         TossedGarbage[] CollectedTrashBuffer;
         int i = 0; int offset = 0; int nulls = 0;
         CollectedTrashBuffer = null;
         CollectedTrashBuffer = new TossedGarbage[CollectedTrash.Length];
         for(i = 0; i < CollectedTrash.Length;i++){
             if(CollectedTrash[i] == null){
                 nulls += 1;
             } else {
                 CollectedTrashBuffer[i-nulls] = CollectedTrash[i];
             }
         }
         CollectedTrash = null;
         CollectedTrash = new TossedGarbage[i-nulls];
         for(i = 0; i < CollectedTrashBuffer.Length-nulls;i++){
             CollectedTrash[i] = CollectedTrashBuffer[i];
         }
     }
 }
Пример #5
0
 void AddToArray(TossedGarbage toAdd)
 {
     TossedGarbage[] CollectedTrashBuffer;
 }