Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        // Load world map states
        private static Dictionary <string, WorldMapState> loadWorldMapStates(List <XElement> allWorldMapStateData)
        {
            Dictionary <string, WorldMapState> worldMapStates = new Dictionary <string, WorldMapState>();

            foreach (XElement worldMapStateData in allWorldMapStateData)
            {
                string        worldMapUid   = worldMapStateData.Attribute("world_map_uid").Value;
                WorldMapState worldMapState = new WorldMapState(
                    _worldMapManager.getWorldMapDefinition(worldMapUid),
                    bool.Parse(worldMapStateData.Attribute("discovered").Value));

                foreach (XElement levelIconStateData in worldMapStateData.Elements("LevelIconState"))
                {
                    string levelIconUid = levelIconStateData.Attribute("level_icon_uid").Value;

                    worldMapState.levelIconStates.Add(
                        new LevelIconState(
                            _worldMapManager.getLevelIconDefinition(worldMapUid, levelIconUid),
                            bool.Parse(levelIconStateData.Attribute("discovered").Value),
                            bool.Parse(levelIconStateData.Attribute("finished").Value)));
                }

                foreach (XElement levelPathStateData in worldMapStateData.Elements("LevelPathState"))
                {
                    int id = int.Parse(levelPathStateData.Attribute("id").Value);

                    worldMapState.levelPathState.Add(
                        new LevelPathState(
                            _worldMapManager.getLevelPathDefinition(worldMapUid, id),
                            bool.Parse(levelPathStateData.Attribute("discovered").Value)));
                }

                worldMapStates.Add(worldMapUid, worldMapState);
            }

            return(worldMapStates);
        }
Ejemplo 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;
        }