예제 #1
0
 /// <summary>
 ///  Will synk the state of the given PrimitiveSet with this ObjectSets state
 /// </summary>
 /// <param name="primitiveGrid"></param>
 public void synkPrimitiveSet(PrimitiveSet primitiveGrid)
 {
     if (primitiveGrid != null)
     {
         resizePrimitiveIDs(primitiveGrid);
         if (enemySet != null)
         {
             for (int loopRow = 0; loopRow < enemySet.Length; loopRow++)
             {
                 if (enemySet[loopRow] != null)
                 {
                     for (int loopCollumn = 0; loopCollumn < enemySet[loopRow].Length; loopCollumn++)
                     {
                         primitiveGrid.getIDArray()[loopRow][loopCollumn] = -1;
                         if (enemySet[loopRow][loopCollumn] != null)
                         {
                             if (enemySet[loopRow][loopCollumn].ID <= 0)
                             {
                                 enemySet[loopRow][loopCollumn].ID = primitiveGrid.getUniqueID();
                             }
                             primitiveGrid.getIDArray()[loopRow][loopCollumn] = enemySet[loopRow][loopCollumn].ID;
                         }
                     }
                 }
             }
             primitiveGrid.resizeArrays();
             for (int loopRow = 0; loopRow < enemySet.Length; loopRow++)
             {
                 if (enemySet[loopRow] != null)
                 {
                     for (int loopCollumn = 0; loopCollumn < enemySet[loopRow].Length; loopCollumn++)
                     {
                         if (enemySet[loopRow][loopCollumn] != null)
                         {
                             primitiveGrid.getTypeArray()[loopRow][loopCollumn]            = (int)enemySet[loopRow][loopCollumn].getType();
                             primitiveGrid.getHealthIncrementArray()[loopRow][loopCollumn] = enemySet[loopRow][loopCollumn].getMaximumHealth();
                             //if((int)(primitiveGrid.getHealthArray()[loopRow][loopCollumn] * (float)enemySet[loopRow][loopCollumn].getMaximumHealth()) != enemySet[loopRow][loopCollumn].getHealth()){
                             primitiveGrid.getHealthArray()[loopRow][loopCollumn] = ((float)enemySet[loopRow][loopCollumn].getHealth() / (float)enemySet[loopRow][loopCollumn].getMaximumHealth());
                             //}
                             primitiveGrid.getScoreArray()[loopRow][loopCollumn]    = enemySet[loopRow][loopCollumn].getScore();
                             primitiveGrid.getRevealedArray()[loopRow][loopCollumn] = enemySet[loopRow][loopCollumn].isRevealed();
                         }
                     }
                 }
             }
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Will Find and return the column positions of the enemies affected by the light
 /// </summary>
 /// <param name="targetSet">the set of Enemies this Light will find targets in. Note if no IDArray was set this set cannot target any enemies </param>
 /// <returns>the array is organized as a 1D array[Number of Enemies Found] where array[?] = the column where an enemy was found.
 ///  Note: there is one entry per enemy found. So duplicate column entries indicate more than one enemy is targeted in the column in question</returns>
 public int[] getTargetedEnemyColumns(PrimitiveSet targetSet)
 {
     if (targetSet != null && targetSet.getIDArray() != null)
     {
         //Laser
         if (type == lightType.LASER)
         {
             return(getTargetedEnemyLocations1DLASER(targetSet.getIDArray(), currentPosition));
         }
         //Wide
         else if (type == lightType.WIDE)
         {
             return(getTargetedEnemyLocations1DWIDE(targetSet.getIDArray(), currentPosition));
         }
         //Mid
         else
         {
             return(getTargetedEnemyLocations1DMEDIUM(targetSet.getIDArray(), currentPosition));
         }
     }
     return(null);
 }
예제 #3
0
 /// <summary>
 /// Will resize the idArray in the given PrimitiveSet and will
 /// </summary>
 /// <param name="primitiveGrid"></param>
 private void resizePrimitiveIDs(PrimitiveSet primitiveGrid)
 {
     if (primitiveGrid != null && enemySet != null)
     {
         //Rows
         //Create
         if (primitiveGrid.getIDArray() == null)
         {
             int[][] newIDArray = new int[enemySet.Length][];
             for (int loopRow = 0; loopRow < enemySet.Length; loopRow++)
             {
                 newIDArray[loopRow] = null;
             }
             primitiveGrid.setIDArray(newIDArray);
         }
         //Resize
         else if (primitiveGrid.getIDArray().Length < enemySet.Length)
         {
             int[][] newIDArray = new int[enemySet.Length][];
             int     loop       = 0;
             while (loop < primitiveGrid.getIDArray().Length)
             {
                 newIDArray[loop] = primitiveGrid.getIDArray()[loop];
                 loop++;
             }
             while (loop < newIDArray.Length)
             {
                 newIDArray[loop] = null;
                 loop++;
             }
             primitiveGrid.setIDArray(newIDArray);
         }
         //Columns
         for (int loopRow = 0; loopRow < enemySet.Length; loopRow++)
         {
             if (enemySet[loopRow] != null)
             {
                 //Create
                 if (primitiveGrid.getIDArray()[loopRow] == null)
                 {
                     int[] newIDArray = new int[enemySet[loopRow].Length];
                     for (int loopCollumn = 0; loopCollumn < newIDArray.Length; loopCollumn++)
                     {
                         newIDArray[loopCollumn] = 0;
                     }
                     primitiveGrid.getIDArray()[loopRow] = newIDArray;
                 }
                 //Resize
                 else if (primitiveGrid.getIDArray()[loopRow].Length < enemySet[loopRow].Length)
                 {
                     int[] newIDArray  = new int[enemySet[loopRow].Length];
                     int   loopCollumn = 0;
                     while (loopCollumn < primitiveGrid.getIDArray()[loopRow].Length)
                     {
                         newIDArray[loopCollumn] = primitiveGrid.getIDArray()[loopRow][loopCollumn];
                         loopCollumn++;
                     }
                     while (loopCollumn < newIDArray.Length)
                     {
                         newIDArray[loopCollumn] = 0;
                         loopCollumn++;
                     }
                     primitiveGrid.getIDArray()[loopRow] = newIDArray;
                 }
             }
         }
     }
 }