diff options
| author | aldrikboy <aldrikboy@gmail.com> | 2017-12-25 14:07:42 +0100 |
|---|---|---|
| committer | aldrikboy <aldrikboy@gmail.com> | 2017-12-25 14:07:42 +0100 |
| commit | 020fd61af37eaaac81d7b930be15f8c350f28b7d (patch) | |
| tree | 213e59cc8a7b60c717a0ea05159ac8967e6f5c35 /Penguloon | |
| parent | 3281eed3ffca3b4488335846430b231001aea753 (diff) | |
I dab everyday
Diffstat (limited to 'Penguloon')
22 files changed, 264 insertions, 38 deletions
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 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +This file contains an xml description of a font, and will be read by the XNA +Framework Content Pipeline. Follow the comments to customize the appearance +of the font in your game, and to change the characters which are available to draw +with. +--> +<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics"> + <Asset Type="Graphics:FontDescription"> + + <!-- + Modify this string to change the font that will be imported. + --> + <FontName>GWENT.ttf</FontName> + + <!-- + Size is a float value, measured in points. Modify this value to change + the size of the font. + --> + <Size>52</Size> + + <!-- + Spacing is a float value, measured in pixels. Modify this value to change + the amount of spacing in between characters. + --> + <Spacing>0</Spacing> + + <!-- + UseKerning controls the layout of the font. If this value is true, kerning information + will be used when placing characters. + --> + <UseKerning>true</UseKerning> + + <!-- + Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic", + and "Bold, Italic", and are case sensitive. + --> + <Style>Regular</Style> + + <!-- + If you uncomment this line, the default character will be substituted if you draw + or measure text that contains characters which were not included in the font. + --> + <!-- <DefaultCharacter>*</DefaultCharacter> --> + + <!-- + CharacterRegions control what letters are available in the font. Every + character from Start to End will be built and made available for drawing. The + default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin + character set. The characters are ordered according to the Unicode standard. + See the documentation for more information. + --> + <CharacterRegions> + <CharacterRegion> + <Start> </Start> + <End>~</End> + </CharacterRegion> + </CharacterRegions> + </Asset> +</XnaContent> diff --git a/Penguloon/Content/UI/msgBoxBackground.png b/Penguloon/Content/UI/msgBoxBackground.png Binary files differindex 3516ae8..87e161f 100644 --- a/Penguloon/Content/UI/msgBoxBackground.png +++ b/Penguloon/Content/UI/msgBoxBackground.png diff --git a/Penguloon/Content/UI/optionsMenuBackground.png b/Penguloon/Content/UI/optionsMenuBackground.png Binary files differindex 2eb62bd..ca9e16d 100644 --- a/Penguloon/Content/UI/optionsMenuBackground.png +++ b/Penguloon/Content/UI/optionsMenuBackground.png 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 @@ <Compile Include="Scenes\LoadingScene.cs" /> <Compile Include="Scenes\MenuScene.cs" /> <Compile Include="Scenes\SceneBase.cs" /> + <Compile Include="Scenes\StatsScene.cs" /> <Compile Include="SoundManager.cs" /> <Compile Include="StaticUIValues.cs" /> + <Compile Include="UserdataManager.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> <None Include="Assets\AboutAssets.txt" /> </ItemGroup> <ItemGroup> - <AndroidResource Include="Resources\Values\Strings.xml" /> + <AndroidResource Include="Resources\Values\Strings.xml"> + <SubType>Designer</SubType> + </AndroidResource> </ItemGroup> <ItemGroup> <AndroidResource Include="Resources\Drawable\Icon.png" /> 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 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Penguloon.Penguloon" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"> <uses-sdk android:targetSdkVersion="19" android:minSdkVersion="19" /> - <application android:label="Penguloon"></application> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <application android:label="Penguloon" android:icon="@drawable/Splash"></application> </manifest>
\ 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 @@ <!-- menu --> <string name="MenuBtnPlay">Play</string> - + <string name="MenuBtnStats">Stats</string> + <!-- level selection --> <string name="LevelSelectionBack">Back</string> 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; } + /// <summary> /// Initialize scene manager. /// </summary> @@ -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 |
