예제 #1
0
 /**
  * Will insert the given BaseEnemy at the given location if possible and will remove any enemy residing at that location already
  * @param newEnemy the given BaseEnemy
  * @param row the row the enemy will be placed in
  * @param collumn the collumn the enemy will be placed in
  * @return whether or not the enemy was successfully added
  */
 public bool addEnemy(BaseEnemy newEnemy, int row, int collumn)
 {
     if (newEnemy != null && doesGridPositionExist(row, collumn) && !isActiveEnemy(newEnemy))
     {
         if (enemySetPrime[row][collumn] != null)
         {
             removeEnemy(enemySetPrime[row][collumn]);
         }
         enemySetPrime[row][collumn] = newEnemy;
         newEnemy.setPosition(row, collumn, this);
         newEnemy.setAnimationTarget(row, collumn);
         BaseCode.activeDrawSet.addToDrawSet(newEnemy);
         return(true);
     }
     return(false);
 }
예제 #2
0
 /**
  * Will Attempt to move the Given Enemy to the given position
  * Note this function requires that the Given BaseEnemy be already active in the set
  * Enemy enemy already at the target position will be removed from the set;
  * Assums that the
  * @param moveTarget BaseEnemy you wish to move
  * @param row		Target row to move too
  * @param collumn	Target column to move too
  * @return			True if the Enemy was either moved to a different location in the set or moved into the set for the first time
  */
 public bool moveEnemy(BaseEnemy moveTarget, int row, int collumn)
 {
     if (moveTarget != null && doesGridPositionExist(row, collumn))
     {
         //Moving Enemy to position
         if (isActiveEnemy(moveTarget))
         {
             //Enemy is not at current position
             if (row != moveTarget.currentRow || collumn != moveTarget.currentCollumn)
             {
                 if (enemySetPrime[row][collumn] != null)
                 {
                     removeEnemy(enemySetPrime[row][collumn]);
                 }
                 enemySetPrime[row][collumn] = moveTarget;
                 enemySetPrime[moveTarget.currentRow][moveTarget.currentCollumn] = null;
                 moveTarget.setPosition(row, collumn, this);
                 moveTarget.setAnimationTarget(row, collumn);
             }
             //Enemy is already at the desired position
             else
             {
                 return(false);
             }
         }
         //adding Enemy
         else
         {
             if (enemySetPrime[row][collumn] != null)
             {
                 removeEnemy(enemySetPrime[row][collumn]);
             }
             enemySetPrime[row][collumn] = moveTarget;
             moveTarget.setPosition(row, collumn, this);
             BaseCode.activeDrawSet.addToDrawSet(moveTarget);
         }
         return(true);
     }
     return(false);
 }
예제 #3
0
 /**
  * Will update the subject based on the settings in the representative
  * @param hostSet the Enemy set that is in change of storing all of the BaseEnemies in use
  * @param puasetime the amount of time the game will pause for animations to proceed
  * @return whether or not any changes were made that actually require the game to pause
  * This includes revealing a Enemy, and Moving an enemy
  */
 internal StateChange updateSubject(EnemySet hostSet, int puasetime)
 {
     if (hostSet != null)
     {
         //Matching EnemyTypes and moving/Adding Enemy to appropriate array position
         if (subject == null)
         {
             subject = createEnemy(type);
             storedStateChangeObject.puaseForAnimation = hostSet.addEnemy(subject, currentRow, currentCollumn);
         }
         else if (subject.type != type)
         {
             if (type == InteractableObject.ObjectType.GHOST && subject.type == InteractableObject.ObjectType.ANGRY)
             {
                 ((Ghost)subject).MakeNotAngry();
                 storedStateChangeObject.puaseForAnimation = hostSet.moveEnemy(subject, currentRow, currentCollumn);
             }
             else if (type == InteractableObject.ObjectType.ANGRY && subject.type == InteractableObject.ObjectType.GHOST)
             {
                 ((Ghost)subject).MakeAngry();
                 storedStateChangeObject.puaseForAnimation = hostSet.moveEnemy(subject, currentRow, currentCollumn);
             }
             else
             {
                 subject.removeThis();
                 BaseEnemy newSubject = createEnemy(type);
                 newSubject.setCenter(subject.getCenterX(), subject.getCenterY());
                 subject = newSubject;
                 hostSet.addEnemy(subject, currentRow, currentCollumn);
                 storedStateChangeObject.puaseForAnimation = false;
             }
         }
         else
         {
             storedStateChangeObject.puaseForAnimation = hostSet.moveEnemy(subject, currentRow, currentCollumn);
         }
         //Updating reveal state infect state etc..
         subject.representative = (InteractableObject)this;
         subject.setInfectStatus(infectedTimer);
         subject.getHealth().setMaxSegments(maxHealth);
         subject.getHealth().setFilledSegments(currentHealth);
         subject.setScore(score);
         subject.circleEnemy(highlighted);
         //updating animation
         subject.setAnimationTarget(currentRow, currentCollumn);
         //updating Partial Reveal status
         if (subject.isPartialRevealed != partialRevealed && !revealed)
         {
             if (partialRevealed)
             {
                 subject.partialReveal();
             }
             else
             {
                 subject.unrevealType();
             }
         }
         //updating reveal state
         if (subject.isTypeRevealed != revealed)
         {
             subject.setToReveal = true;
         }
         subject.setInvulnerablility(invulnerable);
     }
     return(storedStateChangeObject);
 }