Exemplo n.º 1
0
        // Load player data
        public static void loadPlayerData(int playerSlot)
        {
            Logger.log("DataManager.loadPlayerData method starting.");

            string filePath = _playersDirectory + string.Format("player_data_{0}.xml", playerSlot);

            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                XDocument doc = XDocument.Load(fs);

                // Basic player data
                _playerData = doc.Element("PlayerData");
                _playerSlot = playerSlot;
                _playerName = _playerData.Attribute("name").Value;

                // Create managers
                _worldMapManager = createWorldMapManager();
                _questManager    = new QuestManager();
                _itemManager     = createItemManager();
                _dialogueManager = new DialogueManager(_systemManager, _entityManager);

                // World map states
                _worldMapManager.worldMapStates = loadWorldMapStates(new List <XElement>(_playerData.Elements("WorldMapState")));

                // Inventory and toolbar
                loadPlayerInventory();
                loadPlayerToolbar();

                // Custom flags and values
                loadCustomFlags();
                loadCustomValues();
            }

            Logger.log("DataManager.loadPlayerData method finished.");
        }
Exemplo n.º 2
0
        // Create new player data
        public static int createPlayerData(string playerName, bool saveData = true)
        {
            Logger.log("DataManager.createPlayerData method starting.");

            int  unusedPlayerSlot = 0;
            bool created          = false;

            while (!created)
            {
                if (File.Exists(_playersDirectory + string.Format("player_data_{0}.xml", unusedPlayerSlot)))
                {
                    unusedPlayerSlot++;
                }
                else
                {
                    WorldMapState startingWorldMapState;

                    _playerName = playerName;
                    _playerSlot = unusedPlayerSlot;

                    // Create managers
                    _worldMapManager = createWorldMapManager();
                    _itemManager     = createItemManager();
                    _dialogueManager = new DialogueManager(_systemManager, _entityManager);
                    _questManager    = new QuestManager();

                    // Create starting world map states
                    startingWorldMapState = new WorldMapState(_worldMapManager.getWorldMapDefinition("oria_world_map"), true);
                    startingWorldMapState.levelIconStates.Add(
                        new LevelIconState(
                            _worldMapManager.getLevelIconDefinition("oria_world_map", "home_village"),
                            true,
                            true));
                    _worldMapManager.worldMapStates.Add(
                        "oria_world_map",
                        startingWorldMapState);

                    // Create inventory and toolbar
                    _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, new InventoryComponent(32));
                    _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, new ToolbarComponent(4, PlayerSystem.PLAYER_ID));

                    if (saveData)
                    {
                        savePlayerData();
                    }
                    created = true;
                }
            }

            Logger.log("DataManager.createPlayerData method finished.");

            return(unusedPlayerSlot);
        }
Exemplo n.º 3
0
        // Create new player data
        public static int createPlayerData(string playerName, bool saveData = true)
        {
            Logger.log("DataManager.createPlayerData method starting.");

            int unusedPlayerSlot = 0;
            bool created = false;

            while (!created)
            {
                if (File.Exists(_playersDirectory + string.Format("player_data_{0}.xml", unusedPlayerSlot)))
                    unusedPlayerSlot++;
                else
                {
                    WorldMapState startingWorldMapState;

                    _playerName = playerName;
                    _playerSlot = unusedPlayerSlot;

                    // Create managers
                    _worldMapManager = createWorldMapManager();
                    _itemManager = createItemManager();
                    _dialogueManager = new DialogueManager(_systemManager, _entityManager);
                    _questManager = new QuestManager();

                    // Create starting world map states
                    startingWorldMapState = new WorldMapState(_worldMapManager.getWorldMapDefinition("oria_world_map"), true);
                    startingWorldMapState.levelIconStates.Add(
                        new LevelIconState(
                            _worldMapManager.getLevelIconDefinition("oria_world_map", "home_village"),
                            true,
                            true));
                    _worldMapManager.worldMapStates.Add(
                        "oria_world_map",
                        startingWorldMapState);

                    // Create inventory and toolbar
                    _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, new InventoryComponent(32));
                    _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, new ToolbarComponent(4, PlayerSystem.PLAYER_ID));

                    if (saveData)
                    {
                        savePlayerData();
                    }
                    created = true;
                }
            }

            Logger.log("DataManager.createPlayerData method finished.");

            return unusedPlayerSlot;
        }
Exemplo n.º 4
0
        // Load player data
        public static void loadPlayerData(int playerSlot)
        {
            Logger.log("DataManager.loadPlayerData method starting.");

            string filePath = _playersDirectory + string.Format("player_data_{0}.xml", playerSlot);

            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            {
                XDocument doc = XDocument.Load(fs);

                // Basic player data
                _playerData = doc.Element("PlayerData");
                _playerSlot = playerSlot;
                _playerName = _playerData.Attribute("name").Value;

                // Create managers
                _worldMapManager = createWorldMapManager();
                _questManager = new QuestManager();
                _itemManager = createItemManager();
                _dialogueManager = new DialogueManager(_systemManager, _entityManager);

                // World map states
                _worldMapManager.worldMapStates = loadWorldMapStates(new List<XElement>(_playerData.Elements("WorldMapState")));

                // Inventory and toolbar
                loadPlayerInventory();
                loadPlayerToolbar();

                // Custom flags and values
                loadCustomFlags();
                loadCustomValues();
            }

            Logger.log("DataManager.loadPlayerData method finished.");
        }