Cycle 3 Update: Enemy Level Up Logic.

Android Programming Tutorial.

Android Code.

Because Cycle 3 is an “endless” type game, enemies level up by wave progress. Depending on the wave number, each enemy type will increase in point value, life and color profile. Here is the implementation of that logic.


protected static void setLevel() {
    Gdx.app.log(TAG, "setLevel");

    int wave = GS.get().getWaveNumber();

    // wave 1 = game start, set default values.
    if (wave == 1) {
        VALUE = 6;
        FULL_LIFE = 2;
        COLOR_PROFILE = 1;
    }

    // Every 2 waves level up.
    if (wave % 2 == 0) {
        VALUE ++;
        FULL_LIFE ++;
        COLOR_PROFILE = Math.min(COLOR_PROFILE + 1, RM.get().color_profile.size());
        Gdx.app.log(TAG, "Level Up! " + LEVEL);
        Gdx.app.log(TAG, "Value: " + VALUE);
        Gdx.app.log(TAG, "Life: " + FULL_LIFE);
    }
}

1: Static method declaration. No need to have copies of this method for each object. Only one shared by all.

7: If wave = 1 the cycle is starting. Setting all default values for this specific enemy.

14: Using the modulus arithmetical operator to check if the current wave is divisible by 2. This will guarantee that every 2 waves, the enemy will Level Up.

15-16: Static integers VALUE and FULL_LIFE increase by 1 when leveling up.

17: Static integer COLOR_PROFILE is use for selecting what color profile to use. RM.get().color_profile is a HashMap containing the color profiles for each level. Using Math.min() to make sure I don’t go over the list size() when requesting a color profile.