Beispiel #1
0
        protected async Task HandleValidSubmit()
        {
            int.TryParse(ZoneId, out var zoneId);

            if (zoneId == 0) //new
            {
                var newZone = Mapper.Map <ZoneForCreationDto>(Zone);

                var addedZone = await ZoneDataService.AddZone(newZone);

                if (addedZone != null)
                {
                    StatusClass = "alert-success";
                    Message     = "New zone added successfully.";
                    Saved       = true;
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new zone. Please try again.";
                    Saved       = true;
                }
            }
            else
            {
                var newZone = Mapper.Map <ZoneForUpdateDto>(Zone);

                await ZoneDataService.UpdateZone(newZone, zoneId);

                StatusClass = "alert-success";
                Message     = "Zone updated successfully.";
                Saved       = true;
            }
        }
Beispiel #2
0
        protected override async Task OnInitializedAsync()
        {
            Saved = false;
            int.TryParse(QuestId, out var questId);

            if (questId == 0) //new quest is being created
            {
                //add some defaults
                Quest = new QuestForUpdateDto
                {
                    IsPrivate = false,
                    ZoneId    = 1
                };
            }
            else
            {
                QuestDp = await QuestDataService.GetQuestDetails(questId);

                DataPoints = QuestDp.DataPoints;

                Quest            = Mapper.Map <QuestForUpdateDto>(QuestDp);
                Quest.DataPoints = Mapper.Map <IEnumerable <DataPointForCreationDto> >(QuestDp.DataPoints).ToList();
                Title            = $"Details for {Quest.Description}";
                Views            = new List <ViewDto>(await ViewDataService.GetAllViews(questId));
            }


            Zones  = (await ZoneDataService.GetAllZones()).ToList();
            ZoneId = Quest.ZoneId.ToString();
        }
Beispiel #3
0
        protected override void OnThreadUnSafeEventFired(object source, CharacterSessionDataChangedEventArgs args)
        {
            if (Logger.IsInfoEnabled)
            {
                Logger.Info($"Starting process to download world.");
            }

            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                long worldId = 0;
                try
                {
                    //TODO: Handle failure
                    ProjectVersionStage.AssertAlpha();

                    //TODO: Handle throwing/error
                    //We need to know the world the zone is it, so we can request a download URL for it.
                    var worldConfig = await ZoneDataService.GetZoneWorldConfigurationAsync(args.ZoneIdentifier)
                                      .ConfigureAwaitFalse();

                    if (!worldConfig.isSuccessful)
                    {
                        throw new InvalidOperationException($"Failed to query World Configuration for ZoneId: {args.ZoneIdentifier}");
                    }

                    worldId = worldConfig.Result.WorldId;

                    //With the worldid we can get the download URL.
                    ContentDownloadURLResponse urlDownloadResponse = await ContentService.RequestWorldDownloadUrl(worldId)
                                                                     .ConfigureAwaitFalse();

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info($"World Download Url: {urlDownloadResponse.DownloadURL}");
                    }

                    //Can't do web request not on the main thread, sadly.
                    await new UnityYieldAwaitable();

                    WorldDownloader downloader = new WorldDownloader(Logger);

                    await downloader.DownloadAsync(urlDownloadResponse.DownloadURL, urlDownloadResponse.Version, o =>
                    {
                        OnWorldDownloadBegins?.Invoke(this, new WorldDownloadBeginEventArgs(o));
                    });
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to query for Download URL for ZoneId: {args.ZoneIdentifier} WorldId: {worldId} (0 if never succeeded request). Error: {e.Message}");
                    }
                    throw;
                }
            });
        }
Beispiel #4
0
        protected async Task DeleteZone()
        {
            int.TryParse(ZoneId, out var zoneId);

            await ZoneDataService.DeleteZone(zoneId);

            StatusClass = "alert-success";
            Message     = "Deleted successfully";

            Saved = true;
        }
Beispiel #5
0
        protected override async Task OnInitializedAsync()
        {
            Saved = false;
            int.TryParse(ZoneId, out var zoneId);

            if (zoneId != 0)//new zone is being created
            {
                ZoneDto = await ZoneDataService.GetZoneById(zoneId);

                Zone  = Mapper.Map <ZoneForUpdateDto>(ZoneDto);
                Title = $"Details for {Zone.Description}";
            }
        }
Beispiel #6
0
        protected override async Task OnInitializedAsync()
        {
            Saved = false;
            int.TryParse(QuestId, out var questId);
            MapMarkers = new List <Marker>();

            if (questId == 0) //new quest is being created
            {
                //add some defaults
                Quest = new QuestForUpdateDto
                {
                    IsPrivate = false,
                    ZoneId    = -1
                };
            }
            else
            {
                QuestDp = await QuestDataService.GetQuestDetails(questId);

                DataPoints = QuestDp.DataPoints;

                Quest            = Mapper.Map <QuestForUpdateDto>(QuestDp);
                Quest.DataPoints = Mapper.Map <IEnumerable <DataPointForCreationDto> >(QuestDp.DataPoints).ToList();
                Title            = $"Details for {Quest.Description}";
                Views            = new List <ViewDto>(await ViewDataService.GetAllViews(questId));
                foreach (var dataPoint in Quest.DataPoints)
                {
                    MapMarkers.Add(
                        new Marker
                    {
                        Description  = $"{dataPoint.Description}",
                        ShowPopup    = false,
                        X            = dataPoint.Longitude,
                        Y            = dataPoint.Latitude,
                        RadiusMeters = dataPoint.RadiusMeters,
                        IsNegative   = dataPoint.IsNegative,
                        Certainty    = dataPoint.Certainty
                    });
                }
            }

            Zones  = (await ZoneDataService.GetAllZones()).ToList();
            ZoneId = Quest?.ZoneId.ToString();
        }
Beispiel #7
0
        //TODO: Refactor this behind its own object to provide download URL for character.
        /// <inheritdoc />
        public async Task OnGameInitialized()
        {
            if (Logger.IsInfoEnabled)
            {
                Logger.Info("About to start downloading map data.");
            }

            //When we start the loading screen for the game
            //To know what world we should load we should
            CharacterSessionDataResponse characterSessionData = await CharacterService.GetCharacterSessionData(LocalCharacterData.CharacterId, AuthTokenRepo.RetrieveWithType())
                                                                .ConfigureAwait(false);

            if (!characterSessionData.isSuccessful)
            {
                Logger.Error($"Failed to query Character Session Data: {characterSessionData.ResultCode}:{(int)characterSessionData.ResultCode}");
                return;
            }

            //TODO: Handle failure
            ProjectVersionStage.AssertAlpha();
            //TODO: Handle throwing/error
            //We need to know the world the zone is it, so we can request a download URL for it.
            long worldId = await ZoneDataService.GetZoneWorld(characterSessionData.ZoneId)
                           .ConfigureAwait(false);

            //With the worldid we can get the download URL.
            ContentDownloadURLResponse urlDownloadResponse = await ContentService.RequestWorldDownloadUrl(worldId, AuthTokenRepo.RetrieveWithType())
                                                             .ConfigureAwait(false);

            //TODO: Handle failure
            if (urlDownloadResponse.isSuccessful)
            {
                if (Logger.IsInfoEnabled)
                {
                    Logger.Info($"Download URL: {urlDownloadResponse.DownloadURL}");
                }

                //Can't do web request not on the main thread, sadly.
                await new UnityYieldAwaitable();

                //TODO: Do we need to be on the main unity3d thread
                UnityWebRequestAsyncOperation asyncOperation = UnityWebRequestAssetBundle.GetAssetBundle(urlDownloadResponse.DownloadURL, 0).SendWebRequest();

                //TODO: We should render these operations to the loading screen UI.
                asyncOperation.completed += operation =>
                {
                    AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(asyncOperation.webRequest);

                    string[] paths = bundle.GetAllScenePaths();

                    foreach (string p in paths)
                    {
                        Debug.Log($"Found Scene in Bundle: {p}");
                    }

                    AsyncOperation sceneAsync = SceneManager.LoadSceneAsync(System.IO.Path.GetFileNameWithoutExtension(paths.First()));

                    sceneAsync.completed += operation1 =>
                    {
                        //When the scene is finished loading we should cleanup the asset bundle
                        //Don't clean up the WHOLE BUNDLE, just the compressed downloaded data
                        bundle.Unload(false);

                        //TODO: We need a way/system to reference the bundle later so it can be cleaned up inbetween scene loads.
                    };

                    sceneAsync.allowSceneActivation = true;
                };
            }
        }
Beispiel #8
0
 protected override async Task OnInitializedAsync()
 {
     Zones = (await ZoneDataService.GetAllZones()).ToList();
 }
Beispiel #9
0
 protected override async Task OnInitializedAsync()
 {
     Quests = (await QuestDataService.GetAllQuests())?.ToList();
     Zones  = (await ZoneDataService.GetAllZones())?.ToList();
 }
Beispiel #10
0
        protected override async Task OnInitializedAsync()
        {
            int.TryParse(ZoneId, out var zoneId);

            Zone = await ZoneDataService.GetZoneById(zoneId);
        }