Beyond_Beyaan.EmpireManager.Load C# (CSharp) Метод

Load() публичный Метод

public Load ( System.Xml.Linq.XElement root ) : bool
root System.Xml.Linq.XElement
Результат bool
        public bool Load(XElement root)
        {
            _empires = new List<Empire>();
            var empires = root.Element("Empires");
            foreach (var empire in empires.Elements())
            {
                var newEmpire = new Empire();
                newEmpire.Load(empire, _gameMain);
                _empires.Add(newEmpire);
            }
            foreach (var empire in _empires)
            {
                empire.SetUpContacts(_empires);
                //TODO: Update all empires' contacts
            }
            SetInitialEmpireTurn();
            return true;
        }

Usage Example

Пример #1
0
        public bool LoadGame(string filename)
        {
            string path = Path.Combine(GameDataSet.FullName, "Saves");

            if (!Directory.Exists(path))
            {
                //No folder exists, impossible to load anything
                return(false);
            }
            try
            {
                XDocument doc  = XDocument.Load(Path.Combine(path, filename));
                XElement  root = doc.Root;
                if (!Galaxy.Load(root, this))
                {
                    return(false);
                }
                if (!EmpireManager.Load(root))
                {
                    return(false);
                }
                Galaxy.Reconcilate(EmpireManager);
                if (_galaxyScreen != null)
                {
                    _galaxyScreen.ResetCamera();
                }
                if (_processingTurnScreen != null)
                {
                    _processingTurnScreen.ResetCamera();
                }
                ChangeToScreen(Screen.Galaxy);
                return(true);
            }
            catch
            {
                return(false);
            }
        }