Android Open Source - ninja-trials Game Manager






From Project

Back to project page ninja-trials.

License

The source code is released under:

Apache License

If you think the Android project ninja-trials listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Ninja Trials is an old school style Android Game developed for OUYA & using
 * AndEngine. It features several minigames with simple gameplay.
 * Copyright 2013 Mad Gear Games <madgeargames@gmail.com>
 */*  w ww  . j av a  2  s .  c om*/
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package com.madgear.ninjatrials.managers;

import com.madgear.ninjatrials.ResultTrial;
import com.madgear.ninjatrials.achievements.AchievementSetNinjaTrial;
import com.madgear.ninjatrials.records.RecordsTableSet;


public class GameManager {

    //private static GameManager INSTANCE;

    // GENERAL:
    // Use DEBUG_MODE = true for show the testing scene.
    public static final boolean DEBUG_MODE = true;

   
    // Use ACHIEV_DEBUG_MODE = true for test values in achievments (easier goals).
    public static final boolean ACHIEV_DEBUG_MODE = true;

    private static final int SCORE_INIT = 0;
    public static final int LIVES_INIT = 3;

    public static final int CHAR_RYOKO = 0;
    public static final int CHAR_SHO = 1;
    
    public static final int PLAYER_LEFT = 0;
    public static final int PLAYER_RIGHT = 1;
    
    public static final int DIFF_EASY = 0;
    public static final int DIFF_MEDIUM = 1;
    public static final int DIFF_HARD = 2;

    // Trials are ordered by its integer value
    public static final int TRIAL_RUN = 1;
    public static final int TRIAL_CUT = 2;
    public static final int TRIAL_JUMP = 3;
    public static final int TRIAL_SHURIKEN = 4;
    public static final int TRIAL_FINAL = TRIAL_SHURIKEN;
    public static final int TRIAL_START = TRIAL_RUN;

    public static final int SEQUENCE_SKIP_DIRECTLY = 0;
    public static final int SEQUENCE_ASK_BEFORE_SKIP = 1;
    public static final int SEQUENCE_CANNOT_SKIP = 2;


    public static int sequenceBehaviourAtPress = SEQUENCE_SKIP_DIRECTLY;

    public static ResultTrial player1result;
    public static ResultTrial player2result;

    private static AchievementSetNinjaTrial player1achiev;
    private static AchievementSetNinjaTrial player2achiev;

    public static RecordsTableSet recordsTableSet;
    
    private static int score;
    private static int currentTrial;
    private static int lives;
    private static int selectedCharacter;
    private static int selectedDiff;
    private static String gameLanguage;
    
    public static float gameMenuInitTime;
    public static float gamePlayedTime;


/*    // Contructor:
    GameManager(){
    }

    public static GameManager getInstance(){
        if(INSTANCE == null){
            INSTANCE = new GameManager();
        }
        return INSTANCE;
    }*/

    
    // Mtodos:

    public static void resetGame(){
        score = SCORE_INIT;
        lives = LIVES_INIT;
        currentTrial = TRIAL_START;
        selectedCharacter = CHAR_SHO;
        selectedDiff = DIFF_MEDIUM;
        gameLanguage = "en";
        player1result = new ResultTrial();
        player2result = new ResultTrial();
        player1achiev = new AchievementSetNinjaTrial();
        player2achiev = new AchievementSetNinjaTrial();
        recordsTableSet = new RecordsTableSet();
    }
    
    /**
     * Called when press PLAY in the main Menu Scene.
     */
    public static void newGame() {
        score = SCORE_INIT;
        lives = LIVES_INIT;
        currentTrial = TRIAL_START;
        player1result = new ResultTrial();
        player2result = new ResultTrial();
    }
    
    public static void endGame() {
        // GAME EXIT:
        if (ResourceManager.getInstance().engine != null) {
            SceneManager.getInstance().mCurrentScene.onHideManagedScene();
            SceneManager.getInstance().mCurrentScene.onUnloadManagedScene();
            ResourceManager.getInstance().unloadHUDResources();
            ResourceManager.getInstance().unloadFonts();
            System.exit(0);
        }
    }
    
    public static void setSelectedCharacter(int c) {
        selectedCharacter = c;
    }
    
    public static int getSelectedCharacter() {
        return selectedCharacter;
    }

    public static void setSelectedDiff(int d) {
        selectedDiff = d;
    }
    
    public static int getSelectedDiff() {
        return selectedDiff;
    }

    public static int getCurrentScore(){
        return score;
    }

    public static String getGameLanguage() {
        return gameLanguage;
    }

    public static void incrementScore(int pIncrementBy){
        score += pIncrementBy;
    }
    
    public static void resetScore() {
        score = 0;
    }

    public static int getCurrentTrial() {
        return currentTrial;
    }
    
    public static void setCurrentTrial(int t) {
        currentTrial = t;
    }
    
    public static int nextTrial(int currentTrial) {
        if (currentTrial < TRIAL_FINAL)
            return (currentTrial + 1);
        else return -1;
    }
    
    public static int previousTrial(int currentTrial) {
        if (currentTrial > TRIAL_START)
            return (currentTrial - 1);
        else return -1;
    }

    public static int getLives() {
        return lives;
    }

    public static void setLives(int t) {
        lives = t;
    }
    
    public static AchievementSetNinjaTrial getAchievSet() {
        return player1achiev;
    }
    
    public static void setAchievSet(AchievementSetNinjaTrial achievSet) {
        player1achiev = achievSet;
    }
}




Java Source Code List

com.madgear.ninjatrials.AchievementsScene.java
com.madgear.ninjatrials.CharacterIntroScene.java
com.madgear.ninjatrials.ControllerOptionsScene.java
com.madgear.ninjatrials.DummyMenu.java
com.madgear.ninjatrials.GameScene.java
com.madgear.ninjatrials.IUserInput.java
com.madgear.ninjatrials.MainMenuScene.java
com.madgear.ninjatrials.MainOptionsScene.java
com.madgear.ninjatrials.ManagedLayer.java
com.madgear.ninjatrials.ManagedScene.java
com.madgear.ninjatrials.MapScene.java
com.madgear.ninjatrials.NinjaTrials.java
com.madgear.ninjatrials.PlayerSelectionScene.java
com.madgear.ninjatrials.RecordsScene.java
com.madgear.ninjatrials.ResultLoseScene.java
com.madgear.ninjatrials.ResultTrial.java
com.madgear.ninjatrials.ResultWinScene.java
com.madgear.ninjatrials.achievements.AchievementSetNinjaTrial.java
com.madgear.ninjatrials.achievements.AchievementSet.java
com.madgear.ninjatrials.achievements.Achievement.java
com.madgear.ninjatrials.hud.AchievementNotify.java
com.madgear.ninjatrials.hud.Chronometer.java
com.madgear.ninjatrials.hud.GameHUD.java
com.madgear.ninjatrials.hud.HeadCharacter.java
com.madgear.ninjatrials.hud.PowerBar.java
com.madgear.ninjatrials.hud.PrecisionAngleBar.java
com.madgear.ninjatrials.hud.PrecisionBar.java
com.madgear.ninjatrials.hud.SelectionStripe.java
com.madgear.ninjatrials.hud.ShurikenEnemyCounter.java
com.madgear.ninjatrials.hud.VolumeBar.java
com.madgear.ninjatrials.layers.GameOverLayer.java
com.madgear.ninjatrials.managers.GameManager.java
com.madgear.ninjatrials.managers.ResourceManager.java
com.madgear.ninjatrials.managers.SFXManager.java
com.madgear.ninjatrials.managers.SceneManager.java
com.madgear.ninjatrials.managers.UserData.java
com.madgear.ninjatrials.records.Record.java
com.madgear.ninjatrials.records.RecordsTableSet.java
com.madgear.ninjatrials.records.RecordsTable.java
com.madgear.ninjatrials.sequences.CreditsScene.java
com.madgear.ninjatrials.sequences.EndingScene.java
com.madgear.ninjatrials.sequences.EndingSequenceRyokoEasy.java
com.madgear.ninjatrials.sequences.EndingSequenceShoEasy.java
com.madgear.ninjatrials.sequences.Intro1Scene.java
com.madgear.ninjatrials.sequences.Intro2Scene.java
com.madgear.ninjatrials.sequences.Intro2SequenceRyokoEasy.java
com.madgear.ninjatrials.sequences.Intro2SequenceShoEasy.java
com.madgear.ninjatrials.sequences.Sequence.java
com.madgear.ninjatrials.sequences.SplashIntroScene.java
com.madgear.ninjatrials.trials.TrialSceneCut.java
com.madgear.ninjatrials.trials.TrialSceneJump.java
com.madgear.ninjatrials.trials.TrialSceneRun.java
com.madgear.ninjatrials.trials.TrialSceneShuriken.java
com.madgear.ninjatrials.trials.run.RunBg.java
com.madgear.ninjatrials.trials.run.RunCharacter.java
com.madgear.ninjatrials.trials.shuriken.ShurikenCoordinates.java
com.madgear.ninjatrials.trials.shuriken.ShurikenEnemy.java
com.madgear.ninjatrials.trials.shuriken.ShurikenHands.java
com.madgear.ninjatrials.trials.shuriken.ShurikenShuriken.java
com.madgear.ninjatrials.utils.AutoDiagonalParallaxBackground.java
com.madgear.ninjatrials.utils.AutoHorizontalParallaxBackground.java
com.madgear.ninjatrials.utils.AutoVerticalParallaxBackground.java
com.madgear.ninjatrials.utils.ParallaxBackground2d.java