Exemplo n.º 1
0
 public static void RestoreState(Originator orig)
 {
     orig.SetMemento(save);
 }
Exemplo n.º 2
0
        private void ReservHandlers()
        {
            menuHandler.AddDelegate("change hero", () =>
            {
                ChooseHero();
                CurrentMenu = StartMenuDrawer.LabMenu;
            });
            menuHandler.AddDelegate("stats", () =>
            {
                player.ShowPlayer();
                CurrentMenu = StartMenuDrawer.LabMenu;
            });
            menuHandler.AddDelegate("disco", () =>
            {
                player      = new Decorator.DiscoDecorator(player);
                CurrentMenu = StartMenuDrawer.LabMenu;
                player.ShowPlayer();
            });
            menuHandler.AddDelegate("doser", () =>
            {
                player      = new Decorator.DoserDecorator(player);
                CurrentMenu = StartMenuDrawer.LabMenu;
                player.ShowPlayer();
            });
            menuHandler.AddDelegate("super wolf", () =>
            {
                player      = new Decorator.SuperWolfPlayer(player);
                CurrentMenu = StartMenuDrawer.LabMenu;
                player.ShowPlayer();
            });
            menuHandler.AddDelegate("wolf", () =>
            {
                player      = new Decorator.WolfPlayer(player);
                CurrentMenu = StartMenuDrawer.LabMenu;
                player.ShowPlayer();
            });
            menuHandler.AddDelegate("become cooller", () =>
            {
                CurrentMenu = ((StartMenuDrawer)menuDrawer).CoolHeroMenu;
            });
            menuHandler.AddDelegate("world", () =>
            {
                Console.WriteLine(WorldHead.GetInfo());
                CurrentMenu = StartMenuDrawer.LabMenu;
            });
            menuHandler.AddDelegate("map", () =>
            {
                CallStartMap();
                CurrentMenu = StartMenuDrawer.LabMenu;
            });
            menuHandler.AddDelegate("small", () =>
            {
                Console.Clear();
                GameUI = iuiFactory.BuildSmallUI();
                GameUI.SetResolution();
                GameUI.SetStyle();
                ChooseHero();
                CurrentMenu = StartMenuDrawer.LabMenu;
            });
            menuHandler.AddDelegate("wide", () =>
            {
                Console.Clear();
                GameUI = iuiFactory.BuildWideUI();
                GameUI.SetResolution();
                GameUI.SetStyle();
                ChooseHero();
                CurrentMenu = StartMenuDrawer.LabMenu;
            });
            menuHandler.AddDelegate("light", () =>
            {
                Console.Clear();
                iuiFactory  = new LightUIFactory();
                CurrentMenu = ((StartMenuDrawer)menuDrawer).ResolutionMenu;
            });
            menuHandler.AddDelegate("dark", () =>
            {
                Console.Clear();
                iuiFactory  = new DarkUIFactory();
                CurrentMenu = ((StartMenuDrawer)menuDrawer).ResolutionMenu;
            });
            menuHandler.AddDelegate("exit", () => { System.Environment.Exit(1); });
            menuHandler.AddDelegate("new game", () =>
            {
                Console.Clear();
                CurrentMenu = ((StartMenuDrawer)menuDrawer).StyleMenu;
            });
            menuHandler.AddDelegate("continue", () =>
            {
                Console.Clear();
                UIMemento.Originator UIOrig = new UIMemento.Originator();
                UIMemento.Caretaker.RestoreState(UIOrig);
                GameUI = UIOrig.GetState();

                PlayerMemento.Originator PlayerOrig = new PlayerMemento.Originator();
                PlayerMemento.Caretaker.RestoreState(PlayerOrig);
                player = PlayerOrig.GetState();

                GameUI.SetResolution();
                GameUI.SetStyle();
                CurrentMenu = StartMenuDrawer.LabMenu;
                //Command order = new LoadCommand(receiver);
                //send to invoker
            });
            menuHandler.AddDelegate("save", () =>
            {
                Console.Clear();

                UIMemento.Originator UIOrig = new UIMemento.Originator();
                UIOrig.SetState(GameUI);
                UIMemento.Caretaker.SaveState(UIOrig);

                PlayerMemento.Originator PlayerOrig = new PlayerMemento.Originator();
                PlayerOrig.SetState(player);
                PlayerMemento.Caretaker.SaveState(PlayerOrig);
                CurrentMenu = StartMenuDrawer.LabMenu;

                //Command order = new SaveCommand(receiver);
                //send to invoker
            });
            menuHandler.AddDelegate("quests", () =>
            {
                Console.Clear();
                questsManeger.ShowQuests();

                //CurrentMenu = ((StartMenuDrawer)menuDrawer).LabMenu;
            });
        }
Exemplo n.º 3
0
 public static void SaveState(Originator orig)
 {
     save = orig.CreateMemento();
 }