Exemple #1
0
        private void Initialize()
        {
            Logger.Log("GameSystem: Starting GameSystem");
            IsInitialized   = true;
            AssetManager    = new AssetManager();
            AudioController = new AudioController();
            TextController  = new TextController();
            TextHistory     = new TextHistory();
            try
            {
                AssetManager.CompileIfNeeded();
                Logger.Log("GameSystem: Starting ScriptInterpreter");
                Type type = Type.GetType(ScriptInterpreterName);
                if (type == null)
                {
                    throw new Exception("Cannot find class " + ScriptInterpreterName + " through reflection!");
                }
                ScriptSystem = (Activator.CreateInstance(type) as IScriptInterpreter);
                if (ScriptSystem == null)
                {
                    throw new Exception("Failed to instantiate ScriptSystem!");
                }
                ScriptSystem.Initialize(this);
            }
            catch (Exception arg)
            {
                Logger.LogError($"Unable to load Script Interpreter of type {ScriptInterpreterName}!\r\n{arg}");
                throw;
                IL_00d0 :;
            }
            IsRunning   = true;
            GameState   = GameState.Normal;
            curStateObj = new StateNormal();
            IGameState obj = curStateObj;

            inputHandler      = obj.InputHandler;
            MessageBoxVisible = false;
            if (!PlayerPrefs.HasKey("width"))
            {
                PlayerPrefs.SetInt("width", 640);
            }
            if (!PlayerPrefs.HasKey("height"))
            {
                PlayerPrefs.SetInt("height", 480);
            }
            if (PlayerPrefs.GetInt("width") < 640)
            {
                PlayerPrefs.SetInt("width", 640);
            }
            if (PlayerPrefs.GetInt("height") < 480)
            {
                PlayerPrefs.SetInt("height", 480);
            }
            if ((Screen.width < 640 || Screen.height < 480) && !Screen.fullScreen)
            {
                Screen.SetResolution(640, 480, fullscreen: false);
            }
        }
Exemple #2
0
 public void Register(string extension, IScriptInterpreter interpreter)
 {
     _interpreters[extension] = interpreter;
     interpreter.Initialize(_scriptsDirectory);
 }