commit 81031ff411868e630c830ae114abe1bdfea3e532 Author: Ellpeck Date: Sat May 30 19:41:49 2020 +0200 the beginning diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..634ecdc --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +bin/ +obj/ +/packages/ +.idea \ No newline at end of file diff --git a/Android/.config/dotnet-tools.json b/Android/.config/dotnet-tools.json new file mode 100644 index 0000000..c429d1a --- /dev/null +++ b/Android/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-mgcb": { + "version": "3.8.0.1375-develop", + "commands": [ + "mgcb" + ] + } + } +} \ No newline at end of file diff --git a/Android/Activity1.cs b/Android/Activity1.cs new file mode 100644 index 0000000..8c74e77 --- /dev/null +++ b/Android/Activity1.cs @@ -0,0 +1,49 @@ +using Android.App; +using Android.Content.PM; +using Android.OS; +using Android.Views; +using Microsoft.Xna.Framework; +using MLEM.Extensions; +using MLEM.Misc; +using ThemeParkClicker; + +namespace Android { + [Activity( + Label = "@string/app_name", + MainLauncher = true, + Icon = "@drawable/icon", + AlwaysRetainTaskState = true, + LaunchMode = LaunchMode.SingleInstance, + ScreenOrientation = ScreenOrientation.UserPortrait, + ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize + )] + public class Activity1 : AndroidGameActivity { + + private GameImpl game; + private View view; + + protected override void OnCreate(Bundle bundle) { + base.OnCreate(bundle); + // render under notches + if (Build.VERSION.SdkInt >= BuildVersionCodes.P) + this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges; + + TextInputWrapper.Current = new TextInputWrapper.Mobile(); + this.game = new GameImpl(); + this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window); + this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false; + this.game.GraphicsDeviceManager.IsFullScreen = true; + this.view = this.game.Services.GetService(typeof(View)) as View; + + this.SetContentView(this.view); + this.game.Run(); + } + + public override void OnWindowFocusChanged(bool hasFocus) { + base.OnWindowFocusChanged(hasFocus); + // hide the status bar + this.view.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky); + } + + } +} \ No newline at end of file diff --git a/Android/Android.csproj b/Android/Android.csproj new file mode 100644 index 0000000..e6dd93b --- /dev/null +++ b/Android/Android.csproj @@ -0,0 +1,81 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {410C0262-131C-4D0E-910D-D01B4F7143E0} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + Android + Android + 512 + true + Resources\Resource.Designer.cs + Resource + Off + .m4a + v9.0 + Properties\AndroidManifest.xml + false + Resources + Assets + true + Xamarin.Android.Net.AndroidClientHandler + + + true + full + false + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + DEBUG;TRACE;ANDROID + prompt + 4 + True + None + + + pdbonly + true + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + TRACE;ANDROID + prompt + 4 + False + SdkOnly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {3df7ae69-f3f0-461a-be98-f31eb576b5e2} + ThemeParkClicker + + + + \ No newline at end of file diff --git a/Android/Properties/AndroidManifest.xml b/Android/Properties/AndroidManifest.xml new file mode 100644 index 0000000..710acda --- /dev/null +++ b/Android/Properties/AndroidManifest.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/Android/Properties/AssemblyInfo.cs b/Android/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fd082d4 --- /dev/null +++ b/Android/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Android.App; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Android")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Android")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Android/Resources/Drawable/Icon.png b/Android/Resources/Drawable/Icon.png new file mode 100644 index 0000000..25fe044 Binary files /dev/null and b/Android/Resources/Drawable/Icon.png differ diff --git a/Android/Resources/Resource.Designer.cs b/Android/Resources/Resource.Designer.cs new file mode 100644 index 0000000..ffa9478 --- /dev/null +++ b/Android/Resources/Resource.Designer.cs @@ -0,0 +1,77 @@ +#pragma warning disable 1591 +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +[assembly: global::Android.Runtime.ResourceDesignerAttribute("Android.Resource", IsApplication=true)] + +namespace Android +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")] + public partial class Resource + { + + static Resource() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + public static void UpdateIdValues() + { + } + + public partial class Attribute + { + + static Attribute() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Attribute() + { + } + } + + public partial class Drawable + { + + // aapt resource value: 0x7F010000 + public const int Icon = 2130771968; + + static Drawable() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Drawable() + { + } + } + + public partial class String + { + + // aapt resource value: 0x7F020000 + public const int app_name = 2130837504; + + static String() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private String() + { + } + } + } +} +#pragma warning restore 1591 diff --git a/Android/Resources/Values/Strings.xml b/Android/Resources/Values/Strings.xml new file mode 100644 index 0000000..7f40978 --- /dev/null +++ b/Android/Resources/Values/Strings.xml @@ -0,0 +1,4 @@ + + + Android + diff --git a/Desktop/.config/dotnet-tools.json b/Desktop/.config/dotnet-tools.json new file mode 100644 index 0000000..c429d1a --- /dev/null +++ b/Desktop/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-mgcb": { + "version": "3.8.0.1375-develop", + "commands": [ + "mgcb" + ] + } + } +} \ No newline at end of file diff --git a/Desktop/Desktop.csproj b/Desktop/Desktop.csproj new file mode 100644 index 0000000..99301e5 --- /dev/null +++ b/Desktop/Desktop.csproj @@ -0,0 +1,25 @@ + + + + Exe + netcoreapp3.0 + false + false + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Desktop/Program.cs b/Desktop/Program.cs new file mode 100644 index 0000000..f2dfd5b --- /dev/null +++ b/Desktop/Program.cs @@ -0,0 +1,18 @@ +using Microsoft.Xna.Framework; +using MLEM.Misc; +using ThemeParkClicker; + +namespace Desktop { + public static class Program { + + public static void Main() { + TextInputWrapper.Current = new TextInputWrapper.DesktopGl((w, c) => w.TextInput += c); + using var game = new GameImpl(); + game.GraphicsDeviceManager.PreferredBackBufferWidth = 1080 / 3; + game.GraphicsDeviceManager.PreferredBackBufferHeight = 1920 / 3; + game.IsMouseVisible = true; + game.Run(); + } + + } +} \ No newline at end of file diff --git a/ThemeParkClicker.sln b/ThemeParkClicker.sln new file mode 100644 index 0000000..cd60f02 --- /dev/null +++ b/ThemeParkClicker.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ThemeParkClicker", "ThemeParkClicker\ThemeParkClicker.csproj", "{3DF7AE69-F3F0-461A-BE98-F31EB576B5E2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Android", "Android\Android.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop", "Desktop\Desktop.csproj", "{41506EAE-7E73-4147-8C8F-CA70924DB7FA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3DF7AE69-F3F0-461A-BE98-F31EB576B5E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3DF7AE69-F3F0-461A-BE98-F31EB576B5E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3DF7AE69-F3F0-461A-BE98-F31EB576B5E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3DF7AE69-F3F0-461A-BE98-F31EB576B5E2}.Release|Any CPU.Build.0 = Release|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.Build.0 = Release|Any CPU + {41506EAE-7E73-4147-8C8F-CA70924DB7FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41506EAE-7E73-4147-8C8F-CA70924DB7FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41506EAE-7E73-4147-8C8F-CA70924DB7FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41506EAE-7E73-4147-8C8F-CA70924DB7FA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/ThemeParkClicker/Content/Content.mgcb b/ThemeParkClicker/Content/Content.mgcb new file mode 100644 index 0000000..9a4ab94 --- /dev/null +++ b/ThemeParkClicker/Content/Content.mgcb @@ -0,0 +1,32 @@ + +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin +/intermediateDir:obj +/platform:DesktopGL +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# + +#begin Textures/Ui.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/Ui.png + +#begin Fonts/Regular.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/build:Fonts/Regular.spritefont + diff --git a/ThemeParkClicker/Content/Fonts/EXEPixelPerfect.ttf b/ThemeParkClicker/Content/Fonts/EXEPixelPerfect.ttf new file mode 100644 index 0000000..3b62ed4 Binary files /dev/null and b/ThemeParkClicker/Content/Fonts/EXEPixelPerfect.ttf differ diff --git a/ThemeParkClicker/Content/Fonts/Regular.spritefont b/ThemeParkClicker/Content/Fonts/Regular.spritefont new file mode 100644 index 0000000..d9022a5 --- /dev/null +++ b/ThemeParkClicker/Content/Fonts/Regular.spritefont @@ -0,0 +1,60 @@ + + + + + + + EXEPixelPerfect.ttf + + + 128 + + + 0 + + + true + + + + + + + + + + + + Ā + + + + diff --git a/ThemeParkClicker/Content/Textures/Ui.aseprite b/ThemeParkClicker/Content/Textures/Ui.aseprite new file mode 100644 index 0000000..9038f76 Binary files /dev/null and b/ThemeParkClicker/Content/Textures/Ui.aseprite differ diff --git a/ThemeParkClicker/Content/Textures/Ui.png b/ThemeParkClicker/Content/Textures/Ui.png new file mode 100644 index 0000000..529d563 Binary files /dev/null and b/ThemeParkClicker/Content/Textures/Ui.png differ diff --git a/ThemeParkClicker/GameImpl.cs b/ThemeParkClicker/GameImpl.cs new file mode 100644 index 0000000..47d32e8 --- /dev/null +++ b/ThemeParkClicker/GameImpl.cs @@ -0,0 +1,34 @@ +using System.Numerics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MLEM.Extensions; +using MLEM.Font; +using MLEM.Startup; + +namespace ThemeParkClicker { + public class GameImpl : MlemGame { + + public static GameImpl Instance { get; private set; } + public BigInteger Tickets = 200; + public Ui Ui { get; private set; } + + public GameImpl() { + Instance = this; + } + + protected override void LoadContent() { + base.LoadContent(); + this.Ui = new Ui(this.UiSystem); + } + + public string DisplayTicketCount() { + return this.Tickets.ToString(); + } + + protected override void DoDraw(GameTime gameTime) { + this.GraphicsDevice.Clear(ColorExtensions.FromHex(0x86cfcb)); + base.DoDraw(gameTime); + } + + } +} \ No newline at end of file diff --git a/ThemeParkClicker/RainingTicket.cs b/ThemeParkClicker/RainingTicket.cs new file mode 100644 index 0000000..7ae81ac --- /dev/null +++ b/ThemeParkClicker/RainingTicket.cs @@ -0,0 +1,35 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MLEM.Extensions; +using MLEM.Misc; +using MLEM.Textures; + +namespace ThemeParkClicker { + public class RainingTicket { + + private static readonly Random Random = new Random(); + private readonly Vector2 speed; + private readonly float rotationSpeed; + private float rotation; + private Vector2 position; + + public RainingTicket() { + this.position = new Vector2((float) Random.NextDouble(), -0.15F); + this.speed = new Vector2((float) Random.NextDouble() * 0.0005F - 0.00025F, 0.005F + (float) Random.NextDouble() * 0.01F); + this.rotationSpeed = MathHelper.ToRadians((float) Random.NextDouble() * 5); + } + + public bool Update() { + this.rotation += this.rotationSpeed; + this.position += this.speed; + return this.position.Y >= 1.15F; + } + + public void Draw(SpriteBatch batch, Vector2 viewport, float scale) { + var tex = Ui.Texture[2, 0]; + batch.Draw(tex, this.position * viewport, Color.White, this.rotation, tex.Size.ToVector2() / 2, scale, SpriteEffects.None, 0); + } + + } +} \ No newline at end of file diff --git a/ThemeParkClicker/ThemeParkClicker.csproj b/ThemeParkClicker/ThemeParkClicker.csproj new file mode 100644 index 0000000..7dadf37 --- /dev/null +++ b/ThemeParkClicker/ThemeParkClicker.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.0 + + + + + + all + + + + + + + + \ No newline at end of file diff --git a/ThemeParkClicker/Ui.cs b/ThemeParkClicker/Ui.cs new file mode 100644 index 0000000..8d17f30 --- /dev/null +++ b/ThemeParkClicker/Ui.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Numerics; +using Coroutine; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using MLEM.Font; +using MLEM.Startup; +using MLEM.Textures; +using MLEM.Ui; +using MLEM.Ui.Elements; + +namespace ThemeParkClicker { + public class Ui { + + public static readonly UniformTextureAtlas Texture = new UniformTextureAtlas(MlemGame.LoadContent("Textures/Ui"), 16, 16); + + public Ui(UiSystem uiSystem) { + uiSystem.GlobalScale = 4; + uiSystem.AutoScaleWithScreen = true; + uiSystem.AutoScaleReferenceSize = new Point(720, 1280); + uiSystem.Style.Font = new GenericSpriteFont(MlemGame.LoadContent("Fonts/Regular")); + uiSystem.Style.TextScale = 0.1F; + + // ticket store ui + var rainingTickets = new List(); + Group ticketStoreUi = new Group(Anchor.TopLeft, Vector2.One, false) { + OnUpdated = (e, time) => { + for (var i = rainingTickets.Count - 1; i >= 0; i--) { + if (rainingTickets[i].Update()) + rainingTickets.RemoveAt(i); + } + while (rainingTickets.Count < BigInteger.Min(GameImpl.Instance.Tickets / 100, 500)) + rainingTickets.Add(new RainingTicket()); + }, + OnDrawn = (e, time, batch, alpha) => { + foreach (var ticket in rainingTickets) + ticket.Draw(batch, e.DisplayArea.Size, e.Scale); + } + }; + ticketStoreUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, p => GameImpl.Instance.DisplayTicketCount(), true) { + TextScale = 0.3F + }); + var storeGroup = ticketStoreUi.AddChild(new CustomDrawGroup(Anchor.AutoLeft, Vector2.One)); + storeGroup.AddChild(new Image(Anchor.TopLeft, Vector2.One, Texture[0, 0, 2, 3]) { + OnPressed = e => { + GameImpl.Instance.Tickets++; + CoroutineHandler.Start(WobbleElement(storeGroup)); + }, + CanBeSelected = true, + CanBeMoused = true + }); + ticketStoreUi.OnAreaUpdated += e => storeGroup.Size = new Vector2(e.DisplayArea.Width / e.Scale); + uiSystem.Add("TicketStore", ticketStoreUi); + } + + private static IEnumerator WobbleElement(CustomDrawGroup element, float intensity = 0.01F) { + var sin = 0F; + while (sin < MathHelper.Pi) { + element.ScaleOrigin(1 + (float) Math.Sin(sin) * intensity * element.Scale); + sin += 0.2F; + yield return new WaitEvent(CoroutineEvents.Update); + } + element.Transform = Matrix.Identity; + } + + } +} \ No newline at end of file