コード例 #1
0
    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;
            }
        }
    }