Пример #1
0
        static void SaveGame()
        {
            List <Object> objList = new List <object>();

            objList.Add(playerField);
            objList.Add(bomberman);
            objList.Add(bombList);
            objList.Add(gadsList);
            objList.Add(seconds);
            //objList.Add();

            IOSerialization.Serialize(file, objList);
        }
Пример #2
0
        static void LoadGame()
        {
            Console.Clear();
            Console.ResetColor();
            LogoPrint();
            InitPlayerField(playerField);
            DrawPlayerField(playerField);
            PrintLegend();

            List <Object> objList = new List <object>();

            objList = (List <Object>)IOSerialization.Deserialize(file);

            foreach (var item in objList)
            {
                if (item is char[, ])
                {
                    playerField = (char[, ])item;
                }
                if (item is Man)
                {
                    bomberman = (Man)item;
                }
                if (item is List <Gad> )
                {
                    gadsList = (List <Gad>)item;
                }
                if (item is List <Bomb> )
                {
                    bombList = (List <Bomb>)item;
                }
                if (item is int)
                {
                    seconds = (int)item;
                }
            }
            bombermanPositionOld = bomberman.position;
            DrawBomberman();
        }