diff options
| author | aldrikboy <aldrikboy@gmail.com> | 2017-12-11 22:02:13 +0100 |
|---|---|---|
| committer | aldrikboy <aldrikboy@gmail.com> | 2017-12-11 22:02:13 +0100 |
| commit | fd6fa4e5cebbe3edb65d50c78dcc8a97ce98ce64 (patch) | |
| tree | 8950f6b9023e0b47e22e1cd4869ab76de0803f4c | |
| parent | c4c0f3c887d627b6432551e96009c7aeecd4cdd8 (diff) | |
First commit
62 files changed, 2274 insertions, 78 deletions
diff --git a/Penguloon/Activity1.cs b/Penguloon/Activity.cs index ac9aa1e..bb5a3d4 100644 --- a/Penguloon/Activity1.cs +++ b/Penguloon/Activity.cs @@ -11,14 +11,14 @@ namespace Penguloon , Theme = "@style/Theme.Splash" , AlwaysRetainTaskState = true , LaunchMode = Android.Content.PM.LaunchMode.SingleInstance - , ScreenOrientation = ScreenOrientation.FullUser + , ScreenOrientation = ScreenOrientation.Landscape , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)] - public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity + public class Activity : Microsoft.Xna.Framework.AndroidGameActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); - var g = new Game1(); + var g = new Main(Resources); SetContentView((View)g.Services.GetService(typeof(View))); g.Run(); } diff --git a/Penguloon/Content/Bullets/cannon-ammo.png b/Penguloon/Content/Bullets/cannon-ammo.png Binary files differnew file mode 100644 index 0000000..93df390 --- /dev/null +++ b/Penguloon/Content/Bullets/cannon-ammo.png diff --git a/Penguloon/Content/Bullets/penguin-ammo.png b/Penguloon/Content/Bullets/penguin-ammo.png Binary files differnew file mode 100644 index 0000000..5227b4c --- /dev/null +++ b/Penguloon/Content/Bullets/penguin-ammo.png diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index 895694b..a47b8e8 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -13,3 +13,396 @@ #---------------------------------- Content ---------------------------------# +#begin Tiles/ice.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:Tiles/ice.png + +#begin Tiles/waterCornerLeftDown.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:Tiles/waterCornerLeftDown.png + +#begin Tiles/waterCornerLeftTop.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:Tiles/waterCornerLeftTop.png + +#begin Tiles/waterCornerRightDown.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:Tiles/waterCornerRightDown.png + +#begin Tiles/waterCornerRightTop.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:Tiles/waterCornerRightTop.png + +#begin Tiles/waterHorizontal.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:Tiles/waterHorizontal.png + +#begin Tiles/waterVertical.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:Tiles/waterVertical.png + +#begin Objects/cannon.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:Objects/cannon.png + +#begin Objects/penguin1.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:Objects/penguin1.png + +#begin Objects/penguin2.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:Objects/penguin2.png + +#begin Bullets/cannon-ammo.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:Bullets/cannon-ammo.png + +#begin Bullets/penguin-ammo.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:Bullets/penguin-ammo.png + +#begin UI/btnDisabled.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:UI/btnDisabled.png + +#begin UI/btnIdle.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:UI/btnIdle.png + +#begin UI/btnPressed.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:UI/btnPressed.png + +#begin Fonts/GWENT/GWENT.ttf +/copy:Fonts/GWENT/GWENT.ttf + +#begin Fonts/GWENT/36.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/36.spritefont + +#begin Fonts/GWENT/72.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/72.spritefont + +#begin Fonts/GWENT/24.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/24.spritefont + +#begin Fonts/GWENT/16.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/16.spritefont + +#begin Fonts/GWENT/128.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/128.spritefont + +#begin UI/progressbar.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:UI/progressbar.png + +#begin UI/red.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:UI/red.png + +#begin Enemies/blue.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:Enemies/blue.png + +#begin Enemies/green.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:Enemies/green.png + +#begin Enemies/orange.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:Enemies/orange.png + +#begin Enemies/purple.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:Enemies/purple.png + +#begin Enemies/rainbow.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:Enemies/rainbow.png + +#begin Enemies/rainbow_dark.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:Enemies/rainbow_dark.png + +#begin Enemies/red.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:Enemies/red.png + +#begin Enemies/yellow.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:Enemies/yellow.png + +#begin UI/background.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:UI/background.png + +#begin UI/snowflake.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:UI/snowflake.png + +#begin Sounds/baseline.wav +/importer:WavImporter +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Sounds/baseline.wav + +#begin Sounds/click.wav +/importer:WavImporter +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Sounds/click.wav + +#begin Fonts/GWENT/48.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/GWENT/48.spritefont + +#begin SplashArt/1.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:SplashArt/1.png + diff --git a/Penguloon/Content/Enemies/blue.png b/Penguloon/Content/Enemies/blue.png Binary files differnew file mode 100644 index 0000000..f528424 --- /dev/null +++ b/Penguloon/Content/Enemies/blue.png diff --git a/Penguloon/Content/Enemies/green.png b/Penguloon/Content/Enemies/green.png Binary files differnew file mode 100644 index 0000000..6074e80 --- /dev/null +++ b/Penguloon/Content/Enemies/green.png diff --git a/Penguloon/Content/Enemies/orange.png b/Penguloon/Content/Enemies/orange.png Binary files differnew file mode 100644 index 0000000..44211c7 --- /dev/null +++ b/Penguloon/Content/Enemies/orange.png diff --git a/Penguloon/Content/Enemies/purple.png b/Penguloon/Content/Enemies/purple.png Binary files differnew file mode 100644 index 0000000..bb00460 --- /dev/null +++ b/Penguloon/Content/Enemies/purple.png diff --git a/Penguloon/Content/Enemies/rainbow.png b/Penguloon/Content/Enemies/rainbow.png Binary files differnew file mode 100644 index 0000000..ecf93f0 --- /dev/null +++ b/Penguloon/Content/Enemies/rainbow.png diff --git a/Penguloon/Content/Enemies/rainbow_dark.png b/Penguloon/Content/Enemies/rainbow_dark.png Binary files differnew file mode 100644 index 0000000..acee5b2 --- /dev/null +++ b/Penguloon/Content/Enemies/rainbow_dark.png diff --git a/Penguloon/Content/Enemies/red.png b/Penguloon/Content/Enemies/red.png Binary files differnew file mode 100644 index 0000000..ac0bb1f --- /dev/null +++ b/Penguloon/Content/Enemies/red.png diff --git a/Penguloon/Content/Enemies/yellow.png b/Penguloon/Content/Enemies/yellow.png Binary files differnew file mode 100644 index 0000000..dc4fc03 --- /dev/null +++ b/Penguloon/Content/Enemies/yellow.png diff --git a/Penguloon/Content/Fonts/GWENT/128.spritefont b/Penguloon/Content/Fonts/GWENT/128.spritefont new file mode 100644 index 0000000..2a32972 --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/128.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>128</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/Fonts/GWENT/16.spritefont b/Penguloon/Content/Fonts/GWENT/16.spritefont new file mode 100644 index 0000000..fedd403 --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/16.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>16</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/Fonts/GWENT/24.spritefont b/Penguloon/Content/Fonts/GWENT/24.spritefont new file mode 100644 index 0000000..faf835c --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/24.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>24</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/Fonts/GWENT/36.spritefont b/Penguloon/Content/Fonts/GWENT/36.spritefont new file mode 100644 index 0000000..f6268f3 --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/36.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>36</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/Fonts/GWENT/48.spritefont b/Penguloon/Content/Fonts/GWENT/48.spritefont new file mode 100644 index 0000000..04f942a --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/48.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>48</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/Fonts/GWENT/72.spritefont b/Penguloon/Content/Fonts/GWENT/72.spritefont new file mode 100644 index 0000000..41a8c17 --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/72.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>72</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/Fonts/GWENT/GWENT.ttf b/Penguloon/Content/Fonts/GWENT/GWENT.ttf Binary files differnew file mode 100644 index 0000000..639d955 --- /dev/null +++ b/Penguloon/Content/Fonts/GWENT/GWENT.ttf diff --git a/Penguloon/Content/Objects/cannon.png b/Penguloon/Content/Objects/cannon.png Binary files differnew file mode 100644 index 0000000..cb25c49 --- /dev/null +++ b/Penguloon/Content/Objects/cannon.png diff --git a/Penguloon/Content/Objects/penguin1.png b/Penguloon/Content/Objects/penguin1.png Binary files differnew file mode 100644 index 0000000..e7ee2c3 --- /dev/null +++ b/Penguloon/Content/Objects/penguin1.png diff --git a/Penguloon/Content/Objects/penguin2.png b/Penguloon/Content/Objects/penguin2.png Binary files differnew file mode 100644 index 0000000..7c2afec --- /dev/null +++ b/Penguloon/Content/Objects/penguin2.png diff --git a/Penguloon/Content/Sounds/baseline.wav b/Penguloon/Content/Sounds/baseline.wav Binary files differnew file mode 100644 index 0000000..0e8eeb0 --- /dev/null +++ b/Penguloon/Content/Sounds/baseline.wav diff --git a/Penguloon/Content/Sounds/click.wav b/Penguloon/Content/Sounds/click.wav Binary files differnew file mode 100644 index 0000000..3364b09 --- /dev/null +++ b/Penguloon/Content/Sounds/click.wav diff --git a/Penguloon/Content/SplashArt/1.png b/Penguloon/Content/SplashArt/1.png Binary files differnew file mode 100644 index 0000000..4091ca6 --- /dev/null +++ b/Penguloon/Content/SplashArt/1.png diff --git a/Penguloon/Content/Tiles/ice.png b/Penguloon/Content/Tiles/ice.png Binary files differnew file mode 100644 index 0000000..b4ba6d8 --- /dev/null +++ b/Penguloon/Content/Tiles/ice.png diff --git a/Penguloon/Content/Tiles/waterCornerLeftDown.png b/Penguloon/Content/Tiles/waterCornerLeftDown.png Binary files differnew file mode 100644 index 0000000..31c1fea --- /dev/null +++ b/Penguloon/Content/Tiles/waterCornerLeftDown.png diff --git a/Penguloon/Content/Tiles/waterCornerLeftTop.png b/Penguloon/Content/Tiles/waterCornerLeftTop.png Binary files differnew file mode 100644 index 0000000..980b0e6 --- /dev/null +++ b/Penguloon/Content/Tiles/waterCornerLeftTop.png diff --git a/Penguloon/Content/Tiles/waterCornerRightDown.png b/Penguloon/Content/Tiles/waterCornerRightDown.png Binary files differnew file mode 100644 index 0000000..a28e63a --- /dev/null +++ b/Penguloon/Content/Tiles/waterCornerRightDown.png diff --git a/Penguloon/Content/Tiles/waterCornerRightTop.png b/Penguloon/Content/Tiles/waterCornerRightTop.png Binary files differnew file mode 100644 index 0000000..7f44d4a --- /dev/null +++ b/Penguloon/Content/Tiles/waterCornerRightTop.png diff --git a/Penguloon/Content/Tiles/waterHorizontal.png b/Penguloon/Content/Tiles/waterHorizontal.png Binary files differnew file mode 100644 index 0000000..881e133 --- /dev/null +++ b/Penguloon/Content/Tiles/waterHorizontal.png diff --git a/Penguloon/Content/Tiles/waterVertical.png b/Penguloon/Content/Tiles/waterVertical.png Binary files differnew file mode 100644 index 0000000..8c2cee2 --- /dev/null +++ b/Penguloon/Content/Tiles/waterVertical.png diff --git a/Penguloon/Content/UI/background.png b/Penguloon/Content/UI/background.png Binary files differnew file mode 100644 index 0000000..00a8558 --- /dev/null +++ b/Penguloon/Content/UI/background.png diff --git a/Penguloon/Content/UI/btnDisabled.png b/Penguloon/Content/UI/btnDisabled.png Binary files differnew file mode 100644 index 0000000..1a0bbfd --- /dev/null +++ b/Penguloon/Content/UI/btnDisabled.png diff --git a/Penguloon/Content/UI/btnIdle.png b/Penguloon/Content/UI/btnIdle.png Binary files differnew file mode 100644 index 0000000..f536b99 --- /dev/null +++ b/Penguloon/Content/UI/btnIdle.png diff --git a/Penguloon/Content/UI/btnPressed.png b/Penguloon/Content/UI/btnPressed.png Binary files differnew file mode 100644 index 0000000..b7dfe7d --- /dev/null +++ b/Penguloon/Content/UI/btnPressed.png diff --git a/Penguloon/Content/UI/progressbar.png b/Penguloon/Content/UI/progressbar.png Binary files differnew file mode 100644 index 0000000..32266ff --- /dev/null +++ b/Penguloon/Content/UI/progressbar.png diff --git a/Penguloon/Content/UI/red.png b/Penguloon/Content/UI/red.png Binary files differnew file mode 100644 index 0000000..b1fcae6 --- /dev/null +++ b/Penguloon/Content/UI/red.png diff --git a/Penguloon/Content/UI/snowflake.png b/Penguloon/Content/UI/snowflake.png Binary files differnew file mode 100644 index 0000000..7064643 --- /dev/null +++ b/Penguloon/Content/UI/snowflake.png diff --git a/Penguloon/ContentManager.cs b/Penguloon/ContentManager.cs new file mode 100644 index 0000000..ad34ac3 --- /dev/null +++ b/Penguloon/ContentManager.cs @@ -0,0 +1,157 @@ +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using System.Threading; +using Microsoft.Xna.Framework.Audio; + +namespace Penguloon +{ + public static class ContentManager + { + private static Dictionary<string, Texture2D> TextureDictionary { get; set; } = new Dictionary<string, Texture2D>(); + private static Dictionary<string, SpriteFont> FontDictionary { get; set; } = new Dictionary<string, SpriteFont>(); + private static Dictionary<string, SoundEffect> SoundDictionary { get; set; } = new Dictionary<string, SoundEffect>(); + + public static int LoadPercentage { get; set; } = 0; + public static float LoadPercentageF { get; set; } = 0; + + public static bool DoneLoading { get; set; } + public static bool DonePreLoading { get; set; } + + public static void LoadContent(Main main) + { + new Thread(() => + { + Thread.CurrentThread.IsBackground = true; + + PreLoadContent(main); + + LoadContent_(main); + + }).Start(); + } + + private static void LoadContent_(Main main) + { + float totalItemsToLoad = ContentPathManager.TexturePaths.Count + ContentPathManager.FontPaths.Count + ContentPathManager.SoundPaths.Count; + float itemsLoaded = 0; + + for (int i = 0; i < ContentPathManager.SoundPaths.Count; i++) + { + SoundEffect ef = main.Content.Load<SoundEffect>(ContentPathManager.SoundPaths[i]); + SoundDictionary.Add(ContentPathManager.SoundPaths[i], ef); + + LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); + LoadPercentageF = (itemsLoaded / totalItemsToLoad); + + Thread.Sleep(25); + } + + for (int i = 0; i < ContentPathManager.TexturePaths.Count; i++) + { + TextureDictionary.Add(ContentPathManager.TexturePaths[i], main.Content.Load<Texture2D>(ContentPathManager.TexturePaths[i])); + itemsLoaded++; + + LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); + LoadPercentageF = (itemsLoaded / totalItemsToLoad); + + Thread.Sleep(25); + } + + for (int i = 0; i < ContentPathManager.FontPaths.Count; i++) + { + FontDictionary.Add(ContentPathManager.FontPaths[i], main.Content.Load<SpriteFont>(ContentPathManager.FontPaths[i])); + itemsLoaded++; + + LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); + LoadPercentageF = (itemsLoaded / totalItemsToLoad); + + Thread.Sleep(25); + } + + DoneLoading = true; + } + + private static void PreLoadContent(Main main) + { + for (int i = 0; i < ContentPathManager.SoundPathsPreLoad.Count; i++) + { + SoundEffect ef = main.Content.Load<SoundEffect>(ContentPathManager.SoundPathsPreLoad[i]); + SoundDictionary.Add(ContentPathManager.SoundPathsPreLoad[i], ef); + } + + for (int i = 0; i < ContentPathManager.TexturePathsPreLoad.Count; i++) + { + TextureDictionary.Add(ContentPathManager.TexturePathsPreLoad[i], + main.Content.Load<Texture2D>(ContentPathManager.TexturePathsPreLoad[i])); + } + + for (int i = 0; i < ContentPathManager.FontPathsPreLoad.Count; i++) + { + FontDictionary.Add(ContentPathManager.FontPathsPreLoad[i], + main.Content.Load<SpriteFont>(ContentPathManager.FontPathsPreLoad[i])); + } + + DonePreLoading = true; + } + + public static Texture2D GetTexture(string name) + { + if (TextureDictionary.ContainsKey(name)) + return TextureDictionary[name]; + + return null; + } + + public static SoundEffect GetSound(string name) + { + if (SoundDictionary.ContainsKey(name)) + return SoundDictionary[name]; + + return null; + } + + public static SpriteFont GetFont(string name) + { + if (FontDictionary.ContainsKey(name)) + return FontDictionary[name]; + + return null; + } + + public static Texture2D GetTileTextureByType(int type) + { + switch (type) + { + case 0: + return GetTexture("Tiles/ice"); + case 1: + return GetTexture("Tiles/waterCornerLeftDown"); + case 2: + return GetTexture("Tiles/waterCornerLeftTop"); + case 3: + return GetTexture("Tiles/waterCornerRightDown"); + case 4: + return GetTexture("Tiles/waterCornerRightTop"); + case 5: + return GetTexture("Tiles/waterHorizontal"); + case 6: + return GetTexture("Tiles/waterVertical"); + } + + return null; + } + + public static void DisposeContent() + { + foreach (var entry in TextureDictionary) + entry.Value.Dispose(); + + foreach (var entry in SoundDictionary) + entry.Value.Dispose(); + + SoundDictionary.Clear(); + FontDictionary.Clear(); + TextureDictionary.Clear(); + } + } +}
\ No newline at end of file diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs new file mode 100644 index 0000000..abe5bc3 --- /dev/null +++ b/Penguloon/ContentPathManager.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; + +namespace Penguloon +{ + public static class ContentPathManager + { + public static List<string> TexturePaths { get; set; } = new List<string>() + { + "Bullets/cannon-ammo", + "Bullets/penguin-ammo", + + "Objects/cannon", + "Objects/penguin1", + "Objects/penguin2", + + "Tiles/ice", + "Tiles/waterCornerLeftDown", + "Tiles/waterCornerLeftTop", + "Tiles/waterCornerRightDown", + "Tiles/waterCornerRightTop", + "Tiles/waterHorizontal", + "Tiles/waterVertical", + + "UI/btnDisabled", + "UI/btnIdle", + "UI/btnPressed", + + "SplashArt/1", + + "Enemies/red", + "Enemies/blue", + "Enemies/yellow", + "Enemies/green", + "Enemies/orange", + "Enemies/purple", + "Enemies/rainbow", + "Enemies/rainbow_dark", + }; + + public static List<string> FontPaths { get; set; } = new List<string>() + { + "Fonts/GWENT/16", + "Fonts/GWENT/24", + "Fonts/GWENT/36", + "Fonts/GWENT/48", + "Fonts/GWENT/72", + }; + + public static List<string> SoundPaths { get; set; } = new List<string>() + { + "Sounds/click", + }; + + public static List<string> TexturePathsPreLoad { get; set; } = new List<string>() + { + "UI/progressbar", + "UI/red", + "UI/snowflake", + "UI/background", + }; + + public static List<string> FontPathsPreLoad { get; set; } = new List<string>() + { + "Fonts/GWENT/128", + }; + + public static List<string> SoundPathsPreLoad { get; set; } = new List<string>() + { + "Sounds/baseline", + }; + } +}
\ No newline at end of file diff --git a/Penguloon/Controls/Button.cs b/Penguloon/Controls/Button.cs new file mode 100644 index 0000000..121321c --- /dev/null +++ b/Penguloon/Controls/Button.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + class Button : ControlBase + { + public Button(SceneBase parentScene, Vector2 position, Vector2 size, string text) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/btnIdle"); + this.BackgroundPressed = ContentManager.GetTexture("UI/btnPressed"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/btnDisabled"); + this.Text = text; + + this.ForeColor = Color.Gray; + this.BorderColor = Color.Gray; + this.BorderWidth = 0; + this.Font = ContentManager.GetFont(StaticUIValues.MenuFont); + + OnClick += Button_OnClick; + } + + private void Button_OnClick(object sender, ClickArgs e) + { + SoundManager.PlayClickSound(); + } + } +}
\ No newline at end of file diff --git a/Penguloon/Controls/ControlBase.cs b/Penguloon/Controls/ControlBase.cs new file mode 100644 index 0000000..dea0bd7 --- /dev/null +++ b/Penguloon/Controls/ControlBase.cs @@ -0,0 +1,134 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public abstract class ControlBase + { + public SceneBase ParentScene { get; set; } + + public ControlState ControlState { get; set; } = ControlState.Idle; + + public string Text { get; set; } + public SpriteFont Font { get; set; } + public Vector2 Position { get; set; } + public Vector2 Size { get; set; } + public Color ForeColor { get; set; } + public Color BorderColor { get; set; } + public int BorderWidth { get; set; } + + public Texture2D BackgroundIdle { get; set; } + public Texture2D BackgroundPressed { get; set; } + public Texture2D BackgroundDisabled { get; set; } + + public event EventHandler<ClickArgs> OnClick; + public event EventHandler<MoveArgs> OnMove; + + /// <summary> + /// Base constructor. + /// </summary> + /// <param name="main">Active Main object.</param> + /// <param name="position">Control position.</param> + /// <param name="size">Control size.</param> + protected ControlBase(SceneBase parentScene, Vector2 position, Vector2 size) + { + this.ParentScene = parentScene; + this.Position = position; + this.Size = size; + } + + /// <summary> + /// Draw controls. + /// </summary> + /// <param name="deltaTime">Delta time.</param> + public virtual void Draw(float deltaTime) + { + switch (ControlState) + { + case ControlState.Idle: + if(BackgroundIdle != null) + ParentScene.Main.SpriteBatch.Draw(BackgroundIdle, + destinationRectangle: new Rectangle(Position.ToPoint(), Size.ToPoint())); break; + case ControlState.Pressed: + if (BackgroundPressed != null) + ParentScene.Main.SpriteBatch.Draw(BackgroundPressed, + destinationRectangle: new Rectangle(Position.ToPoint(), Size.ToPoint())); break; + case ControlState.Disabled: + if (BackgroundDisabled != null) + ParentScene.Main.SpriteBatch.Draw(BackgroundDisabled, + destinationRectangle: new Rectangle(Position.ToPoint(), Size.ToPoint())); break; + } + + if (Font == null) return; + if (string.IsNullOrWhiteSpace(Text)) return; + + ParentScene.DrawText(Font, Text, Position, Size, TextAllignment.CenterMiddle, ForeColor, BorderColor, BorderWidth); + } + + /// <summary> + /// Update control. + /// </summary> + /// <param name="deltaTime">Delta time.</param> + /// <param name="touchLocations">Finger touch points.</param> + public virtual void Update(float deltaTime, TouchLocation[] touchLocations) + { + if (ControlState == ControlState.Disabled) return; + + Rectangle controlRec = new Rectangle(Position.ToPoint(), Size.ToPoint()); + + for(int i = 0; i < touchLocations.Length; i++) + { + Rectangle touchRec = new Rectangle(touchLocations[i].Position.ToPoint(), new Point(1, 1)); + + if (touchRec.Intersects(controlRec)) + { + if (touchLocations[i].State == TouchLocationState.Released) + { + this.ControlState = ControlState.Idle; + OnClick?.Invoke(this, new ClickArgs(touchLocations[i].Position)); + } + + if (touchLocations[i].State == TouchLocationState.Pressed) + { + this.ControlState = ControlState.Pressed; + } + + if (touchLocations[i].State == TouchLocationState.Moved) + { + touchLocations[i].TryGetPreviousLocation(out TouchLocation touch); + OnMove?.Invoke(this, new MoveArgs(touchLocations[i].Position, touch.Position)); + } + + return; + } + else + this.ControlState = ControlState.Idle; + } + } + } + + public class ClickArgs : EventArgs + { + public Vector2 ClickPosition { get; set; } + + public ClickArgs(Vector2 clickPosition) + { + this.ClickPosition = clickPosition; + } + } + + public class MoveArgs : EventArgs + { + public Vector2 TouchPosition { get; set; } + public Vector2 PrevTouchPosition { get; set; } + + public MoveArgs(Vector2 touchPosition, Vector2 prevTouchPosition) + { + TouchPosition = touchPosition; + PrevTouchPosition = prevTouchPosition; + } + } +}
\ No newline at end of file diff --git a/Penguloon/Controls/LevelSelector.cs b/Penguloon/Controls/LevelSelector.cs new file mode 100644 index 0000000..1e26fcc --- /dev/null +++ b/Penguloon/Controls/LevelSelector.cs @@ -0,0 +1,101 @@ +using Penguloon.Scenes; +using Microsoft.Xna.Framework; +using System; +using System.Collections.Generic; +using Penguloon.Levels; +using Microsoft.Xna.Framework.Input.Touch; + +namespace Penguloon.Controls +{ + class LevelSelector : ControlBase + { + public int PanelWidth { get; set; } + public const int PanelMarginX = 30; + public const int MaxPanels = 3; + + int selectedMap = 0; + + public List<LevelBase> Levels { get; set; } = new List<LevelBase>(); + + public Rectangle Panel1 { get; set; } + public Rectangle Panel2 { get; set; } + public Rectangle Panel3 { get; set; } + + public LevelSelector(SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/btnIdle"); + this.BackgroundPressed = ContentManager.GetTexture("UI/btnIdle"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/btnIdle"); + + PanelWidth = (int)(StaticUIValues.ScreenViewport.X - ((MaxPanels + 1) * PanelMarginX)) / MaxPanels; + + int panel1posX = PanelMarginX + (PanelMarginX * 0) + (PanelWidth * 0); + int panel2posX = PanelMarginX + (PanelMarginX * 1) + (PanelWidth * 1); + int panel3posX = PanelMarginX + (PanelMarginX * 2) + (PanelWidth * 2); + + int sidePanelMarginY = 25; + + Panel1 = new Rectangle(panel1posX, (int)position.Y + (sidePanelMarginY / 2), PanelWidth, (int)size.Y - sidePanelMarginY); + Panel2 = new Rectangle(panel2posX, (int)position.Y, PanelWidth, (int)size.Y); + Panel3 = new Rectangle(panel3posX, (int)position.Y + (sidePanelMarginY / 2), PanelWidth, (int)size.Y - sidePanelMarginY); + + this.OnClick += LevelSelector_OnClick; + + CreateLevels(); + } + + private void LevelSelector_OnClick(object sender, ClickArgs e) + { + Rectangle fingerRec = new Rectangle(e.ClickPosition.ToPoint(), new Point(1, 1)); + + if (Panel1.Intersects(fingerRec) && selectedMap > 0) + { + selectedMap--; + } + + if (Panel2.Intersects(fingerRec)) + { + SceneManager.GameScene = new GameScene(ParentScene.Main, Levels[selectedMap]); + SceneManager.SelectedScene = SelectedScene.Ingame; + } + + if (Panel3.Intersects(fingerRec) && selectedMap < Levels.Count - 1) + { + selectedMap++; + } + } + + private void CreateLevels() + { + Levels.Add(new IceLevel()); + //Levels.Add(new IceLevel()); + //Levels.Add(new IceLevel()); + } + + public override void Draw(float deltaTime) + { + // We dont need to draw text or a background + //base.Draw(deltaTime); + + DrawPanels(); + } + + private void DrawPanels() + { + if (selectedMap - 1 >= 0) + { + ParentScene.Main.SpriteBatch.Draw(Levels[selectedMap - 1].SplashArt, + destinationRectangle: Panel1); + } + + ParentScene.Main.SpriteBatch.Draw(Levels[selectedMap].SplashArt, + destinationRectangle: Panel2); + + if (selectedMap + 1 < Levels.Count) + { + ParentScene.Main.SpriteBatch.Draw(Levels[selectedMap + 1].SplashArt, + destinationRectangle: Panel3); + } + } + } +}
\ No newline at end of file diff --git a/Penguloon/Enums.cs b/Penguloon/Enums.cs new file mode 100644 index 0000000..bc2fa6d --- /dev/null +++ b/Penguloon/Enums.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; + +namespace Penguloon +{ + public enum SelectedScene + { + Menu, + Ingame, + Loading, + LevelSelection + } + + public enum ControlState + { + Idle, + Pressed, + Disabled + } + + public enum TextAllignment + { + LeftTop, + CenterTop, + RightTop, + + LeftMiddle, + CenterMiddle, + RightMiddle, + + LeftBottom, + CenterBottom, + RightBottom, + } + + public enum Direction + { + Up, + Down, + Left, + Right, + None, + Finish + } +}
\ No newline at end of file diff --git a/Penguloon/Levels/IceLevel.cs b/Penguloon/Levels/IceLevel.cs new file mode 100644 index 0000000..984a07f --- /dev/null +++ b/Penguloon/Levels/IceLevel.cs @@ -0,0 +1,47 @@ +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Scenes; + +namespace Penguloon.Levels +{ + public class IceLevel : LevelBase + { + public IceLevel() : base() + { + this.SplashArt = ContentManager.GetTexture("SplashArt/1"); + } + + public override void DrawUnique(float deltaTime) + { + base.DrawUnique(deltaTime); + } + + public override void UpdateUnique(float deltaTime, TouchLocation[] touchLocations) + { + base.UpdateUnique(deltaTime, touchLocations); + } + + public override void CreateMap() + { + Map = new Map(ParentScene); + + Tile OO = new Tile(0, Direction.None); + Tile DN = new Tile(6, Direction.Down); + + Map.TileMap = new Tile[12, 18] + { + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,DN,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + { OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, + }; + } + } +}
\ No newline at end of file diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs new file mode 100644 index 0000000..de17caf --- /dev/null +++ b/Penguloon/Levels/LevelBase.cs @@ -0,0 +1,52 @@ +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Scenes; + +namespace Penguloon.Levels +{ + public abstract class LevelBase + { + public SceneBase ParentScene { get; set; } + + public Texture2D SplashArt { get; set; } + + public Map Map { get; set; } + + public LevelBase() + { + + } + + public abstract void CreateMap(); + + public virtual void Initialize(SceneBase sceneBase) + { + this.ParentScene = sceneBase; + CreateMap(); + } + + public void Draw(float deltaTime) + { + Map.Draw(deltaTime); + + DrawUnique(deltaTime); + } + + public void Update(float deltaTime, TouchLocation[] touchLocations) + { + Map.Update(deltaTime); + + UpdateUnique(deltaTime, touchLocations); + } + + public virtual void DrawUnique(float deltaTime) + { + + } + + public virtual void UpdateUnique(float deltaTime, TouchLocation[] touchLocations) + { + + } + } +}
\ No newline at end of file diff --git a/Penguloon/Levels/Map.cs b/Penguloon/Levels/Map.cs new file mode 100644 index 0000000..384d011 --- /dev/null +++ b/Penguloon/Levels/Map.cs @@ -0,0 +1,63 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Penguloon.Scenes; + +namespace Penguloon.Levels +{ + public class Map + { + // 18 x 12 + public Tile[,] TileMap { get; set; } + + public int MapWidth { get; private set; } + public int MapHeight { get; private set; } + + public int TileWidth { get; private set; } + public int TileHeight { get; private set; } + + public SceneBase ParentScene { get; set; } + + public Map(SceneBase parentScene) + { + this.ParentScene = parentScene; + + MapWidth = (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth; + MapHeight = (int)StaticUIValues.ScreenViewport.Y; + + TileWidth = MapWidth / 18; + TileHeight = MapHeight / 12; + } + + public void Draw(float deltaTime) + { + for(int y = 0; y < TileMap.GetLength(0); y++) + { + for (int x = 0; x < TileMap.GetLength(1); x++) + { + Texture2D tileTexture = ContentManager.GetTileTextureByType(TileMap[y, x].Type); + + ParentScene.Main.SpriteBatch.Draw(tileTexture, + destinationRectangle: new Rectangle(x * TileWidth, y * TileHeight, TileWidth, TileHeight)); + } + } + } + + public void Update(float deltaTime) + { + + } + } + + public class Tile + { + public int Type { get; set; } + + public Direction Direction { get; set; } + + public Tile(int type, Direction direction) + { + this.Type = type; + this.Direction = direction; + } + } +}
\ No newline at end of file diff --git a/Penguloon/Game1.cs b/Penguloon/Main.cs index b77d9c4..b2844fc 100644 --- a/Penguloon/Game1.cs +++ b/Penguloon/Main.cs @@ -1,26 +1,48 @@ +using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Input.Touch; + +using Android.Content.Res; namespace Penguloon { /// <summary> /// This is the main type for your game. /// </summary> - public class Game1 : Game + public class Main : Game { - GraphicsDeviceManager graphics; - SpriteBatch spriteBatch; + private GraphicsDeviceManager _graphics; + private SpriteBatch _spriteBatch; + private Resources _resources; + + public GraphicsDeviceManager Graphics + { + get => _graphics; + set => _graphics = value; + } - public Game1() + public SpriteBatch SpriteBatch { - graphics = new GraphicsDeviceManager(this); + get => _spriteBatch; + set => _spriteBatch = value; + } + + public Resources Resources + { + get => _resources; + set => _resources = value; + } + + public Main(Resources resources) + { + Resources = resources; + Graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; - graphics.IsFullScreen = true; - graphics.PreferredBackBufferWidth = 800; - graphics.PreferredBackBufferHeight = 480; - graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; + Graphics.IsFullScreen = true; + Graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; } /// <summary> @@ -31,7 +53,8 @@ namespace Penguloon /// </summary> protected override void Initialize() { - // TODO: Add your initialization logic here + SceneManager.Initialize(this); + StaticUIValues.Initialize(this); base.Initialize(); } @@ -43,7 +66,9 @@ namespace Penguloon protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. - spriteBatch = new SpriteBatch(GraphicsDevice); + SpriteBatch = new SpriteBatch(GraphicsDevice); + + ContentManager.LoadContent(this); // TODO: use this.Content to load your game content here } @@ -55,6 +80,7 @@ namespace Penguloon protected override void UnloadContent() { // TODO: Unload any non ContentManager content here + ContentManager.DisposeContent(); } /// <summary> @@ -64,10 +90,11 @@ namespace Penguloon /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { - if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) - Exit(); + var delta = (float)gameTime.ElapsedGameTime.TotalSeconds; + + TouchLocation[] touchLocations = TouchPanel.GetState().ToArray(); - // TODO: Add your update logic here + SceneManager.Update(delta, touchLocations); base.Update(gameTime); } @@ -78,9 +105,15 @@ namespace Penguloon /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { - GraphicsDevice.Clear(Color.CornflowerBlue); + var delta = (float)gameTime.ElapsedGameTime.TotalSeconds; + + GraphicsDevice.Clear(Color.Black); + + SpriteBatch.Begin(); + + SceneManager.Draw(delta); - // TODO: Add your drawing code here + SpriteBatch.End(); base.Draw(gameTime); } diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index bfeba13..86b2a65 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" /> <PropertyGroup> @@ -19,10 +19,10 @@ <AndroidSupportedAbis>armeabi-v7a%3bx86</AndroidSupportedAbis> <AndroidStoreUncompressedFileExtensions>.m4a</AndroidStoreUncompressedFileExtensions> <MandroidI18n /> - <TargetFrameworkVersion>v8.0</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> <MonoGamePlatform>Android</MonoGamePlatform> <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> - <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> + <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -34,6 +34,9 @@ <WarningLevel>4</WarningLevel> <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> <AndroidLinkMode>None</AndroidLinkMode> + <AotAssemblies>false</AotAssemblies> + <EnableLLVM>false</EnableLLVM> + <BundleAssemblies>false</BundleAssemblies> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -58,10 +61,27 @@ </Reference> </ItemGroup> <ItemGroup> - <Compile Include="Activity1.cs" /> - <Compile Include="Game1.cs" /> + <Compile Include="Activity.cs" /> + <Compile Include="ContentManager.cs" /> + <Compile Include="ContentPathManager.cs" /> + <Compile Include="Controls\Button.cs" /> + <Compile Include="Controls\ControlBase.cs" /> + <Compile Include="Scenes\GameScene.cs" /> + <Compile Include="Controls\LevelSelector.cs" /> + <Compile Include="Enums.cs" /> + <Compile Include="Levels\IceLevel.cs" /> + <Compile Include="Levels\LevelBase.cs" /> + <Compile Include="Levels\Map.cs" /> + <Compile Include="Main.cs" /> <Compile Include="Resources\Resource.Designer.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="SceneManager.cs" /> + <Compile Include="Scenes\LevelSelectionScene.cs" /> + <Compile Include="Scenes\LoadingScene.cs" /> + <Compile Include="Scenes\MenuScene.cs" /> + <Compile Include="Scenes\SceneBase.cs" /> + <Compile Include="SoundManager.cs" /> + <Compile Include="StaticUIValues.cs" /> </ItemGroup> <ItemGroup> <None Include="Resources\AboutResources.txt" /> diff --git a/Penguloon/Penguloon.csproj.bak b/Penguloon/Penguloon.csproj.bak new file mode 100644 index 0000000..7daac9d --- /dev/null +++ b/Penguloon/Penguloon.csproj.bak @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{6C46FE18-F5D6-4255-A202-475C1AB5EDAE}</ProjectGuid> + <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Penguloon</RootNamespace> + <AssemblyName>Penguloon</AssemblyName> + <FileAlignment>512</FileAlignment> + <AndroidApplication>true</AndroidApplication> + <AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> + <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> + <AndroidSupportedAbis>armeabi-v7a%3bx86</AndroidSupportedAbis> + <AndroidStoreUncompressedFileExtensions>.m4a</AndroidStoreUncompressedFileExtensions> + <MandroidI18n /> + <TargetFrameworkVersion>v4.4</TargetFrameworkVersion> + <MonoGamePlatform>Android</MonoGamePlatform> + <AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> + <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath> + <DefineConstants>DEBUG;TRACE;ANDROID</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> + <AndroidLinkMode>None</AndroidLinkMode> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\</OutputPath> + <DefineConstants>TRACE;ANDROID</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> + <AndroidLinkMode>SdkOnly</AndroidLinkMode> + </PropertyGroup> + <ItemGroup> + <Reference Include="Mono.Android" /> + <Reference Include="mscorlib" /> + <Reference Include="OpenTK-1.0" /> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Xml" /> + <Reference Include="MonoGame.Framework"> + <HintPath>$(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Android\MonoGame.Framework.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="Activity1.cs" /> + <Compile Include="Game1.cs" /> + <Compile Include="Resources\Resource.Designer.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="Resources\AboutResources.txt" /> + <None Include="Assets\AboutAssets.txt" /> + </ItemGroup> + <ItemGroup> + <AndroidResource Include="Resources\Values\Strings.xml" /> + </ItemGroup> + <ItemGroup> + <AndroidResource Include="Resources\Drawable\Icon.png" /> + </ItemGroup> + <ItemGroup> + <Folder Include="Resources\Layout\" /> + </ItemGroup> + <ItemGroup> + <AndroidResource Include="Resources\Drawable\Splash.png" /> + </ItemGroup> + <ItemGroup> + <AndroidResource Include="Resources\Values\Styles.xml" /> + </ItemGroup> + <ItemGroup> + <MonoGameContentReference Include="Content\Content.mgcb" /> + </ItemGroup> + <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" /> + <Import Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project>
\ No newline at end of file diff --git a/Penguloon/Properties/AndroidManifest.xml b/Penguloon/Properties/AndroidManifest.xml new file mode 100644 index 0000000..ebf11be --- /dev/null +++ b/Penguloon/Properties/AndroidManifest.xml @@ -0,0 +1,5 @@ +<?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> +</manifest>
\ No newline at end of file diff --git a/Penguloon/Resources/Resource.Designer.cs b/Penguloon/Resources/Resource.Designer.cs index d408e93..7de55ec 100644 --- a/Penguloon/Resources/Resource.Designer.cs +++ b/Penguloon/Resources/Resource.Designer.cs @@ -1,65 +1,102 @@ +#pragma warning disable 1591 //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. -// Runtime Version:4.0.30319.269 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // </auto-generated> //------------------------------------------------------------------------------ +[assembly: global::Android.Runtime.ResourceDesignerAttribute("Penguloon.Resource", IsApplication=true)] + namespace Penguloon { - - - public partial class Resource - { - - public partial class Attribute - { - - private Attribute() - { - } - } - - public partial class Drawable - { - - // aapt resource value: 0x7f020000 - public const int Icon = 2130837504; - - // aapt resource value: 0x7f020001 - public const int Splash = 2130837505; - - private Drawable() - { - } - } - - public partial class String - { - - // aapt resource value: 0x7f030001 - public const int ApplicationName = 2130903041; - - // aapt resource value: 0x7f030000 - public const int Hello = 2130903040; - - private String() - { - } - } - - public partial class Style - { - - // aapt resource value: 0x7f040000 - public const int Theme_Splash = 2130968576; - - private Style() - { - } - } - } + + + [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: 0x7f020000 + public const int Icon = 2130837504; + + // aapt resource value: 0x7f020001 + public const int Splash = 2130837505; + + static Drawable() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Drawable() + { + } + } + + public partial class String + { + + // aapt resource value: 0x7f030000 + public const int ApplicationName = 2130903040; + + // aapt resource value: 0x7f030002 + public const int LevelSelectionBack = 2130903042; + + // aapt resource value: 0x7f030001 + public const int MenuBtnPlay = 2130903041; + + static String() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private String() + { + } + } + + public partial class Style + { + + // aapt resource value: 0x7f040000 + public const int Theme_Splash = 2130968576; + + static Style() + { + global::Android.Runtime.ResourceIdManager.UpdateIdValues(); + } + + private Style() + { + } + } + } } +#pragma warning restore 1591 diff --git a/Penguloon/Resources/Values/Strings.xml b/Penguloon/Resources/Values/Strings.xml index 01bbd6d..3e77381 100644 --- a/Penguloon/Resources/Values/Strings.xml +++ b/Penguloon/Resources/Values/Strings.xml @@ -1,5 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="Hello">Hello World, Click Me!</string> <string name="ApplicationName">Penguloon</string> + + <!-- menu --> + <string name="MenuBtnPlay">Play</string> + + <!-- level selection --> + <string name="LevelSelectionBack">Back</string> </resources> diff --git a/Penguloon/SceneManager.cs b/Penguloon/SceneManager.cs new file mode 100644 index 0000000..7ea296a --- /dev/null +++ b/Penguloon/SceneManager.cs @@ -0,0 +1,71 @@ +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Scenes; + +namespace Penguloon +{ + public static class SceneManager + { + public static SelectedScene SelectedScene { get; set; } = SelectedScene.Loading; + + public static SceneBase MenuScene { get; set; } + + public static SceneBase LevelSelectionScene { get; set; } + + public static SceneBase LoadingScene { get; set; } + + public static SceneBase GameScene { get; set; } + + /// <summary> + /// Initialize scene manager. + /// </summary> + public static void Initialize(Main main) + { + LoadingScene = new LoadingScene(main); + } + + /// <summary> + /// Draw selected scene. + /// </summary> + /// <param name="deltaTime">Delta time.</param> + public static void Draw(float deltaTime) + { + switch (SelectedScene) + { + case SelectedScene.Menu: + MenuScene.Draw(deltaTime); break; + case SelectedScene.Ingame: + GameScene.Draw(deltaTime); break; + case SelectedScene.LevelSelection: + LevelSelectionScene.Draw(deltaTime); break; + case SelectedScene.Loading: + LoadingScene.Draw(deltaTime); break; + + default: + return; + } + } + + /// <summary> + /// Update selected scene. + /// </summary> + /// <param name="deltaTime">Delta time.</param> + /// <param name="touchLocations">Finger touch points.</param> + public static void Update(float deltaTime, TouchLocation[] touchLocations) + { + switch (SelectedScene) + { + case SelectedScene.Menu: + MenuScene.Update(deltaTime, touchLocations); break; + case SelectedScene.Ingame: + GameScene.Update(deltaTime, touchLocations); break; + case SelectedScene.LevelSelection: + LevelSelectionScene.Update(deltaTime, touchLocations); break; + case SelectedScene.Loading: + LoadingScene.Update(deltaTime, touchLocations); break; + + default: + return; + } + } + } +}
\ No newline at end of file diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs new file mode 100644 index 0000000..2928b4b --- /dev/null +++ b/Penguloon/Scenes/GameScene.cs @@ -0,0 +1,36 @@ +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Levels; +using Penguloon.Scenes; + +namespace Penguloon.Scenes +{ + internal class GameScene : SceneBase + { + public LevelBase Level { get; set; } + + public GameScene(Main main, LevelBase level) : base(main) + { + this.Level = level; + this.Level.Initialize(this); + } + + public override void CreateControls() + { + + } + + public override void Draw(float deltaTime) + { + base.Draw(deltaTime); + + this.Level.Draw(deltaTime); + } + + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + base.Update(deltaTime, touchLocations); + + this.Level.Update(deltaTime, touchLocations); + } + } +}
\ No newline at end of file diff --git a/Penguloon/Scenes/LevelSelectionScene.cs b/Penguloon/Scenes/LevelSelectionScene.cs new file mode 100644 index 0000000..4df627c --- /dev/null +++ b/Penguloon/Scenes/LevelSelectionScene.cs @@ -0,0 +1,47 @@ +using System; +using Penguloon.Controls; +using Microsoft.Xna.Framework; + +namespace Penguloon.Scenes +{ + public class LevelSelectionScene : SceneBase + { + public LevelSelectionScene(Main main) : base(main) + { + + } + + public override void CreateControls() + { + Button btnStart = new Button(this, + new Vector2(10, 10), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.LevelSelectionBack)); + + btnStart.OnClick += BtnStart_OnClick; + + int levelSelectorPosY = (int)((StaticUIValues.ScreenViewport.Y - StaticUIValues.MenuButtonSize.Y) - StaticUIValues.LevelSelectorHeight); + + LevelSelector levelSelector = new LevelSelector(this, + new Vector2(0, levelSelectorPosY), new Vector2(StaticUIValues.ScreenViewport.X, StaticUIValues.LevelSelectorHeight)); + + Controls.Add(levelSelector); + Controls.Add(btnStart); + } + + 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(); + + base.Draw(deltaTime); + } + } +}
\ No newline at end of file diff --git a/Penguloon/Scenes/LoadingScene.cs b/Penguloon/Scenes/LoadingScene.cs new file mode 100644 index 0000000..19f0215 --- /dev/null +++ b/Penguloon/Scenes/LoadingScene.cs @@ -0,0 +1,71 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Scenes; +using System; +using System.Collections.Generic; + +namespace Penguloon.Scenes +{ + public class LoadingScene : SceneBase + { + public LoadingScene(Main main) : base(main) + { + + } + + public override void CreateControls() + { + + } + + public override void Draw(float deltaTime) + { + base.Draw(deltaTime); + + // if were still loading assets for loading screen, return + if (!ContentManager.DonePreLoading) return; + + // background + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/background"), + destinationRectangle: new Rectangle(0, 0, (int)StaticUIValues.ScreenViewport.X, (int)StaticUIValues.ScreenViewport.Y)); + + DrawSnowflakes(); + + // draw progressbar + DrawProgressbar(); + + // draw title + DrawText(ContentManager.GetFont("Fonts/GWENT/128"), "Penguloon", new Vector2(0, 100), + StaticUIValues.ScreenViewport, TextAllignment.CenterTop, Color.Red, Color.Black, 5); + } + + /// <summary> + /// Draw progress bar. + /// </summary> + private void DrawProgressbar() + { + int barWidth = (int)(StaticUIValues.LoadingProgressbarSize.X * ContentManager.LoadPercentageF); + + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/red"), + destinationRectangle: new Rectangle(StaticUIValues.LoadingProgressbarValuePosition.ToPoint(), + new Point(barWidth - 10, (int)StaticUIValues.LoadingProgressbarSize.Y - 10))); + + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/progressbar"), + destinationRectangle: new Rectangle(StaticUIValues.LoadingProgressbarPosition.ToPoint(), + StaticUIValues.LoadingProgressbarSize.ToPoint())); + } + + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + base.Update(deltaTime, touchLocations); + + // if loading is completed + if (ContentManager.DoneLoading) + { + SceneManager.MenuScene = new MenuScene(Main); + SceneManager.SelectedScene = SelectedScene.Menu; + } + } + } +}
\ No newline at end of file diff --git a/Penguloon/Scenes/MenuScene.cs b/Penguloon/Scenes/MenuScene.cs new file mode 100644 index 0000000..24a260c --- /dev/null +++ b/Penguloon/Scenes/MenuScene.cs @@ -0,0 +1,50 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Controls; + +namespace Penguloon.Scenes +{ + internal class MenuScene : SceneBase + { + public MenuScene(Main main) : base(main) + { + if (SoundManager.Baseline == null) + SoundManager.StartBaseline(); + } + + public override void CreateControls() + { + Button btnStart = new Button(this, + new Vector2((StaticUIValues.ScreenViewport.X - StaticUIValues.MenuButtonSize.X) / 2, 100), + StaticUIValues.MenuButtonSize, Main.Resources.GetString(Resource.String.MenuBtnPlay)); + + btnStart.OnClick += BtnStart_OnClick; + + Controls.Add(btnStart); + } + + private void BtnStart_OnClick(object sender, ClickArgs e) + { + if(SceneManager.LevelSelectionScene == null) + SceneManager.LevelSelectionScene = new LevelSelectionScene(Main); + + SceneManager.SelectedScene = SelectedScene.LevelSelection; + } + + 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(); + + base.Draw(deltaTime); + } + + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + base.Update(deltaTime, touchLocations); + } + } +}
\ No newline at end of file diff --git a/Penguloon/Scenes/SceneBase.cs b/Penguloon/Scenes/SceneBase.cs new file mode 100644 index 0000000..4214e97 --- /dev/null +++ b/Penguloon/Scenes/SceneBase.cs @@ -0,0 +1,157 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Controls; +using System; +using System.Collections.Generic; + +namespace Penguloon.Scenes +{ + public abstract class SceneBase + { + public List<Vector2> SnowflakeList { get; set; } = new List<Vector2>(); + public DateTime LastSnowflakeSpawn { get; set; } + public int SnowflakeSpawnDelayMS { get; set; } = 1000; + public float SnowflakeRotation { get; set; } = 0f; + + public Main Main { get; set; } + + public List<ControlBase> Controls = new List<ControlBase>(); + + /// <summary> + /// Base constructor. + /// </summary> + /// <param name="main">active Main object.</param> + protected SceneBase(Main main) + { + this.Main = main; + CreateControls(); + } + + /// <summary> + /// Draw this scene. + /// </summary> + /// <param name="deltaTime">Delta time.</param> + public virtual void Draw(float deltaTime) + { + for (int i = 0; i < Controls.Count; i++) + Controls[i].Draw(deltaTime); + } + + /// <summary> + /// Update this scene. + /// </summary> + /// <param name="deltaTime">Delta time.</param> + /// <param name="touchLocations">Finger touch locations.</param> + public virtual void Update(float deltaTime, TouchLocation[] touchLocations) + { + for (int i = 0; i < Controls.Count; i++) + Controls[i].Update(deltaTime, touchLocations); + + SnowflakeRotation += 5f * deltaTime; + + if ((DateTime.Now - LastSnowflakeSpawn).TotalMilliseconds > SnowflakeSpawnDelayMS) + SpawnSnowflake(); + + for (int i = 0; i < SnowflakeList.Count; i++) + { + SnowflakeList[i] = new Vector2(SnowflakeList[i].X, SnowflakeList[i].Y + 5); + } + + DeleteOutofBoundSnowflakes(); + } + + private void DeleteOutofBoundSnowflakes() + { + for (int i = 0; i < SnowflakeList.Count; i++) + { + if (SnowflakeList[i].Y - 100 > StaticUIValues.ScreenViewport.Y) + SnowflakeList.RemoveAt(i); + } + } + + /// <summary> + /// Draw text at given parameters. + /// </summary> + /// <param name="font"></param> + /// <param name="text"></param> + /// <param name="position"></param> + /// <param name="size"></param> + /// <param name="textAllignment"></param> + /// <param name="color"></param> + public void DrawText(SpriteFont font, string text, Vector2 position, Vector2 size, TextAllignment textAllignment, Color color, Color borderColor, int borderWidth) + { + if (font == null) return; + + Vector2 textSize = font.MeasureString(text); + + Vector2 pos = position; + + switch (textAllignment) + { + case TextAllignment.LeftTop: pos = position; break; + case TextAllignment.CenterTop: pos.X += (size.X / 2) - (textSize.X / 2); break; + case TextAllignment.RightTop: pos.X += (size.X) - (textSize.X); break; + + case TextAllignment.LeftMiddle: pos.Y += (size.Y / 2) - (textSize.Y / 2) + 5; break; + case TextAllignment.CenterMiddle: pos.X += (size.X / 2) - (textSize.X / 2); pos.Y += (size.Y / 2) - (textSize.Y / 2) + 5; break; + case TextAllignment.RightMiddle: pos.X += (size.X) - (textSize.X); pos.Y += (size.Y / 2) - (textSize.Y / 2) + 5; break; + + case TextAllignment.LeftBottom: pos.Y += (size.Y) - (textSize.Y); break; + case TextAllignment.CenterBottom: pos.X += (size.X / 2) - (textSize.X / 2); pos.Y += (size.Y) - (textSize.Y); break; + case TextAllignment.RightBottom: pos.X += (size.X) - (textSize.X); pos.Y += (size.Y) - (textSize.Y); break; + } + + // border + + //leftTop + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X - borderWidth, pos.Y - borderWidth), borderColor); + //centerTop + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X, pos.Y - borderWidth), borderColor); + //rightTop + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X + borderWidth, pos.Y - borderWidth), borderColor); + + //LeftMiddle + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X - borderWidth, pos.Y), borderColor); + //RightMiddle + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X + borderWidth, pos.Y), borderColor); + + //LeftBottom + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X - borderWidth, pos.Y + borderWidth), borderColor); + //CenterBottom + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X, pos.Y + borderWidth), borderColor); + //RightBottom + Main.SpriteBatch.DrawString(font, text, new Vector2(pos.X + borderWidth, pos.Y + borderWidth), borderColor); + + // text + Main.SpriteBatch.DrawString(font, text, pos, color); + } + + protected void DrawSnowflakes() + { + // draw snowflakes + for (int i = 0; i < SnowflakeList.Count; i++) + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/snowflake"), + destinationRectangle: new Rectangle((int)SnowflakeList[i].X, (int)SnowflakeList[i].Y, + StaticUIValues.SnowflakeSize, StaticUIValues.SnowflakeSize), + rotation: SnowflakeRotation, + origin: new Vector2(ContentManager.GetTexture("UI/snowflake").Width / 2, ContentManager.GetTexture("UI/snowflake").Height / 2)); + } + + protected void SpawnSnowflake() + { + LastSnowflakeSpawn = DateTime.Now; + + int minX = 100, maxX = (int)StaticUIValues.ScreenViewport.X - 200; + + int randomPosX = new Random().Next(minX, maxX); + + SnowflakeList.Add(new Vector2(randomPosX, -100)); + } + + /// <summary> + /// Create the controls for this scene. + /// </summary> + public abstract void CreateControls(); + } +}
\ No newline at end of file diff --git a/Penguloon/SoundManager.cs b/Penguloon/SoundManager.cs new file mode 100644 index 0000000..4ee40c8 --- /dev/null +++ b/Penguloon/SoundManager.cs @@ -0,0 +1,32 @@ +using Microsoft.Xna.Framework.Audio; + +namespace Penguloon +{ + public static class SoundManager + { + public static SoundEffectInstance Baseline { get; set; } + public static SoundEffectInstance BtnClick { get; set; } + + public static void StartBaseline() + { + SoundEffect effect = ContentManager.GetSound("Sounds/baseline"); + Baseline = effect.CreateInstance(); + Baseline.Volume = 0.1f; + Baseline.IsLooped = true; + Baseline.Play(); + } + + public static void PlayClickSound() + { + if(BtnClick == null) + { + SoundEffect effect = ContentManager.GetSound("Sounds/click"); + BtnClick = effect.CreateInstance(); + BtnClick.Volume = 0.5f; + BtnClick.IsLooped = false; + } + + BtnClick.Play(); + } + } +}
\ No newline at end of file diff --git a/Penguloon/StaticUIValues.cs b/Penguloon/StaticUIValues.cs new file mode 100644 index 0000000..48ae696 --- /dev/null +++ b/Penguloon/StaticUIValues.cs @@ -0,0 +1,64 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace Penguloon +{ + public static class StaticUIValues + { + public static Vector2 ScreenViewport { get; private set; } + + public static Vector2 LoadingProgressbarSize { get; set; } + public static Vector2 LoadingProgressbarPosition { get; set; } + public static Vector2 LoadingProgressbarValuePosition { get; set; } + + public static int LevelSelectorHeight { get; set; } + + public static Vector2 MenuButtonSize { get; set; } + + public static int SnowflakeSize { get; set; } + + public static string MenuFont { get; set; } + + public static int IngameUIWidth { get; set; } + + public static void Initialize(Main main) + { + ScreenViewport = main.GraphicsDevice.Viewport.Bounds.Size.ToVector2(); + + if(ScreenViewport.X >= 2440) + { + LevelSelectorHeight = 600; + LoadingProgressbarSize = new Vector2((int)(800 * 2), (int)(150 * 2)); + MenuButtonSize = new Vector2(800, 150); + MenuFont = "Fonts/GWENT/72"; + } + else if (ScreenViewport.X >= 1920) + { + LevelSelectorHeight = 600; + MenuButtonSize = new Vector2((int)(800 * 1), (int)(150 * 1)); + LoadingProgressbarSize = new Vector2((int)(800 * 1.3), (int)(150 * 1.3)); + MenuFont = "Fonts/GWENT/72"; + } + else if (ScreenViewport.X >= 1280) + { + LevelSelectorHeight = 400; + MenuButtonSize = new Vector2((int)(800 * 0.7), (int)(150 * 0.7)); + LoadingProgressbarSize = new Vector2((int)(800 * 1), (int)(150 * 1)); + MenuFont = "Fonts/GWENT/48"; + } + else + { + LevelSelectorHeight = 400; + MenuButtonSize = new Vector2((int)(800 * 0.7), (int)(150 * 0.7)); + LoadingProgressbarSize = new Vector2((int)(800 * 0.7), (int)(150 * 0.7)); + MenuFont = "Fonts/GWENT/48"; + } + + LoadingProgressbarPosition = new Vector2((ScreenViewport.X - LoadingProgressbarSize.X) / 2, ScreenViewport.Y - LoadingProgressbarSize.Y - 200); + LoadingProgressbarValuePosition = new Vector2(LoadingProgressbarPosition.X + 5, LoadingProgressbarPosition.Y + 5); + + IngameUIWidth = 250; + SnowflakeSize = 100; + } + } +}
\ No newline at end of file |
