Package com.aqpproject.game

Source Code of com.aqpproject.game.Singleton

/*
* AQP Project
* http://http://code.google.com/p/aqp-project/
* Alexandre Gomez - Clément Troesch - Fabrice Latterner
*/
package com.aqpproject.game;

import com.aqpproject.ia.IA;
import com.aqpproject.ia.game.IAGame;
import com.aqpproject.input.Input;
import com.aqpproject.input.gdx.InputGDX;
import com.aqpproject.network.Network;
import com.aqpproject.network.game.NetworkGame;
import com.aqpproject.physics.Physics;
import com.aqpproject.physics.gdx.PhysicsGDX;
import com.aqpproject.sound.SoundController;
import com.aqpproject.visualisation.Visualisation;
import com.aqpproject.visualisation.gdx.VisualisationGDX;
import com.aqpproject.worldmodel.OptionsController;
import com.aqpproject.worldmodel.RandomController;
import com.aqpproject.worldmodel.WorldModel;
import com.aqpproject.worldmodel.game.WorldModelGame;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;

/**
* Singleton factory
*
* @author Alexandre, Clement, Fabrice
*/
public class Singleton {

    /**
     * @return the input component singleton
     */
    public static Input getInput() {
        if (m_input == null) {
            m_input = new InputGDX();
        }
        return m_input;
    }

    /**
     * @return the visualisation component singleton
     */
    public static Visualisation getVisualisation() {
        if (m_visualisation == null) {
            m_visualisation = new VisualisationGDX();
        }
        return m_visualisation;
    }

    /**
     * @return the world model component singleton
     */
    public static WorldModel getWorldModel() {
        if (m_worldmodel == null) {
            m_worldmodel = new WorldModelGame();
        }
        return m_worldmodel;
    }

    /**
     * @return the physics component singleton
     */
    public static Physics getPhysics() {
        if (m_physics == null) {
            m_physics = new PhysicsGDX();
        }
        return m_physics;
    }

    public static SoundController getAudioController() throws ParserConfigurationException, SAXException, IOException {
        if (m_audioController == null) {
            m_audioController = new SoundController("config\\musics.xml", "config\\sounds.xml", "config\\playlists.xml");
        }
        return m_audioController;
    }

    /**
     * @return the network component singleton
     */
    public static Network getNetwork() {
        if (m_network == null) {
            m_network = new NetworkGame();
        }
        return m_network;
    }

    public static IA getIA() {
        if (m_ia == null) {
            m_ia = new IAGame();
        }
        return m_ia;
    }

    public static OptionsController getOptionsController() {
        if (m_OptionsController == null) {
            m_OptionsController = new OptionsController();
        }
        return m_OptionsController;
    }

    public static RandomController getRandomController() {
        if (m_randomController == null) {
            m_randomController = new RandomController("config/cars.xml", "config/pseudo.xml");
        }
        return m_randomController;
    }
    /////////////////////////////////////////
    // Attributes
    /////////////////////////////////////////
    private static Input m_input;
    private static Visualisation m_visualisation;
    private static WorldModel m_worldmodel;
    private static Physics m_physics;
    private static SoundController m_audioController;
    private static Network m_network;
    private static OptionsController m_OptionsController;
    private static IA m_ia;
    private static RandomController m_randomController;
}
TOP

Related Classes of com.aqpproject.game.Singleton

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.