예제 #1
0
        public void SetupGame()
        {
            if (Globals.UserMenuChoice == GameStartupChoice.NewGame)
            {
                universes = new Universe[Globals.Universes];

                for (int i = 0; i < universes.Length; ++i)
                {
                    universes[i] = new Universe();
                    universes[i].CreateUniverse(Globals.Width, Globals.Height, Globals.Pattern);
                }
            }
            else if (Globals.UserMenuChoice == GameStartupChoice.LoadGame)
            {
                FileReadWrite   rw  = FileReadWrite.GetReadWriteService;
                UniverseState[] obj = rw.Deserialize();

                universes = new Universe[obj.Length];

                for (int i = 0; i < universes.Length; ++i)
                {
                    universes[i]        = new Universe();
                    universes[i].UState = obj[i];
                }
            }

            LiveUniverses();
            VisibleUniverses();
        }
예제 #2
0
        private void SaveLife()
        {
            FileReadWrite rw = FileReadWrite.GetReadWriteService;

            UniverseState[] st = new UniverseState[_gameSetup.universes.Length];
            for (int i = 0; i < _gameSetup.universes.Length; i++)
            {
                st[i] = _gameSetup.universes[i].UState;
            }
            rw.Serialize(st);

            Globals.Save  = false; //Class should controll self state
            Globals.Pause = true;

            _renderer.Clear();
            _renderer.Color(ConsoleColor.White);
            Console.WriteLine("Game Was Saved Press Enter to continue");
            Console.ReadLine();
            Globals.Pause = false;
            _renderer.Clear();
        }