Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //大戰Boss前
            GameRole lixiaoyao = new GameRole();

            lixiaoyao.GetInitState();
            lixiaoyao.StateDisplay();

            //保存進度
            GameRole backup = new GameRole();

            backup.Vitality = lixiaoyao.Vitality;
            backup.Attack   = lixiaoyao.Attack;
            backup.Defense  = lixiaoyao.Defense;

            //大戰Boss時,損耗嚴重
            lixiaoyao.Fight();
            lixiaoyao.StateDisplay();

            //恢復之前狀態
            lixiaoyao.Vitality = backup.Vitality;
            lixiaoyao.Attack   = backup.Attack;
            lixiaoyao.Defense  = backup.Defense;

            lixiaoyao.StateDisplay();

            Console.Read();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //大戰Boss前
            GameRole lixiaoyao = new GameRole();

            lixiaoyao.GetInitState();
            lixiaoyao.StateDisplay();

            //保存進度
            RoleStateCaretaker stateAdmin = new RoleStateCaretaker();

            stateAdmin.Memento = lixiaoyao.SaveState();

            //大戰Boss時,損耗嚴重
            lixiaoyao.Fight();
            lixiaoyao.StateDisplay();

            //恢復之前狀態
            lixiaoyao.RecoveryState(stateAdmin.Memento);

            lixiaoyao.StateDisplay();


            Console.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //大戰Boss前
            GameRole lixiaoyao = new GameRole();
            lixiaoyao.GetInitState();
            lixiaoyao.StateDisplay();

            //保存進度
            RoleStateCaretaker stateAdmin = new RoleStateCaretaker();
            stateAdmin.Memento = lixiaoyao.SaveState();

            //大戰Boss時,損耗嚴重
            lixiaoyao.Fight();
            lixiaoyao.StateDisplay();

            //恢復之前狀態
            lixiaoyao.RecoveryState(stateAdmin.Memento);

            lixiaoyao.StateDisplay();

            Console.Read();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //大戰Boss前
            GameRole lixiaoyao = new GameRole();
            lixiaoyao.GetInitState();
            lixiaoyao.StateDisplay();

            //保存進度
            GameRole backup = new GameRole();
            backup.Vitality = lixiaoyao.Vitality;
            backup.Attack = lixiaoyao.Attack;
            backup.Defense = lixiaoyao.Defense;

            //大戰Boss時,損耗嚴重
            lixiaoyao.Fight();
            lixiaoyao.StateDisplay();

            //恢復之前狀態
            lixiaoyao.Vitality = backup.Vitality;
            lixiaoyao.Attack = backup.Attack;
            lixiaoyao.Defense = backup.Defense;

            lixiaoyao.StateDisplay();

            Console.Read();
        }