public override async Task DoActionAsync() { for (int i = 0; i < Amount; i++) { GameObject ins = Prefabs.Instantiate(Identify, GameArgs.World.transform); CoreBase[] targets = (from a in GameArgs.World.GetComponentsInChildren <TroopCore>() where a.Team == AgentTeam.Ally && a.Type == AgentType.Troop select a).ToArray(); if (targets.Length == 0) { targets = (from a in GameArgs.World.GetComponentsInChildren <BuildingCore>() where a.Team == AgentTeam.Ally && a.Identify != 20001 select a).ToArray(); } if (targets.Length == 0) { targets = (from a in GameArgs.World.GetComponentsInChildren <BuildingCore>() where a.Team == AgentTeam.Ally select a).ToArray(); } float posX = Naukri.Random.Objects(targets).transform.position.x + Random.Range(-5f, 0); if (posX < -35) { posX = -35 + +Random.Range(5f, 0); } ins.transform.position = new Vector3(posX, Random.Range(-1f, 10f), 0); ins.GetComponent <CoreBase>().SetTeam(AgentTeam.Enemy); await Awaiters.Seconds(0.1f); } await Awaiters.Seconds(2f); }
/// Does some synchronous work inside the compositor. /// Some mostly-faked progress will be displayed. public async Task <T> RunInCompositorAsync <T>( OverlayType overlayType, Func <T> action, float fadeDuration, bool showSuccessText = false) { SetOverlayFromType(overlayType); bool bFullProgress = false; UpdateProgress(bFullProgress ? 1.0f : 0.0f); App.VrSdk.SetOverlayAlpha(0); await Awaiters.NextFrame; try { // You can't rely on the SteamVR compositor fade being totally over in the time // you specified. You also can't rely on being able to get a sensible value for the fade // alpha, so you can't reliably wait for it to be done. // Therefore, we use the simple method of just waiting a bit longer than we should // need to, by passing slightly-too-wide bounds. await FadeCompositorAndOverlayAsync(0, 1.1f, fadeDuration); // Wait one additional frame for any transitions to complete (e.g. fade to black). App.VrSdk.PauseRendering(true); Progress.Report(0.25); await Awaiters.NextFrame; T result = default; try { result = action(); } catch (Exception e) { Debug.LogException(e); } Progress.Report(0.75); if (showSuccessText) { SetText("Success!"); await Awaiters.Seconds(1f); } App.VrSdk.PauseRendering(false); await FadeCompositorAndOverlayAsync(1, 0, fadeDuration); return(result); } catch (Exception) { App.VrSdk.PauseRendering(false); App.VrSdk.FadeFromCompositor(0); SetOverlayTransitionRatio(0); throw; } }
public override async Task Test() { foreach (string ab in AssetBundleLoader.Manifest.GetAllAssetBundles()) { paths.Add(ab); } var handle = await AssetBundleLoader.AsyncLoad("Prefabs/CompleteLevelArt.prefab.ab"); ++handle.RefCount; await Awaiters.Seconds(5f); --handle.RefCount; AssetSystem.Instance.GarbageCollect(); ResLog.Log("Async Load Finished"); handle = AssetBundleLoader.Load("Prefabs/CompleteLevelArt.prefab.ab"); ++handle.RefCount; await Awaiters.Seconds(5f); --handle.RefCount; AssetSystem.Instance.GarbageCollect(); ResLog.Log("Load Finished"); List <AssetHandle> handles = new List <AssetHandle>(); foreach (string ab in AssetBundleLoader.Manifest.GetAllAssetBundles()) { var h = await AssetBundleLoader.AsyncLoad(ab); ++h.RefCount; handles.Add(h); } ResLog.Log("Async Load All"); await Awaiters.Seconds(5f); ResLog.Log("Disposing"); handles.ForEach(h => -- h.RefCount); handles.Clear(); AssetSystem.Instance.GarbageCollect(); ResLog.Log("Async Load All Finished"); foreach (string ab in AssetBundleLoader.Manifest.GetAllAssetBundles()) { var h = AssetBundleLoader.Load(ab); ++h.RefCount; handles.Add(h); } ResLog.Log("Load All"); await Awaiters.Seconds(5f); ResLog.Log("Disposing"); handles.ForEach(h => -- h.RefCount); handles.Clear(); AssetSystem.Instance.GarbageCollect(); ResLog.Log("Load All Finished"); }
private async Task CheckScreen() { var timeout = Awaiters.Seconds(1f); while (true) { await timeout; screen.Update(); } }
public async Task NightMare() { float posX = GameObject.Find("EvilCastle").transform.position.x; for (; ;) { GameObject ins = Prefabs.Instantiate(Random.Range(10001, 10009), GameArgs.World.transform); ins.transform.SetOnHorizon(posX); ins.GetComponent <CoreBase>().SetTeam(AgentTeam.Enemy); await Awaiters.Seconds(0.5f); } }
public async Task DoActionAsync(CoreBase trainBy) { for (int i = 0; i < Amount; i++) { CoreBase g = Prefabs.Instantiate(Identify).GetComponent <CoreBase>(); g.transform.SetOnHorizon(trainBy.transform.position.x); // TroopDetails det = g.GetComponent <CoreBase>().GetDetails <TroopDetails>(); det.DeBuff.AddFlag(AgentDeBuff.Freeze); det.SetLevel(trainBy.Details.Level); // g.transform.parent = trainBy.transform.parent; g.SetTeam(trainBy.Team); await Awaiters.Seconds(0.1f); } }
public async Task Exodia() { Material mt = GameArgs.World.GetComponent <World>().MateriaGrayScale; for (; ;) { GameObject eff = Prefabs.Instantiate(30002, GameArgs.World.transform); eff.transform.SetOnHorizon(); var det = eff.GetComponent <EffectBase>(); det.Team = Naukri.Random.Objects(new AgentTeam[] { AgentTeam.Ally, AgentTeam.Enemy }); det.TargetTeam = det.Team == AgentTeam.Ally ? AgentTeam.Enemy : AgentTeam.Ally; det.GetComponent <EffectBase>().Damage = 100; if (eff.GetComponent <EffectBase>().Team == AgentTeam.Enemy) { eff.GetComponent <SpriteRenderer>().material = mt; } eff.transform.SetOnHorizon(Random.Range(-40, 40)); eff.transform.Translate(new Vector3(0, -3, 0)); await Awaiters.Seconds(0.2f); } }
async Task TestLoad() { List <GameObject> instances = new List <GameObject>(); var prefabResource = PrefabLoader.Load("Prefabs/CompleteLevelArt"); instances.Add(prefabResource.Instantiate <GameObject>()); instances.Add(prefabResource.Instantiate <GameObject>()); AssetSystem.Instance.GarbageCollect(); ResLog.Log("Instantiate Finish"); await Awaiters.Seconds(5f); instances.ForEach(go => GameObject.Destroy(go)); instances.Clear(); ResLog.Log("Destroy Instances"); await Awaiters.Seconds(3f); AssetSystem.Instance.GarbageCollect(); ResLog.Log("Garbage Collect"); await Awaiters.Seconds(5f); ResLog.Log("TestLoad Finish"); }
public override async Task DoActionAsync() { await Awaiters.Seconds(0); }