Example #1
0
        /// <summary>
        /// Assume we're running a command and have save game data.
        /// </summary>
        /// <param name="gameFile"></param>
        /// <param name="saveFile"></param>
        /// <param name="command"></param>
        public EngineWrapper(byte[] gameFile, byte[] saveFile, string command)
        {
            if (gameFile == null)
                throw new Exception("Missing game data.");

            if (saveFile == null)
                throw new Exception("Missing required save file.");

            if (command == "")
                throw new Exception("Missing command.");

            MemoryStream gameData = new MemoryStream(gameFile);
            saveFileData = new MemoryStream(saveFile);

            vm = new Engine(gameData, saveFileData);

            wrapperState = VMWrapperState.LoadGame;
            if (command == "restore.current.game")
            {
                requestType = VMRequestType.NoCommand;
            }
            else
            {
                requestType = VMRequestType.ExecuteCommand;
            }

            // save the user's command for later
            saveCommand = command;

            Run();
        }
Example #2
0
        public void SendCommand(string command)
        {
            wrapperState = VMWrapperState.RunCommand;
            requestType  = VMRequestType.ExecuteCommand;

            saveCommand = command;

            vm.Continue();
        }
Example #3
0
        public void Restore(byte[] restoreData)
        {
            restoreStream = new MemoryStream(restoreData);

            wrapperState = VMWrapperState.RequestRestore;
            requestType  = VMRequestType.ExecuteCommand;

            needLine = true;

            vm.Continue();
        }
Example #4
0
        /// <summary>
        /// Load the game and return data.
        /// </summary>
        /// <param name="gameFile"></param>
        public EngineWrapper(byte[] gameFile)
        {
            if (gameFile == null)
            {
                throw new Exception("Missing game file.");
            }

            MemoryStream gameData = new MemoryStream(gameFile);

            vm = new Engine(gameData);

            requestType  = VMRequestType.StartGame;
            wrapperState = VMWrapperState.LoadGame;

            Run();
        }
Example #5
0
        /// <summary>
        /// Load the game and return data.
        /// </summary>
        /// <param name="gameFile"></param>
        public EngineWrapper(byte[] gameFile)
        {
            if (gameFile == null)
                throw new Exception("Missing game file.");

            MemoryStream gameData = new MemoryStream(gameFile);

            vm = new Engine(gameData);

            requestType = VMRequestType.StartGame;
            wrapperState = VMWrapperState.LoadGame;

            Run();
        }
Example #6
0
        public void SendCommand(string command)
        {
            wrapperState = VMWrapperState.LoadGame;
            requestType = VMRequestType.ExecuteCommand;

            saveCommand = command;

            vm.Continue();
        }