예제 #1
0
        public async Task<bool> LoadData() {
            var levelHandler = new LevelHandler(Handler);

            var result = await levelHandler.GetLevelList();

            if (result.HasError) {
                return false;
            }

            LevelListing = new ObservableCollection<LevelListingView>(result.Value);

            SelectedLevel = LevelListing.FirstOrDefault();

            return true;
        }
예제 #2
0
        public async Task<Level> LoadLevel(List<ActiveAssetsVIEW> assets) {
            var levelHandler = new LevelHandler(Handler);

            var result = await levelHandler.GetLevel(SelectedLevel.ID);

            if (result.HasError) {
                return null;
            }

            var level = new Level {
                LevelName = result.Value.Description,
                Objects = new List<LevelObject>()
            };
            
            var levelObjects = JsonConvert.DeserializeObject<List<LevelObjectLite>>(result.Value.LevelData);

            foreach (var item in levelObjects) {
                var asset = assets.FirstOrDefault(a => a.ID == item.AssetID);

                //setup level object's asset info
                var lvlObjAssetInfo = new ActiveAssetsVIEW()
                {
                    AssetTypeID = asset.AssetTypeID,
                    ID = asset.ID,
                    Description = "LevelObject",
                    Filename = asset.Filename.Replace("/Content/", "")
                };

                var nItem = new LevelObject {
                    AssetInfos = new List<ActiveAssetsVIEW>() { lvlObjAssetInfo },
                    PositionX = item.PositionX,
                    PositionY = item.PositionY
                };
                
                level.Objects.Add(nItem);
            }

            return level;
        }