update coroutine

This commit is contained in:
Ellpeck 2020-06-15 02:25:41 +02:00
parent 8e3f4812d6
commit acc544ba26
3 changed files with 13 additions and 13 deletions

BIN
Media/Icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Coroutine" Version="1.0.4" /> <PackageReference Include="Coroutine" Version="2.0.0" />
<PackageReference Include="MLEM.Startup" Version="3.3.3-204" /> <PackageReference Include="MLEM.Startup" Version="3.3.3-204" />
<PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189"> <PackageReference Include="MonoGame.Framework.Portable" Version="3.7.1.189">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>

View file

@ -385,7 +385,7 @@ namespace TouchyTickets {
uiSystem.TextFormatter.AddImage(modifier.Name, modifier.Texture); uiSystem.TextFormatter.AddImage(modifier.Name, modifier.Texture);
} }
public static IEnumerator<IWait> DisplaySplash(Action loadGame) { public static IEnumerator<Wait> DisplaySplash(Action loadGame) {
var splash = new Group(Anchor.TopLeft, Vector2.One, false) { var splash = new Group(Anchor.TopLeft, Vector2.One, false) {
OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, Color.Black * alpha) OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, Color.Black * alpha)
}; };
@ -395,9 +395,9 @@ namespace TouchyTickets {
GameImpl.Instance.UiSystem.Add("Splash", splash).Priority = 100000; GameImpl.Instance.UiSystem.Add("Splash", splash).Priority = 100000;
while (center.DrawAlpha < 1) { while (center.DrawAlpha < 1) {
center.DrawAlpha += 0.015F; center.DrawAlpha += 0.015F;
yield return new WaitEvent(CoroutineEvents.Update); yield return new Wait(CoroutineEvents.Update);
} }
yield return new WaitSeconds(0.5); yield return new Wait(0.5);
var analyticsFlag = new FileInfo(Path.Combine(SaveHandler.GetGameDirectory(true).FullName, "_ReadGdpr")); var analyticsFlag = new FileInfo(Path.Combine(SaveHandler.GetGameDirectory(true).FullName, "_ReadGdpr"));
if (!analyticsFlag.Exists) { if (!analyticsFlag.Exists) {
@ -413,25 +413,25 @@ namespace TouchyTickets {
CoroutineHandler.RaiseEvent(evt); CoroutineHandler.RaiseEvent(evt);
} }
}); });
yield return new WaitEvent(evt); yield return new Wait(evt);
} }
yield return new WaitSeconds(0.25); yield return new Wait(0.25);
loadGame(); loadGame();
yield return new WaitSeconds(0.25); yield return new Wait(0.25);
while (center.DrawAlpha > 0) { while (center.DrawAlpha > 0) {
center.DrawAlpha -= 0.015F; center.DrawAlpha -= 0.015F;
yield return new WaitEvent(CoroutineEvents.Update); yield return new Wait(CoroutineEvents.Update);
} }
while (splash.DrawAlpha > 0) { while (splash.DrawAlpha > 0) {
splash.DrawAlpha -= 0.015F; splash.DrawAlpha -= 0.015F;
yield return new WaitEvent(CoroutineEvents.Update); yield return new Wait(CoroutineEvents.Update);
} }
splash.System.Remove(splash.Root.Name); splash.System.Remove(splash.Root.Name);
} }
private void FadeUi(bool fadeOut, Action after = null) { private void FadeUi(bool fadeOut, Action after = null) {
IEnumerator<IWait> Impl() { IEnumerator<Wait> Impl() {
// disable input handling during fade // disable input handling during fade
this.uiSystem.Controls.HandleTouch = false; this.uiSystem.Controls.HandleTouch = false;
GameImpl.Instance.DrawMap = true; GameImpl.Instance.DrawMap = true;
@ -440,7 +440,7 @@ namespace TouchyTickets {
while (alpha > 0) { while (alpha > 0) {
alpha -= 0.03F; alpha -= 0.03F;
this.currentUi.DrawAlpha = !fadeOut ? 1 - alpha : alpha; this.currentUi.DrawAlpha = !fadeOut ? 1 - alpha : alpha;
yield return new WaitEvent(CoroutineEvents.Update); yield return new Wait(CoroutineEvents.Update);
} }
this.uiSystem.Controls.HandleTouch = true; this.uiSystem.Controls.HandleTouch = true;
GameImpl.Instance.DrawMap = fadeOut; GameImpl.Instance.DrawMap = fadeOut;
@ -519,12 +519,12 @@ namespace TouchyTickets {
} }
} }
private static IEnumerator<IWait> WobbleElement(CustomDrawGroup element, float intensity = 0.02F) { private static IEnumerator<Wait> WobbleElement(CustomDrawGroup element, float intensity = 0.02F) {
var sin = 0F; var sin = 0F;
while (sin < MathHelper.Pi) { while (sin < MathHelper.Pi) {
element.ScaleOrigin(1 + (float) Math.Sin(sin) * intensity); element.ScaleOrigin(1 + (float) Math.Sin(sin) * intensity);
sin += 0.2F; sin += 0.2F;
yield return new WaitEvent(CoroutineEvents.Update); yield return new Wait(CoroutineEvents.Update);
} }
element.Transform = Matrix.Identity; element.Transform = Matrix.Identity;
} }