Exemple #1
0
        public IEnumerable <GameItem> Read()
        {
            var reader    = new JsonFileReader(_filename);
            var dataItems = reader.ReadArray <ItemModel>();

            foreach (var dataItem in dataItems)
            {
                var gameItem = dataItem.ToGameItem();
                if (gameItem != null)
                {
                    yield return(gameItem);
                }
            }
            ;
        }
        public IEnumerable <Recipe> Read()
        {
            var reader    = new JsonFileReader(_filename);
            var dataItems = reader.ReadArray <RecipeModel>();

            foreach (var dataItem in dataItems)
            {
                var recipe = dataItem.ToRecipe();
                if (recipe != null)
                {
                    yield return(recipe);
                }
            }
            ;
        }
Exemple #3
0
        public IEnumerable <Quest> Read()
        {
            var reader    = new JsonFileReader(_filename);
            var dataItems = reader.ReadArray <QuestModel>();

            foreach (var dataItem in dataItems)
            {
                var quest = dataItem.ToQuest();
                if (quest != null)
                {
                    yield return(quest);
                }
            }
            ;
        }
        public IEnumerable <Trader> Read()
        {
            var reader    = new JsonFileReader(_filename);
            var dataItems = reader.ReadArray <TraderModel>();

            foreach (var dataItem in dataItems)
            {
                var item = dataItem.ToTrader();
                if (item != null)
                {
                    yield return(item);
                }
            }
            ;
        }
Exemple #5
0
        public IEnumerable <Location> Read()
        {
            var basePath = Path.GetDirectoryName(_filename);

            var reader    = new JsonFileReader(_filename);
            var dataItems = reader.ReadArray <LocationModel>();

            foreach (var dataItem in dataItems)
            {
                var location = dataItem.ToLocation();
                if (location != null)
                {
                    //Images are relative to JSON file so fix the path
                    if (!Path.IsPathRooted(location.ImagePath))
                    {
                        location.ImagePath = Path.Combine(basePath, location.ImagePath);
                    }

                    yield return(location);
                }
                ;
            }
            ;
        }
        public IEnumerable <Monster> Read()
        {
            var basePath = Path.GetDirectoryName(_filename);

            var reader    = new JsonFileReader(_filename);
            var dataItems = reader.ReadArray <MonsterModel>();

            foreach (var dataItem in dataItems)
            {
                var monster = dataItem.ToMonster();
                if (monster != null)
                {
                    //Images are relative to JSON file so fix the path
                    if (!Path.IsPathRooted(monster.ImagePath))
                    {
                        monster.ImagePath = Path.Combine(basePath, monster.ImagePath);
                    }

                    yield return(monster);
                }
                ;
            }
            ;
        }