From 020fd61af37eaaac81d7b930be15f8c350f28b7d Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Mon, 25 Dec 2017 14:07:42 +0100 Subject: I dab everyday --- Penguloon/Activity.cs | 2 +- Penguloon/Content/Content.mgcb | 7 +++ Penguloon/Content/Fonts/GWENT/52.spritefont | 60 +++++++++++++++++++++ Penguloon/Content/UI/msgBoxBackground.png | Bin 5079 -> 6558 bytes Penguloon/Content/UI/optionsMenuBackground.png | Bin 12347 -> 8797 bytes Penguloon/ContentPathManager.cs | 1 + Penguloon/Controls/IngameOptions.cs | 2 +- Penguloon/Controls/MessageBox.cs | 8 +-- Penguloon/Enemies/EnemyBase.cs | 2 +- Penguloon/Enums.cs | 3 +- Penguloon/Levels/LevelBase.cs | 2 +- Penguloon/Main.cs | 8 ++- Penguloon/Penguloon.csproj | 6 ++- Penguloon/Properties/AndroidManifest.xml | 4 +- Penguloon/Resources/Resource.Designer.cs | 33 ++++++------ Penguloon/Resources/Values/Strings.xml | 3 +- Penguloon/SceneManager.cs | 6 +++ Penguloon/Scenes/LevelSelectionScene.cs | 6 +-- Penguloon/Scenes/MenuScene.cs | 14 +++++ Penguloon/Scenes/StatsScene.cs | 69 +++++++++++++++++++++++++ Penguloon/StaticUIValues.cs | 16 +++--- Penguloon/UserdataManager.cs | 50 ++++++++++++++++++ 22 files changed, 264 insertions(+), 38 deletions(-) create mode 100644 Penguloon/Content/Fonts/GWENT/52.spritefont create mode 100644 Penguloon/Scenes/StatsScene.cs create mode 100644 Penguloon/UserdataManager.cs diff --git a/Penguloon/Activity.cs b/Penguloon/Activity.cs index bb5a3d4..1a01358 100644 --- a/Penguloon/Activity.cs +++ b/Penguloon/Activity.cs @@ -18,7 +18,7 @@ namespace Penguloon protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); - var g = new Main(Resources); + var g = new Main(Resources, ApplicationContext); SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); } diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index 4ea14fe..0ae8103 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -551,3 +551,10 @@ /processorParam:TextureFormat=Color /build:UI/msgBoxBackground.png +#begin Fonts/GWENT/52.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/52.spritefont + diff --git a/Penguloon/Content/Fonts/GWENT/52.spritefont b/Penguloon/Content/Fonts/GWENT/52.spritefont new file mode 100644 index 0000000..c2e9ac7 --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/52.spritefont @@ -0,0 +1,60 @@ + + + + + + + GWENT.ttf + + + 52 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/Penguloon/Content/UI/msgBoxBackground.png b/Penguloon/Content/UI/msgBoxBackground.png index 3516ae8..87e161f 100644 Binary files a/Penguloon/Content/UI/msgBoxBackground.png and b/Penguloon/Content/UI/msgBoxBackground.png differ diff --git a/Penguloon/Content/UI/optionsMenuBackground.png b/Penguloon/Content/UI/optionsMenuBackground.png index 2eb62bd..ca9e16d 100644 Binary files a/Penguloon/Content/UI/optionsMenuBackground.png and b/Penguloon/Content/UI/optionsMenuBackground.png differ diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs index cd305c0..4996aa4 100644 --- a/Penguloon/ContentPathManager.cs +++ b/Penguloon/ContentPathManager.cs @@ -65,6 +65,7 @@ namespace Penguloon "Fonts/GWENT/24", "Fonts/GWENT/36", "Fonts/GWENT/48", + "Fonts/GWENT/52", "Fonts/GWENT/72", }; diff --git a/Penguloon/Controls/IngameOptions.cs b/Penguloon/Controls/IngameOptions.cs index d6eda02..e5a6890 100644 --- a/Penguloon/Controls/IngameOptions.cs +++ b/Penguloon/Controls/IngameOptions.cs @@ -31,7 +31,7 @@ namespace Penguloon.Controls this.BackgroundDisabled = ContentManager.GetTexture("UI/optionsMenuBackground"); Vector2 BtnSize = new Vector2(Size.X - 90, StaticUIValues.IngameUIPlayButtonHeight); - Vector2 MsgBoxSize = new Vector2(900, 450); + Vector2 MsgBoxSize = new Vector2(900, 550); BtnContinue = new Button(parentScene, new Vector2(position.X + (Size.X / 2) - (BtnSize.X / 2), Position.Y + 50), diff --git a/Penguloon/Controls/MessageBox.cs b/Penguloon/Controls/MessageBox.cs index 6736132..861120e 100644 --- a/Penguloon/Controls/MessageBox.cs +++ b/Penguloon/Controls/MessageBox.cs @@ -27,10 +27,10 @@ namespace Penguloon.Controls this.BackgroundDisabled = ContentManager.GetTexture("UI/msgBoxBackground"); this.Text = text; - this.Font = ContentManager.GetFont("Fonts/GWENT/48"); - this.ForeColor = Color.White; - this.BorderColor = Color.Black; - this.BorderWidth = 2; + this.Font = ContentManager.GetFont("Fonts/GWENT/52"); + this.ForeColor = Color.Gray; + this.BorderColor = Color.Gray; + this.BorderWidth = 0; this.TextAllignment = TextAllignment.CenterTop; this.PaddingTop = 35; diff --git a/Penguloon/Enemies/EnemyBase.cs b/Penguloon/Enemies/EnemyBase.cs index 9bb6230..986c206 100644 --- a/Penguloon/Enemies/EnemyBase.cs +++ b/Penguloon/Enemies/EnemyBase.cs @@ -53,7 +53,7 @@ namespace Penguloon.Enemies int tileX = (int)(TargetPosition.X + 2) / Map.TileWidth; int tileY = (int)(TargetPosition.Y + 2) / Map.TileHeight; - if (Vector2.Distance(Position, TargetPosition) <= 3) + if (Vector2.Distance(Position, TargetPosition) <= 4) { if(MovingTowardsFinish) { diff --git a/Penguloon/Enums.cs b/Penguloon/Enums.cs index bc2fa6d..a815082 100644 --- a/Penguloon/Enums.cs +++ b/Penguloon/Enums.cs @@ -17,7 +17,8 @@ namespace Penguloon Menu, Ingame, Loading, - LevelSelection + LevelSelection, + Stats } public enum ControlState diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs index d8a2867..f331ae7 100644 --- a/Penguloon/Levels/LevelBase.cs +++ b/Penguloon/Levels/LevelBase.cs @@ -102,7 +102,7 @@ namespace Penguloon.Levels public void FinishGame() { - + // upload score here or something } } } \ No newline at end of file diff --git a/Penguloon/Main.cs b/Penguloon/Main.cs index b2844fc..d9d8003 100644 --- a/Penguloon/Main.cs +++ b/Penguloon/Main.cs @@ -5,6 +5,7 @@ using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input.Touch; using Android.Content.Res; +using Android.Content; namespace Penguloon { @@ -35,8 +36,11 @@ namespace Penguloon set => _resources = value; } - public Main(Resources resources) + public Context Context { get; set; } + + public Main(Resources resources, Context context) { + Context = context; Resources = resources; Graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; @@ -70,6 +74,8 @@ namespace Penguloon ContentManager.LoadContent(this); + UserdataManager.ReadData(Context); + // TODO: use this.Content to load your game content here } diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index 5afafc0..a7d05f1 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -102,15 +102,19 @@ + + - + + Designer + diff --git a/Penguloon/Properties/AndroidManifest.xml b/Penguloon/Properties/AndroidManifest.xml index ebf11be..7c30976 100644 --- a/Penguloon/Properties/AndroidManifest.xml +++ b/Penguloon/Properties/AndroidManifest.xml @@ -1,5 +1,7 @@  - + + + \ No newline at end of file diff --git a/Penguloon/Resources/Resource.Designer.cs b/Penguloon/Resources/Resource.Designer.cs index 1a0115e..c33b048 100644 --- a/Penguloon/Resources/Resource.Designer.cs +++ b/Penguloon/Resources/Resource.Designer.cs @@ -66,33 +66,36 @@ namespace Penguloon // aapt resource value: 0x7f030000 public const int ApplicationName = 2130903040; - // aapt resource value: 0x7f030009 - public const int IngameNo = 2130903049; - - // aapt resource value: 0x7f030003 - public const int IngameOptions = 2130903043; + // aapt resource value: 0x7f03000a + public const int IngameNo = 2130903050; - // aapt resource value: 0x7f030005 - public const int IngameOptionsContinue = 2130903045; + // aapt resource value: 0x7f030004 + public const int IngameOptions = 2130903044; // aapt resource value: 0x7f030006 - public const int IngameOptionsQuit = 2130903046; + public const int IngameOptionsContinue = 2130903046; // aapt resource value: 0x7f030007 - public const int IngameOptionsQuitConfirmation = 2130903047; - - // aapt resource value: 0x7f030004 - public const int IngameStart = 2130903044; + public const int IngameOptionsQuit = 2130903047; // aapt resource value: 0x7f030008 - public const int IngameYes = 2130903048; + public const int IngameOptionsQuitConfirmation = 2130903048; - // aapt resource value: 0x7f030002 - public const int LevelSelectionBack = 2130903042; + // aapt resource value: 0x7f030005 + public const int IngameStart = 2130903045; + + // aapt resource value: 0x7f030009 + public const int IngameYes = 2130903049; + + // aapt resource value: 0x7f030003 + public const int LevelSelectionBack = 2130903043; // aapt resource value: 0x7f030001 public const int MenuBtnPlay = 2130903041; + // aapt resource value: 0x7f030002 + public const int MenuBtnStats = 2130903042; + static String() { global::Android.Runtime.ResourceIdManager.UpdateIdValues(); diff --git a/Penguloon/Resources/Values/Strings.xml b/Penguloon/Resources/Values/Strings.xml index 0af942b..1a1452b 100644 --- a/Penguloon/Resources/Values/Strings.xml +++ b/Penguloon/Resources/Values/Strings.xml @@ -4,7 +4,8 @@ Play - + Stats + Back diff --git a/Penguloon/SceneManager.cs b/Penguloon/SceneManager.cs index 7ea296a..dd399e9 100644 --- a/Penguloon/SceneManager.cs +++ b/Penguloon/SceneManager.cs @@ -15,6 +15,8 @@ namespace Penguloon public static SceneBase GameScene { get; set; } + public static SceneBase StatsScene { get; set; } + /// /// Initialize scene manager. /// @@ -39,6 +41,8 @@ namespace Penguloon LevelSelectionScene.Draw(deltaTime); break; case SelectedScene.Loading: LoadingScene.Draw(deltaTime); break; + case SelectedScene.Stats: + StatsScene.Draw(deltaTime); break; default: return; @@ -62,6 +66,8 @@ namespace Penguloon LevelSelectionScene.Update(deltaTime, touchLocations); break; case SelectedScene.Loading: LoadingScene.Update(deltaTime, touchLocations); break; + case SelectedScene.Stats: + StatsScene.Update(deltaTime, touchLocations); break; default: return; diff --git a/Penguloon/Scenes/LevelSelectionScene.cs b/Penguloon/Scenes/LevelSelectionScene.cs index 4df627c..dbc6601 100644 --- a/Penguloon/Scenes/LevelSelectionScene.cs +++ b/Penguloon/Scenes/LevelSelectionScene.cs @@ -13,11 +13,11 @@ namespace Penguloon.Scenes public override void CreateControls() { - Button btnStart = new Button(this, + Button btnBack = new Button(this, new Vector2(10, 10), StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.LevelSelectionBack)); - btnStart.OnClick += BtnStart_OnClick; + btnBack.OnClick += BtnStart_OnClick; int levelSelectorPosY = (int)((StaticUIValues.ScreenViewport.Y - StaticUIValues.MenuButtonSize.Y) - StaticUIValues.LevelSelectorHeight); @@ -25,7 +25,7 @@ namespace Penguloon.Scenes new Vector2(0, levelSelectorPosY), new Vector2(StaticUIValues.ScreenViewport.X, StaticUIValues.LevelSelectorHeight)); Controls.Add(levelSelector); - Controls.Add(btnStart); + Controls.Add(btnBack); } private void BtnStart_OnClick(object sender, ClickArgs e) diff --git a/Penguloon/Scenes/MenuScene.cs b/Penguloon/Scenes/MenuScene.cs index 24a260c..7957151 100644 --- a/Penguloon/Scenes/MenuScene.cs +++ b/Penguloon/Scenes/MenuScene.cs @@ -18,9 +18,23 @@ namespace Penguloon.Scenes new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100), StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.MenuBtnPlay)); + Button btnStats = new Button(this, + new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100 + StaticUIValues.MenuButtonSize.Y + 25), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.MenuBtnStats)); + btnStart.OnClick += BtnStart_OnClick; + btnStats.OnClick += BtnStats_OnClick; Controls.Add(btnStart); + Controls.Add(btnStats); + } + + private void BtnStats_OnClick(object sender, ClickArgs e) + { + if (SceneManager.StatsScene == null) + SceneManager.StatsScene = new StatsScene(Main); + + SceneManager.SelectedScene = SelectedScene.Stats; } private void BtnStart_OnClick(object sender, ClickArgs e) diff --git a/Penguloon/Scenes/StatsScene.cs b/Penguloon/Scenes/StatsScene.cs new file mode 100644 index 0000000..21adf27 --- /dev/null +++ b/Penguloon/Scenes/StatsScene.cs @@ -0,0 +1,69 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Controls; + +namespace Penguloon.Scenes +{ + class StatsScene : SceneBase + { + public StatsScene(Main main) : base(main) + { + + } + + public override void CreateControls() + { + Button btnBack = new Button(this, + new Vector2(10, 10), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.LevelSelectionBack)); + + btnBack.OnClick += BtnStart_OnClick; + + Controls.Add(btnBack); + } + + private void BtnStart_OnClick(object sender, ClickArgs e) + { + SceneManager.SelectedScene = SelectedScene.Menu; + } + + public override void Draw(float deltaTime) + { + // background + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/background"), + destinationRectangle: new Rectangle(0, 0, (int)StaticUIValues.ScreenViewport.X, (int)StaticUIValues.ScreenViewport.Y)); + + DrawSnowflakes(); + + int borderHorizontalY = 10 + (int)StaticUIValues.MenuButtonSize.Y + 50; + + //border top + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), + destinationRectangle: new Rectangle(50, + borderHorizontalY - 7, StaticUIValues.BorderWidth * 2, StaticUIValues.BorderWidth * 2)); + + //border bottom + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), + destinationRectangle: new Rectangle(50, + (int)StaticUIValues.ScreenViewport.Y - 50 - (StaticUIValues.BorderWidth * 2) + 7, StaticUIValues.BorderWidth * 2, StaticUIValues.BorderWidth * 2)); + + //border vertical + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"), + destinationRectangle: new Rectangle(50, + borderHorizontalY, StaticUIValues.BorderWidth * 2, (int)StaticUIValues.ScreenViewport.Y - (borderHorizontalY) - 50)); + + DrawStats(borderHorizontalY); + + base.Draw(deltaTime); + } + + private void DrawStats(int borderHorizontalY) + { + DrawText(ContentManager.GetFont(StaticUIValues.MenuFont), UserdataManager.TotalKills.ToString(), + new Vector2(120, borderHorizontalY), + new Vector2(0, 0), + TextAllignment.LeftTop, Color.White, Color.Black, 2); + } + } +} \ No newline at end of file diff --git a/Penguloon/StaticUIValues.cs b/Penguloon/StaticUIValues.cs index 9068461..f4637b7 100644 --- a/Penguloon/StaticUIValues.cs +++ b/Penguloon/StaticUIValues.cs @@ -20,7 +20,6 @@ namespace Penguloon public static string MenuFont { get; set; } public static string IngameFont { get; set; } - public static string IngameFontSmall { get; set; } public static int IngameUIWidth { get; set; } @@ -50,6 +49,8 @@ namespace Penguloon IngameUIPlayButtonHeight = 120; ChangeSpeedButtonWidth = 200; IngameOptionsSize = new Vector2(800, 1000); + IngameFont = "Fonts/GWENT/36"; + IngameUITextAreaHeight = 160; } else if (ScreenViewport.X >= 1920) { @@ -61,6 +62,8 @@ namespace Penguloon IngameUIPlayButtonHeight = 120; ChangeSpeedButtonWidth = 200; IngameOptionsSize = new Vector2((int)(800 * 0.85), (int)(1000 * 0.85)); + IngameFont = "Fonts/GWENT/36"; + IngameUITextAreaHeight = 160; } else if (ScreenViewport.X >= 1280) { @@ -71,6 +74,8 @@ namespace Penguloon IngameUIPlayButtonHeight = 80; ChangeSpeedButtonWidth = 130; IngameOptionsSize = new Vector2((int)(800 * 0.7), (int)(1000 * 0.7)); + IngameFont = "Fonts/GWENT/24"; + IngameUITextAreaHeight = 120; } else { @@ -81,17 +86,14 @@ namespace Penguloon IngameUIPlayButtonHeight = 80; ChangeSpeedButtonWidth = 130; IngameOptionsSize = new Vector2((int)(800 * 0.7), (int)(1000 * 0.7)); + IngameFont = "Fonts/GWENT/24"; + IngameUITextAreaHeight = 120; } - IngameFont = "Fonts/GWENT/24"; - IngameFontSmall = "Fonts/GWENT/16"; - LoadingProgressbarPosition = new Vector2((ScreenViewport.X - LoadingProgressbarSize.X) / 2, ScreenViewport.Y - LoadingProgressbarSize.Y - 200); LoadingProgressbarValuePosition = new Vector2(LoadingProgressbarPosition.X + 5, LoadingProgressbarPosition.Y + 5); - SnowflakeSize = 100; - IngameUITextAreaHeight = 120; - + SnowflakeSize = 100; } } } \ No newline at end of file diff --git a/Penguloon/UserdataManager.cs b/Penguloon/UserdataManager.cs new file mode 100644 index 0000000..872ab1d --- /dev/null +++ b/Penguloon/UserdataManager.cs @@ -0,0 +1,50 @@ +using Android.Content; +using Java.IO; +using System; +using System.Linq; + + +namespace Penguloon +{ + public static class UserdataManager + { + public static int TotalKills { get; set; } + public static int TotalMoneySpent { get; set; } + public static int GamesPlayed { get; set; } + + public static int HighestRound { get; set; } + public static int HighestKills { get; set; } + + public static void WriteData(Context context) + { + File file = new File(context.CacheDir, "userdata.txt"); + using (var streamWriter = new System.IO.StreamWriter(file.AbsolutePath, false)) + { + streamWriter.WriteLine(TotalKills.ToString()); + streamWriter.WriteLine(TotalMoneySpent.ToString()); + streamWriter.WriteLine(GamesPlayed.ToString()); + streamWriter.WriteLine(HighestRound.ToString()); + streamWriter.WriteLine(HighestKills.ToString()); + } + } + + public static void ReadData(Context context) + { + File file = new File(context.CacheDir, "userdata.txt"); + + if (!file.Exists()) + WriteData(context); + + using (var streamReader = new System.IO.StreamReader(file.AbsolutePath, true)) + { + var lines = streamReader.ReadToEnd().Split(new string[] { "\n" }, StringSplitOptions.None); + + TotalKills = int.Parse(lines[0]); + TotalMoneySpent = int.Parse(lines[1]); + GamesPlayed = int.Parse(lines[2]); + HighestRound = int.Parse(lines[3]); + HighestKills = int.Parse(lines[4]); + } + } + } +} \ No newline at end of file -- cgit v1.2.3-70-g09d2