예제 #1
0
 private void miLoadSaveGame_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog())
     {
         ofd.Filter = "save files (*.sav)|*.sav";
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             Advent.RestoreGame(Advent.GameName, ofd.FileName);
         }
     }
 }
예제 #2
0
        private void BeginPlayback(string pPath)
        {
            if (Recorder != null)
            {
                Recorder.eKeystroke     -= Recorder_eKeystroke;
                Recorder.ReplayFinished -= Recorder_ReplayFinished;
            }

            Recorder = RecordGame.Load(pPath);

            Recorder.eKeystroke      += Recorder_eKeystroke;
            Recorder.ReplayFinished  += Recorder_ReplayFinished;
            Recorder.eCarriageReturn += Recorder_eCarriageReturn;
            Advent.RestoreGame(Recorder.Data);
            Recorder.StartReplay();
        }
예제 #3
0
        static void Main(string[] args)
        {
            //Console.WindowWidth = 70;

            Console.Clear();
            string arg;
            string arg1;
            string userInput = null;


            try
            {
                #region Process arguments

                //no args provided or no recognised args
                if (args.Length == 0 ||
                    args.Select(a => a.Length > 1 ? a.Substring(0, 2) : a).ToArray().Intersect(flags).Count() == 0 ||
                    getFlagArg(flags[5], args) != null)
                {
                    OutputHelp();
                    return;
                }
                else if ((arg = getFlagArg(flags[2], args)) != null) //formatted output of specified game file
                {
                    var g = GameData.Load(arg);
                    g.SaveAsCommentedXML();
                    return;
                }
                else if ((arg = getFlagArg(flags[5], args)) != null) //formatted output of specified game file
                {
                    GameData.SaveAsCommentedDat(arg);
                    return;
                }

                arg          = getFlagArg(flags[1], args); //Game to load
                arg1         = getFlagArg(flags[0], args); //Save game to restore
                _TurnCounter = getFlagArg(flags[3], args) != null;
                if (arg != null)
                {
                    Advent.RoomView     += Advent_RoomView;
                    Advent.GameMessages += Advent_GameMessages;
                    if (arg1 != null)
                    {
                        Advent.RestoreGame(arg, arg1);  //restore save game
                    }
                    else
                    {
                        Advent.LoadGame(arg);   //just load
                    }
                }
                else
                {
                    Console.WriteLine("ERROR: When using -l must specify game to load with -g");
                    return;
                }



                Console.Title = "Playing: " + Advent.GameName;


                #endregion


                do
                {
                    Console.Write(Advent.PlayerPrompt);

                    Advent.ProcessText(userInput = Console.ReadLine());
                } while (!Advent.ISGameOver);

                Output();
            }
            catch (Exception e)
            {
                ErrorBox(6, 6, 60, 10, e.Message);
            }


            //write the final bar
            string exitmsg = "-Press enter to exit-";
            Console.SetCursorPosition(0, Console.WindowHeight - 2);
            Console.BackgroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Write(exitmsg + new string(' ', Console.WindowWidth - exitmsg.Length));
            Console.SetCursorPosition(exitmsg.Length + 1, Console.CursorTop - 1);
            Console.ResetColor();
            Console.Read();
            Console.Clear();
        }