private void checkForDeactivateCannonball(CannonballIndividual cannonballClass, bool isEnemyCannonball) { // if cannonball is currently inactive, return if (!cannonballClass.getIsMoving()) { return; } // if cannonball's lifetime is 0, or if it hits a wall/door (enemy collision will happen someplace else) // call a 'makeInactive' funcion on the cannonball, and place two new wakes there. // if (cannonballClass.checkForTimeout() || !BoolArrayManager.checkForConflict_V3(boolArray, doorHitboxManager, cannonballClass.getCannonballPosition())) // if (cannonballClass.checkForTimeout() || !BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition())) // if (cannonballClass.checkForTimeout() || // ((isEnemyCannonball || !cannonData.getPassesThroughWalls()) && !BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition()))) // { // deactivateCannonball(cannonballClass); // } // Check to see if the cannonball has timed out: if (cannonballClass.checkForTimeout()) { deactivateCannonball(cannonballClass); return; } // Then check to see if it has hit a target: if (isEnemyCannonball) { // The enemy's cannonballs: if (gameView.checkIfCannonballHasHitPlayer(cannonballClass.getCannonballPosition(), cannonballClass.getCannonballDirection())) { deactivateCannonball(cannonballClass); cannonBonkManager.placeNewBonk(cannonballClass.getCannonballPosition(), 1f, false); return; } if (!BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition())) { deactivateCannonball(cannonballClass); return; } } else { // The player's cannonballs: if (enemyManager.checkIfCannonballHasHitEnemy(cannonballClass.getCannonballPosition(), cannonballClass.getCannonballDirection())) { deactivateCannonball(cannonballClass); // cannonBonkManager.placeNewBonk(cannonballClass.getCannonballPosition() + cannonballClass.getCannonballDirection() * 2f, cannonData.getBonkSize(), true); if (cannonData.getExplodes()) { makeCannonballExplode(cannonballClass.getCannonballPosition()); } else { cannonBonkManager.placeNewBonk(cannonballClass.getCannonballPosition() + cannonballClass.getCannonballDirection() * 2f, cannonData.getBonkSize(), true); } return; } if (!cannonData.getPassesThroughWalls() && !BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition())) { deactivateCannonball(cannonballClass); if (cannonData.getExplodes()) { makeCannonballExplode(cannonballClass.getCannonballPosition()); } return; } } }
private void deactivateCannonball(CannonballIndividual cannonballClass) { cannonballClass.stopCannonball(); wakeController.cannonballSplashesAtLocation(cannonballClass.getCannonballPosition()); }
public void moveAllActiveCannonballs() { for (byte index = 0; index < numOfCannonballs_player; index++) { tempCannonballClass = cannonballArray_player[index]; tempCannonballClass.advanceAnimation(); if (cannonData.getAutoTargets()) { tempCannonballClass.rotateDirectionToTarget(enemyManager.findClosestEnemy_noRestriction(tempCannonballClass.getCannonballPosition(), Constants.roomWidthHeight), Constants.cannonAutoTargetingSpeed); } checkForDeactivateCannonball(tempCannonballClass, false); // if (tempCannonballClass.getIsMoving() && enemyManager.checkIfCannonballHasHitEnemy(tempCannonballClass.getCannonballPosition(), tempCannonballClass.getCannonballDirection())) // { // deactivateCannonball(tempCannonballClass); // cannonBonkManager.placeNewBonk(tempCannonballClass.getCannonballPosition() + tempCannonballClass.getCannonballDirection() * 2f, color_cannonballPlayer, cannonData.getCannonballSize()/5f); // } } for (byte index = 0; index < numOfCannonballs_enemy; index++) { tempCannonballClass = cannonballArray_enemies[index]; tempCannonballClass.advanceAnimation(); checkForDeactivateCannonball(tempCannonballClass, true); // if (tempCannonballClass.getIsMoving() && gameView.checkIfCannonballHasHitPlayer(tempCannonballClass.getCannonballPosition(), tempCannonballClass.getCannonballDirection())) // { // deactivateCannonball(tempCannonballClass); // cannonBonkManager.placeNewBonk(tempCannonballClass.getCannonballPosition(), color_cannonballEnemy, 1f); // // cameraManager.playDamageShakeAnimation(); // } } wakeController.updateWakes(); cannonBonkManager.advanceAllCannonbonkAnimations(); explosionDamageManager.advanceAnimation(); }