예제 #1
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;
        }
예제 #2
0
        public async Task<Level> GenerateLevel(List<ActiveAssetsVIEW> assets)
        {
            var level = new Level
            {
                LevelName = "RandomGeneratedLevel",
                Objects = new List<LevelObject>()
            };

            LevelObject lvlObj = new LevelObject();

            return level;
        }