public IProgressResult <float, View> CreateView(Type type, ViewModel vm) { ProgressResult <float, View> progressResult = new ProgressResult <float, View>(); Executors.RunOnCoroutineNoReturn(CreateView(progressResult, type, vm)); return(progressResult); }
public IProgressResult <float, T> LoadAssetAsync <T>(string key) where T : Object { ProgressResult <float, T> progressResult = new ProgressResult <float, T>(true); loadAssetAsync(key, progressResult); return(progressResult); }
public static IProgressResult <TProgress, TResult> RunAsync <TProgress, TResult>(Action <IProgressPromise <TProgress, TResult> > action) { ProgressResult <TProgress, TResult> result = new ProgressResult <TProgress, TResult>(); DoRunAsync(() => { try { CheckDisposed(); action(result); if (!result.IsDone) { result.SetResult(null); } } catch (Exception e) { if (!result.IsDone) { result.SetException(e); } } }); return(result); }
private void InternalOpen <T>(Type type, ProgressResult <float, T> promise, ViewModel viewModel) where T : View { View view = null; var path = (GetClassData(type).Attribute as UIAttribute).Path; promise.Callbackable().OnCallback(progressResult => { Sort(view); view.Show(); }); if (openedSingleViews.TryGetValue(type, out var view1)) { promise.UpdateProgress(1); promise.SetResult(view1); } else { view = ReflectionHelper.CreateInstance(type) as View; Executors.RunOnCoroutineNoReturn(CreateViewGo(promise, view, path, viewModel)); } openedViews.Add(view); if (view.IsSingle) { openedSingleViews[type] = view; } }
private void create_project_button_Click(object sender, RoutedEventArgs e) { TextRange textRange = new TextRange(project_details.Document.ContentStart, project_details.Document.ContentEnd); if (project_name.Text == "" || !ischanged || project_place.Text == "" || project_place.Text == "" || project_maximum.Text == "" || textRange.Text == "") { ModernDialog.ShowMessage("请完整输入所有项目", "提示", MessageBoxButton.OK); } else { try { int num = int.Parse(project_maximum.Text); ProgressResult result = helper.CreatNewProject(Claims.User.Organization, project_time.DisplayDate, project_name.Text, project_place.Text, textRange.Text, num); if (result.Succeeded) { ModernDialog.ShowMessage("项目创建成功!", "", MessageBoxButton.OK); project_name.Clear(); project_place.Clear(); project_maximum.Clear(); project_details.Document.Blocks.Clear(); } else { ModernDialog.ShowMessage("项目创建失败!错误信息" + string.Join(",", result.Errors), "", MessageBoxButton.OK); } } catch (Exception) { ModernDialog.ShowMessage("学号输入非法,仅能输入数字.", "警告", MessageBoxButton.OK); } } }
public IProgressResult <float, View> OpenAsync(Type type, ViewModel viewModel = null) { ProgressResult <float, View> result = new ProgressResult <float, View>(); InternalOpen(type, result, viewModel); return(result); }
protected IEnumerator TestInterceptMoveNextMethod() { ProgressResult <float, bool> result = new ProgressResult <float, bool>(true); /* Register a callback */ result.Callbackable().OnProgressCallback(p => Debug.LogFormat("Progress:{0}%", p * 100)); result.Callbackable().OnCallback((r) => { Debug.LogFormat("The task is finished. IsCancelled:{0} Result:{1} Exception:{2}", r.IsCancelled, r.Result, r.Exception); }); InterceptableEnumerator routine = new InterceptableEnumerator(DoTask(result)); /* if result.IsCancellationRequested == true ,the task will be cancelled. */ routine.RegisterConditionBlock(() => !(result.IsCancellationRequested)); routine.RegisterFinallyBlock(() => { Debug.Log("this is a finally block."); }); /* Start the task */ this.StartCoroutine(routine); yield return(new WaitForSeconds(0.5f)); result.Cancel(); }
public IProgressResult <float, Sprite> LoadSpriteAsync(string path) { ProgressResult <float, Sprite> promise = new ProgressResult <float, Sprite>(); LoadSpriteAsync(path, promise); return(promise); }
public IProgressResult <float, List <BundleInfo> > GetDownloadList(BundleManifest manifest) { ProgressResult <float, List <BundleInfo> > result = new ProgressResult <float, List <BundleInfo> >(); Executors.RunOnCoroutine(DoAnalyzeDownloadList(result, manifest), result); return(result); }
private HttpApiClient (Uri endpoint) { endPointUri = endpoint; currentHttpRequest = null; currentProgressResult = null; currentAsyncResult = null; }
public IProgressResult <Progress, bool> DownloadBundles(List <BundleInfo> bundles) { ProgressResult <Progress, bool> result = new ProgressResult <Progress, bool>(); Executors.RunOnCoroutine(DoDownloadBundles(result, bundles), result); return(result); }
public static IProgressResult <float, SceneInstance> LoadScene(string scene, LoadSceneMode loadSceneMode = LoadSceneMode.Single, bool activeOnLoaded = true) { ProgressResult <float, SceneInstance> progressResult = new ProgressResult <float, SceneInstance>(); loadScene(scene, loadSceneMode, progressResult, activeOnLoaded); return(progressResult); }
public IProgressResult <Progress, BundleManifest> DownloadManifest(string relativePath) { ProgressResult <Progress, BundleManifest> result = new ProgressResult <Progress, BundleManifest>(); Executors.RunOnCoroutine(DoDownloadManifest(relativePath, result), result); return(result); }
protected IEnumerator TestInterceptException() { ProgressResult <float, bool> result = new ProgressResult <float, bool>(true); /* Register a callback */ result.Callbackable().OnProgressCallback(p => Debug.LogFormat("Progress:{0}%", p * 100)); result.Callbackable().OnCallback((r) => { Debug.LogFormat("The task is finished. IsCancelled:{0} Result:{1} Exception:{2}", r.IsCancelled, r.Result, r.Exception); }); InterceptableEnumerator routine = new InterceptableEnumerator(DoTask(result)); routine.RegisterCatchBlock((e) => { Debug.LogError(e); }); routine.RegisterFinallyBlock(() => { Debug.Log("this is a finally block."); }); /* Start the task */ this.StartCoroutine(routine); yield break; }
public void ShowProjectListTest() { // 创建org Organization org = identityhelper.CreateOrFindOrganization(Entity.OrganizationEnum.TestOnly); // 创建两个project Guid uid = Guid.NewGuid(); string name1 = "testcreatafirstproject" + uid.ToString(); string name2 = "testcreatasecondproject" + uid.ToString(); ProgressResult addresult1 = helper.CreatNewProject(org, DateTime.Now, name1, "uibe", "nothing", 20); ProgressResult addresult2 = helper.CreatNewProject(org, DateTime.Now, name2, "uibe", "it's a test", 30); if (!addresult1.Succeeded || !addresult2.Succeeded) { Assert.Fail("添加记录失败!"); } // 测试ShowProjectList var result = helper.ShowProjectList(org, true); var actual = database.Projects.Where(b => b.Organization.Id == org.Id).ToList(); int resultcout = result.Count(); int actualcount = actual.Count(); if (result.Count() == 0 && actual.Count() == 0) { Assert.Fail("记录可能为空,为查询到有关记录!"); } if (resultcout != actualcount) { Assert.Fail("未成功调用showlist方法查询到有关数据!showlist失败!"); } // 删除数据库的有关数据[org pro] DeleteOrgnization(org); }
protected IProgressResult <TProgress, TResult> Execute <TProgress, TResult>(System.Func <IProgressPromise <TProgress, TResult>, IEnumerator> func) { ProgressResult <TProgress, TResult> result = new ProgressResult <TProgress, TResult>(); Executors.RunOnCoroutine(func(result), result); return(result); }
public virtual IProgressResult <float, T> LoadAssetAsync <T>(string path) where T : Object { try { if (string.IsNullOrEmpty(path)) { throw new System.ArgumentNullException("path", "The path is null or empty!"); } ProgressResult <float, T> result = new ProgressResult <float, T>(); AssetPathInfo pathInfo = this.pathInfoParser.Parse(path); if (pathInfo == null) { throw new System.Exception(string.Format("Not found the AssetBundle or parses the path info '{0}' failure.", path)); } T asset = this.GetCache <T>(path); if (asset != null) { result.UpdateProgress(1f); result.SetResult(asset); return(result); } IProgressResult <float, IBundle> bundleResult = this.LoadBundle(pathInfo.BundleName); float weight = bundleResult.IsDone ? 0f : DEFAULT_WEIGHT; bundleResult.Callbackable().OnProgressCallback(p => result.UpdateProgress(p * weight)); bundleResult.Callbackable().OnCallback((r) => { if (r.Exception != null) { result.SetException(r.Exception); return; } using (IBundle bundle = r.Result) { IProgressResult <float, T> assetResult = bundle.LoadAssetAsync <T>(pathInfo.AssetName); assetResult.Callbackable().OnProgressCallback(p => result.UpdateProgress(weight + (1f - weight) * p)); assetResult.Callbackable().OnCallback((ar) => { if (ar.Exception != null) { result.SetException(ar.Exception); } else { result.SetResult(ar.Result); this.AddCache <T>(path, ar.Result); } }); } }); return(result); } catch (System.Exception e) { return(new ImmutableProgressResult <float, T>(e, 0f)); } }
public virtual IProgressResult <float, IBundle> LoadBundle(BundleInfo bundleInfo, int priority) { try { if (bundleInfo == null) { throw new ArgumentNullException("The bundleInfo is null!"); } DefaultBundle bundle = this.GetOrCreateBundle(bundleInfo, priority); var result = bundle.Load(); ProgressResult <float, IBundle> resultCopy = new ProgressResult <float, IBundle>(); result.Callbackable().OnProgressCallback(p => resultCopy.UpdateProgress(p)); result.Callbackable().OnCallback((r) => { if (r.Exception != null) { resultCopy.SetException(r.Exception); } else { resultCopy.SetResult(new InternalBundleWrapper(bundle)); } }); return(resultCopy); } catch (Exception e) { return(new ImmutableProgressResult <float, IBundle>(e, 0f)); } }
public override IProgressResult <float, T> LoadViewAsync <T>(string name) { ProgressResult <float, T> result = new ProgressResult <float, T>(); DoLoad <T>(result, name); return(result); }
public IProgressResult <float, View> OpenAsync <T>(ViewModel viewModel = null) where T : View { ProgressResult <float, View> result = new ProgressResult <float, View>(); InternalOpen(typeof(T), result, viewModel); return(result); }
public virtual IProgressResult <TProgress> Execute <TProgress>(Action <IProgressPromise <TProgress> > action) { ProgressResult <TProgress> result = new ProgressResult <TProgress>(true); Executors.RunAsyncNoReturn(() => { try { if (result.IsCancellationRequested) { result.SetCancelled(); return; } action(result); if (!result.IsDone) { result.SetResult(null); } } catch (Exception e) { if (!result.IsDone) { result.SetException(e); } } }); return(result); }
public void CreatNewProjectTest() { // 创建org Organization org = identityhelper.CreateOrFindOrganization(Entity.OrganizationEnum.TestOnly); // 测试CreateNewProject //创建一个pro Guid tempname = Guid.NewGuid(); string projectname = tempname.ToString(); ProgressResult result = helper.CreatNewProject(org, DateTime.Now, projectname, "uibe", "nothing", 20); if (!result.Succeeded) { Assert.Fail(); } var actual = database.Projects.Where(b => b.Name.ToString() == projectname).ToList(); if (actual == null) { Assert.Fail("CreatNewProject方法失败!无法查找到添加记录!"); } // 删除数据库中添加的数据[org pro] DeleteOrgnization(org); }
public IProgressResult <float, T> CreateView <T>(ViewModel vm) where T : View { ProgressResult <float, T> progressResult = new ProgressResult <float, T>(); Executors.RunOnCoroutineNoReturn(CreateView(progressResult, typeof(T), vm)); return(progressResult); }
public IProgressResult <float, string> LoadScene(string path, LoadSceneMode loadSceneMode = LoadSceneMode.Single, bool allowSceneActivation = true) { ProgressResult <float, string> progressResult = new ProgressResult <float, string>(); LoadScene(progressResult, path, loadSceneMode, allowSceneActivation); return(progressResult); }
public override IProgressResult <float, T> LoadViewAsync <T>(string name) { ProgressResult <float, T> result = new ProgressResult <float, T>(); Executors.RunOnCoroutineNoReturn(DoLoad <T>(result, name)); return(result); }
public static IProgressResult <float> DownloadNewAssets() { ProgressResult <float> progressResult = new ProgressResult <float>(); var operation = Addressables.DownloadDependenciesAsync(DYNAMIC_TAG); Executors.RunOnCoroutineNoReturn(Download(progressResult, operation)); return(progressResult); }
public override IProgressResult <float, GameObject> InstantiateAsync(string key, Vector3 position, Quaternion rotation, Transform parent = null, bool trackHandle = true) { ProgressResult <float, GameObject> progressResult = new ProgressResult <float, GameObject>(); instantiateAsync(getOperation(key, position, rotation, parent, trackHandle), progressResult); return(progressResult); }
public override IProgressResult <float, GameObject> InstantiateAsync(string key, Transform parent = null, bool instantiateInWorldSpace = false, bool trackHandle = true) { ProgressResult <float, GameObject> progressResult = new ProgressResult <float, GameObject>(); instantiateAsync(getOperation(key, parent, instantiateInWorldSpace, trackHandle), progressResult); return(progressResult); }
public IProgressResult <float, View> CreateView(Type type, ViewModel vm) { ProgressResult <float, View> progressResult = new ProgressResult <float, View>(); var view = ReflectionHelper.CreateInstance(type) as View; var path = (GetClassData(type).Attribute as UIAttribute).Path; Executors.RunOnCoroutineNoReturn(CreateViewGo(progressResult, view, path, vm)); return(progressResult); }
#pragma warning disable 1998 public override async Task <IProgressResult <DownloadProgress> > DownloadAssets(string key) #pragma warning restore 1998 { ProgressResult <DownloadProgress> progressResult = new ProgressResult <DownloadProgress>(); var operation = Addressables.DownloadDependenciesAsync(key); Executors.RunOnCoroutineNoReturn(Download(progressResult, operation)); return(progressResult); }
public virtual IProgressResult <TProgress, TResult> Execute <TProgress, TResult>(Action <IProgressPromise <TProgress, TResult> > action) { ProgressResult <TProgress, TResult> result = new ProgressResult <TProgress, TResult>(true); #if NETFX_CORE Task.Factory.StartNew(() => { try { if (result.IsCancellationRequested) { result.SetCancelled(); return; } action(result); if (!result.IsDone) { result.SetResult(null); } } catch (Exception e) { if (!result.IsDone) { result.SetException(e); } } }); #else ThreadPool.QueueUserWorkItem((state) => { try { if (result.IsCancellationRequested) { result.SetCancelled(); return; } action(result); if (!result.IsDone) { result.SetResult(null); } } catch (Exception e) { if (!result.IsDone) { result.SetException(e); } } }); #endif return(result); }
/// <summary> /// Handles skill training. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="item"></param> /// <param name="result"></param> private void OnProgress(Creature creature, Skill skill, Item item, ProgressResult result) { if (skill.Info.Rank == SkillRank.RF) { if (item.HasTag("/weapon/|/tool/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging a tool or a weapon. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging a tool or a weapon. case ProgressResult.VeryBad: skill.Train(3); break; // Achieve a failing result forging a tool or a weapon. case ProgressResult.Bad: skill.Train(4); break; // Achieve a bad result forging a tool or a weapon. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge a tool or a weapon. } } return; } if (skill.Info.Rank == SkillRank.RE) { if (item.HasTag("/shield/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging a shield. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging a shield. case ProgressResult.VeryBad: skill.Train(3); break; // Achieve a failing result forging a shield. case ProgressResult.Bad: skill.Train(4); break; // Achieve a bad result forging a shield. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge a shield. } } return; } if (skill.Info.Rank == SkillRank.RD) { if (item.HasTag("/helmet/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging a helmet. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging a helmet. case ProgressResult.VeryBad: skill.Train(3); break; // Achieve a failing result forging a helmet. case ProgressResult.Bad: skill.Train(4); break; // Achieve a bad result forging a helmet. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge a helmet. } } return; } if (skill.Info.Rank == SkillRank.RC) { if (item.HasTag("/gauntlet/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging gauntlets. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging gauntlets. case ProgressResult.VeryBad: skill.Train(3); break; // Achieve a failing result forging gauntlets. case ProgressResult.Bad: skill.Train(4); break; // Achieve a bad result forging gauntlets. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge gauntlets. } } return; } if (skill.Info.Rank == SkillRank.RB) { if (item.HasTag("/armorboots/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging greaves. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging greaves. case ProgressResult.VeryBad: skill.Train(3); break; // Achieve a failing result forging greaves. case ProgressResult.Bad: skill.Train(4); break; // Achieve a bad result forging greaves. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge greaves. } } return; } if (skill.Info.Rank == SkillRank.RA) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Greatly successful in making Armor case ProgressResult.Good: skill.Train(2); break; // Successful in making Armors case ProgressResult.VeryBad: skill.Train(3); break; // If unsuccessful in making Armor case ProgressResult.Bad: skill.Train(4); break; // The result of making Armor is very poor. case ProgressResult.Finish: skill.Train(5); break; // Completed making Armor 100%. } } return; } if (skill.Info.Rank == SkillRank.R9) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Greatly successful in making Armor case ProgressResult.Good: skill.Train(2); break; // Successful in making Armors case ProgressResult.Finish: skill.Train(3); break; // Completed making Armor 100%. } } else if (item.HasTag("/weapon/|/tool/")) { switch (result) { case ProgressResult.Good: skill.Train(4); break; // Successful in making a tool or a weapon. case ProgressResult.Finish: skill.Train(5); break; // Completed making tool or a weapon 100%. } } return; } if (skill.Info.Rank == SkillRank.R8) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Greatly successful in making Armor case ProgressResult.Good: skill.Train(2); break; // Successful in making Armors case ProgressResult.Finish: skill.Train(3); break; // Completed making Armor 100%. } } else if (item.HasTag("/shield/")) { switch (result) { case ProgressResult.Good: skill.Train(4); break; // Successful in making a Shield. case ProgressResult.Finish: skill.Train(5); break; // Completed making a Shield 100%. } } return; } if (skill.Info.Rank == SkillRank.R7) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging armor. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging armor. case ProgressResult.Finish: skill.Train(3); break; // Successfully forge armor. } } else if (item.HasTag("/helmet/")) { switch (result) { case ProgressResult.Good: skill.Train(4); break; // Achieve a good result forging a helmet. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge a helmet. } } return; } if (skill.Info.Rank == SkillRank.R6) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging armor. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging armor. case ProgressResult.Finish: skill.Train(3); break; // Successfully forge armor. } } else if (item.HasTag("/gauntlet/")) { switch (result) { case ProgressResult.Good: skill.Train(4); break; // Achieve a good result forging gauntlets. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge gauntlets. } } return; } if (skill.Info.Rank == SkillRank.R5) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging armor. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging armor. case ProgressResult.Finish: skill.Train(3); break; // Successfully forge armor. } } else if (item.HasTag("/armorboots/")) { switch (result) { case ProgressResult.Good: skill.Train(4); break; // Achieve a good result forging greaves. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge greaves. } } return; } if (skill.Info.Rank >= SkillRank.R4 && skill.Info.Rank <= SkillRank.R3) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.VeryGood: skill.Train(1); break; // Achieve a great result forging armor. case ProgressResult.Good: skill.Train(2); break; // Achieve a good result forging armor. case ProgressResult.Finish: skill.Train(3); break; // Successfully forge armor. } } else if (item.HasTag("/weapon/|/tool/")) { switch (result) { case ProgressResult.Good: skill.Train(4); break; // Achieve a good result forging a tool or a weapon. case ProgressResult.Finish: skill.Train(5); break; // Successfully forge a tool or a weapon. } } return; } if (skill.Info.Rank >= SkillRank.R2 && skill.Info.Rank <= SkillRank.R1) { if (item.HasTag("/armor/")) { switch (result) { case ProgressResult.Good: skill.Train(1); break; // Achieve a good result forging armor. case ProgressResult.Finish: skill.Train(2); break; // Successfully forge armor. } } else if (item.HasTag("/weapon/|/tool/")) { switch (result) { case ProgressResult.Good: skill.Train(3); break; // Achieve a good result forging a tool or a weapon. case ProgressResult.Finish: skill.Train(4); break; // Successfully forge a tool or a weapon. } } return; } }
protected void SendProgressResult(double min, double max, double current) { var result = new ProgressResult { Id = Id, Min = min, Max = max, Current = current }; Send(result); }
IAsyncResult BeginRequest(byte[] data, int offset, int count, ContentType contentType, RequestType requestType, AsyncCallback userCallback, object userState) { AsyncCallback callback = null; IAsyncResult result = null; if (currentProgressResult != null) { throw new NotSupportedException ("HttpApiClient does not " + "support concurrent I/O " + "operations."); } if (count > PAYLOAD_MAX_SIZE) { throw new ArgumentException("Payload exceedes max size"); } currentHttpRequest = (HttpWebRequest) WebRequest.Create(endPointUri); currentHttpRequest.Method = "POST"; if (contentType == ContentType.Binary) { currentHttpRequest.ContentType = "application/octet-stream"; } else { currentHttpRequest.ContentType = "text/plain"; } if (requestType == RequestType.Signal) { currentHttpRequest.Headers.Add("X-Emit", "yes"); } callback = new AsyncCallback(RequestCallback); result = currentHttpRequest.BeginGetRequestStream(callback, null); currentAsyncResult = result; currentProgressResult = new ProgressResult(requestType, data, offset, count, userCallback, userState); return currentProgressResult; }
void EndRequest(ProgressResult result) { ProgressResult progressResult = null; Exception exception = null; String denyMessage = null; progressResult = currentProgressResult; currentProgressResult = null; if (result == null) { throw new ArgumentNullException("result"); } if (progressResult == null) { throw new ArgumentException("A handle to the pending " + "operation is not available."); } if (currentAsyncResult != null && currentAsyncResult.IsCompleted == false) { exception = new WebException("Aborted", WebExceptionStatus.RequestCanceled); CompleteApiCall(exception, null); } denyMessage = progressResult.denyMessage; exception = progressResult.throwedException; if (denyMessage != null) { throw new HttpApiException(denyMessage, true); } if (exception is WebException) { throw new HttpApiException((WebException) exception); } if (exception != null) { throw new HttpApiException(exception); } }
/// <summary> /// Handles skill training by progress. /// </summary> /// <param name="creature"></param> /// <param name="skill"></param> /// <param name="result"></param> private void OnProgress(Creature creature, Skill skill, ProgressResult result) { if (skill.Info.Rank == SkillRank.Novice) { skill.Train(2); // Use the skill successfully. return; } if (skill.Info.Rank >= SkillRank.RF && skill.Info.Rank <= SkillRank.R3) { skill.Train(1); // Use the skill successfully. switch (result) { case ProgressResult.VeryGood: skill.Train(2); break; // Achieve a very good result. case ProgressResult.Bad: skill.Train(3); break; // The result is a failure. case ProgressResult.VeryBad: skill.Train(4); break; // The result is very bad. case ProgressResult.Finish: skill.Train(5); break; // Clothes are finished. } return; } if (skill.Info.Rank >= SkillRank.R2 && skill.Info.Rank <= SkillRank.R1) { skill.Train(1); // Use the skill successfully. switch (result) { case ProgressResult.Bad: skill.Train(2); break; // The result is a failure. case ProgressResult.VeryBad: skill.Train(3); break; // The result is very bad. case ProgressResult.Finish: skill.Train(4); break; // Clothes are finished. } return; } }
/// <summary> /// </summary> /// <param name="result"></param> private void ReportProgress(ProgressResult result) { _progressValue += result.Value; progressBar.Value = _progressValue; Debug.WriteLine("{0}: {1}", result.Name, _progressValue); }