Ejemplo n.º 1
0
    // This should be called before any other gameobject awakes
    private void Awake()
    {
        // Singleton pattern : this is the only case where it should be used
        if (ms_Instance == null)
        {
            ms_Instance = this;
            DontDestroyOnLoad(gameObject);

            m_Logger           = new UnityLogger();
            m_Updater          = new Updater();
            m_GameEventManager = new GameEventManager();
            m_InputManager     = new InputManager();
            m_LevelManager     = new LevelManager();
            m_GameFlowHSM      = new GameFlowHSM();
            m_SoundManager     = new SoundManager(m_EfxSource, m_MusicSource);
            m_SaveManager      = new SaveManager();
            m_PlayerManager    = new PlayerManager();
            OpenProxies();
            OnEngineStart();
        }
        else if (ms_Instance != this)
        {
            Destroy(gameObject);
            return;
        }
    }
Ejemplo n.º 2
0
    // This should be called before any other gameobject awakes
    private void Awake ()
    {
        // Singleton pattern : this is the only case where it should be used
        if(ms_Instance == null)
        {
            ms_Instance = this;
            DontDestroyOnLoad (gameObject);
            
            // Keep the Updater first, as the other members might want to register to it
            m_Logger = new UnityLogger ();
            LoggerProxy.Open (m_Logger);
            m_Updater = new Updater ();
            UpdaterProxy.Open (m_Updater);
            m_GameEventManager = new GameEventManager ();
            GameEventManagerProxy.Open (m_GameEventManager);
            m_InputManager = new InputManager ();
            InputManagerProxy.Open (m_InputManager);
            m_LevelManager = new LevelManager ();
            LevelManagerProxy.Open (m_LevelManager);
            m_TileManager = new TileManager ();
            TileManagerProxy.Open (m_TileManager);
            m_CommandStack = new CommandStack ();
            CommandStackProxy.Open (m_CommandStack);
            m_GoalManager = new GoalManager ();
            GoalManagerProxy.Open (m_GoalManager);
            m_SoundManager = new SoundManager ();
            SoundManagerProxy.Open (m_SoundManager);
            m_SoundManager.SetMusicSource (m_MusicSource);
            m_SoundManager.SetFXSource (m_EfxSource);

            m_GameFlowHSM = new GameFlowHSM ();
            m_GameFlowHSM.Start (typeof (GameFlowMenuState));
        }
        else if (ms_Instance != this)
        {
            Destroy (gameObject);
            return;
        }
    }