From fd6fa4e5cebbe3edb65d50c78dcc8a97ce98ce64 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Mon, 11 Dec 2017 22:02:13 +0100 Subject: First commit --- Penguloon/Activity.cs | 27 ++ Penguloon/Activity1.cs | 27 -- Penguloon/Content/Bullets/cannon-ammo.png | Bin 0 -> 1285 bytes Penguloon/Content/Bullets/penguin-ammo.png | Bin 0 -> 1224 bytes Penguloon/Content/Content.mgcb | 393 +++++++++++++++++++++++ Penguloon/Content/Enemies/blue.png | Bin 0 -> 26980 bytes Penguloon/Content/Enemies/green.png | Bin 0 -> 26335 bytes Penguloon/Content/Enemies/orange.png | Bin 0 -> 25183 bytes Penguloon/Content/Enemies/purple.png | Bin 0 -> 26068 bytes Penguloon/Content/Enemies/rainbow.png | Bin 0 -> 38734 bytes Penguloon/Content/Enemies/rainbow_dark.png | Bin 0 -> 32260 bytes Penguloon/Content/Enemies/red.png | Bin 0 -> 22424 bytes Penguloon/Content/Enemies/yellow.png | Bin 0 -> 25039 bytes Penguloon/Content/Fonts/GWENT/128.spritefont | 60 ++++ Penguloon/Content/Fonts/GWENT/16.spritefont | 60 ++++ Penguloon/Content/Fonts/GWENT/24.spritefont | 60 ++++ Penguloon/Content/Fonts/GWENT/36.spritefont | 60 ++++ Penguloon/Content/Fonts/GWENT/48.spritefont | 60 ++++ Penguloon/Content/Fonts/GWENT/72.spritefont | 60 ++++ Penguloon/Content/Fonts/GWENT/GWENT.ttf | Bin 0 -> 113860 bytes Penguloon/Content/Objects/cannon.png | Bin 0 -> 1475 bytes Penguloon/Content/Objects/penguin1.png | Bin 0 -> 1946 bytes Penguloon/Content/Objects/penguin2.png | Bin 0 -> 2323 bytes Penguloon/Content/Sounds/baseline.wav | Bin 0 -> 2116978 bytes Penguloon/Content/Sounds/click.wav | Bin 0 -> 15354 bytes Penguloon/Content/SplashArt/1.png | Bin 0 -> 4238 bytes Penguloon/Content/Tiles/ice.png | Bin 0 -> 1080 bytes Penguloon/Content/Tiles/waterCornerLeftDown.png | Bin 0 -> 2336 bytes Penguloon/Content/Tiles/waterCornerLeftTop.png | Bin 0 -> 2329 bytes Penguloon/Content/Tiles/waterCornerRightDown.png | Bin 0 -> 2304 bytes Penguloon/Content/Tiles/waterCornerRightTop.png | Bin 0 -> 2321 bytes Penguloon/Content/Tiles/waterHorizontal.png | Bin 0 -> 2034 bytes Penguloon/Content/Tiles/waterVertical.png | Bin 0 -> 2589 bytes Penguloon/Content/UI/background.png | Bin 0 -> 1511 bytes Penguloon/Content/UI/btnDisabled.png | Bin 0 -> 1713 bytes Penguloon/Content/UI/btnIdle.png | Bin 0 -> 1709 bytes Penguloon/Content/UI/btnPressed.png | Bin 0 -> 1754 bytes Penguloon/Content/UI/progressbar.png | Bin 0 -> 2181 bytes Penguloon/Content/UI/red.png | Bin 0 -> 970 bytes Penguloon/Content/UI/snowflake.png | Bin 0 -> 11144 bytes Penguloon/ContentManager.cs | 157 +++++++++ Penguloon/ContentPathManager.cs | 82 +++++ Penguloon/Controls/Button.cs | 28 ++ Penguloon/Controls/ControlBase.cs | 134 ++++++++ Penguloon/Controls/LevelSelector.cs | 101 ++++++ Penguloon/Enums.cs | 54 ++++ Penguloon/Game1.cs | 88 ----- Penguloon/Levels/IceLevel.cs | 47 +++ Penguloon/Levels/LevelBase.cs | 52 +++ Penguloon/Levels/Map.cs | 63 ++++ Penguloon/Main.cs | 121 +++++++ Penguloon/Penguloon.csproj | 30 +- Penguloon/Penguloon.csproj.bak | 97 ++++++ Penguloon/Properties/AndroidManifest.xml | 5 + Penguloon/Resources/Resource.Designer.cs | 143 ++++++--- Penguloon/Resources/Values/Strings.xml | 7 +- Penguloon/SceneManager.cs | 71 ++++ Penguloon/Scenes/GameScene.cs | 36 +++ Penguloon/Scenes/LevelSelectionScene.cs | 47 +++ Penguloon/Scenes/LoadingScene.cs | 71 ++++ Penguloon/Scenes/MenuScene.cs | 50 +++ Penguloon/Scenes/SceneBase.cs | 157 +++++++++ Penguloon/SoundManager.cs | 32 ++ Penguloon/StaticUIValues.cs | 64 ++++ 64 files changed, 2370 insertions(+), 174 deletions(-) create mode 100644 Penguloon/Activity.cs delete mode 100644 Penguloon/Activity1.cs create mode 100644 Penguloon/Content/Bullets/cannon-ammo.png create mode 100644 Penguloon/Content/Bullets/penguin-ammo.png create mode 100644 Penguloon/Content/Enemies/blue.png create mode 100644 Penguloon/Content/Enemies/green.png create mode 100644 Penguloon/Content/Enemies/orange.png create mode 100644 Penguloon/Content/Enemies/purple.png create mode 100644 Penguloon/Content/Enemies/rainbow.png create mode 100644 Penguloon/Content/Enemies/rainbow_dark.png create mode 100644 Penguloon/Content/Enemies/red.png create mode 100644 Penguloon/Content/Enemies/yellow.png create mode 100644 Penguloon/Content/Fonts/GWENT/128.spritefont create mode 100644 Penguloon/Content/Fonts/GWENT/16.spritefont create mode 100644 Penguloon/Content/Fonts/GWENT/24.spritefont create mode 100644 Penguloon/Content/Fonts/GWENT/36.spritefont create mode 100644 Penguloon/Content/Fonts/GWENT/48.spritefont create mode 100644 Penguloon/Content/Fonts/GWENT/72.spritefont create mode 100644 Penguloon/Content/Fonts/GWENT/GWENT.ttf create mode 100644 Penguloon/Content/Objects/cannon.png create mode 100644 Penguloon/Content/Objects/penguin1.png create mode 100644 Penguloon/Content/Objects/penguin2.png create mode 100644 Penguloon/Content/Sounds/baseline.wav create mode 100644 Penguloon/Content/Sounds/click.wav create mode 100644 Penguloon/Content/SplashArt/1.png create mode 100644 Penguloon/Content/Tiles/ice.png create mode 100644 Penguloon/Content/Tiles/waterCornerLeftDown.png create mode 100644 Penguloon/Content/Tiles/waterCornerLeftTop.png create mode 100644 Penguloon/Content/Tiles/waterCornerRightDown.png create mode 100644 Penguloon/Content/Tiles/waterCornerRightTop.png create mode 100644 Penguloon/Content/Tiles/waterHorizontal.png create mode 100644 Penguloon/Content/Tiles/waterVertical.png create mode 100644 Penguloon/Content/UI/background.png create mode 100644 Penguloon/Content/UI/btnDisabled.png create mode 100644 Penguloon/Content/UI/btnIdle.png create mode 100644 Penguloon/Content/UI/btnPressed.png create mode 100644 Penguloon/Content/UI/progressbar.png create mode 100644 Penguloon/Content/UI/red.png create mode 100644 Penguloon/Content/UI/snowflake.png create mode 100644 Penguloon/ContentManager.cs create mode 100644 Penguloon/ContentPathManager.cs create mode 100644 Penguloon/Controls/Button.cs create mode 100644 Penguloon/Controls/ControlBase.cs create mode 100644 Penguloon/Controls/LevelSelector.cs create mode 100644 Penguloon/Enums.cs delete mode 100644 Penguloon/Game1.cs create mode 100644 Penguloon/Levels/IceLevel.cs create mode 100644 Penguloon/Levels/LevelBase.cs create mode 100644 Penguloon/Levels/Map.cs create mode 100644 Penguloon/Main.cs create mode 100644 Penguloon/Penguloon.csproj.bak create mode 100644 Penguloon/Properties/AndroidManifest.xml create mode 100644 Penguloon/SceneManager.cs create mode 100644 Penguloon/Scenes/GameScene.cs create mode 100644 Penguloon/Scenes/LevelSelectionScene.cs create mode 100644 Penguloon/Scenes/LoadingScene.cs create mode 100644 Penguloon/Scenes/MenuScene.cs create mode 100644 Penguloon/Scenes/SceneBase.cs create mode 100644 Penguloon/SoundManager.cs create mode 100644 Penguloon/StaticUIValues.cs diff --git a/Penguloon/Activity.cs b/Penguloon/Activity.cs new file mode 100644 index 0000000..bb5a3d4 --- /dev/null +++ b/Penguloon/Activity.cs @@ -0,0 +1,27 @@ +using Android.App; +using Android.Content.PM; +using Android.OS; +using Android.Views; + +namespace Penguloon +{ + [Activity(Label = "Penguloon" + , MainLauncher = true + , Icon = "@drawable/icon" + , Theme = "@style/Theme.Splash" + , AlwaysRetainTaskState = true + , LaunchMode = Android.Content.PM.LaunchMode.SingleInstance + , ScreenOrientation = ScreenOrientation.Landscape + , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)] + public class Activity : Microsoft.Xna.Framework.AndroidGameActivity + { + protected override void OnCreate(Bundle bundle) + { + base.OnCreate(bundle); + var g = new Main(Resources); + SetContentView((View)g.Services.GetService(typeof(View))); + g.Run(); + } + } +} + diff --git a/Penguloon/Activity1.cs b/Penguloon/Activity1.cs deleted file mode 100644 index ac9aa1e..0000000 --- a/Penguloon/Activity1.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Android.App; -using Android.Content.PM; -using Android.OS; -using Android.Views; - -namespace Penguloon -{ - [Activity(Label = "Penguloon" - , MainLauncher = true - , Icon = "@drawable/icon" - , Theme = "@style/Theme.Splash" - , AlwaysRetainTaskState = true - , LaunchMode = Android.Content.PM.LaunchMode.SingleInstance - , ScreenOrientation = ScreenOrientation.FullUser - , ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)] - public class Activity1 : Microsoft.Xna.Framework.AndroidGameActivity - { - protected override void OnCreate(Bundle bundle) - { - base.OnCreate(bundle); - var g = new Game1(); - 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 new file mode 100644 index 0000000..93df390 Binary files /dev/null and b/Penguloon/Content/Bullets/cannon-ammo.png differ diff --git a/Penguloon/Content/Bullets/penguin-ammo.png b/Penguloon/Content/Bullets/penguin-ammo.png new file mode 100644 index 0000000..5227b4c Binary files /dev/null and b/Penguloon/Content/Bullets/penguin-ammo.png differ 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 new file mode 100644 index 0000000..f528424 Binary files /dev/null and b/Penguloon/Content/Enemies/blue.png differ diff --git a/Penguloon/Content/Enemies/green.png b/Penguloon/Content/Enemies/green.png new file mode 100644 index 0000000..6074e80 Binary files /dev/null and b/Penguloon/Content/Enemies/green.png differ diff --git a/Penguloon/Content/Enemies/orange.png b/Penguloon/Content/Enemies/orange.png new file mode 100644 index 0000000..44211c7 Binary files /dev/null and b/Penguloon/Content/Enemies/orange.png differ diff --git a/Penguloon/Content/Enemies/purple.png b/Penguloon/Content/Enemies/purple.png new file mode 100644 index 0000000..bb00460 Binary files /dev/null and b/Penguloon/Content/Enemies/purple.png differ diff --git a/Penguloon/Content/Enemies/rainbow.png b/Penguloon/Content/Enemies/rainbow.png new file mode 100644 index 0000000..ecf93f0 Binary files /dev/null and b/Penguloon/Content/Enemies/rainbow.png differ diff --git a/Penguloon/Content/Enemies/rainbow_dark.png b/Penguloon/Content/Enemies/rainbow_dark.png new file mode 100644 index 0000000..acee5b2 Binary files /dev/null and b/Penguloon/Content/Enemies/rainbow_dark.png differ diff --git a/Penguloon/Content/Enemies/red.png b/Penguloon/Content/Enemies/red.png new file mode 100644 index 0000000..ac0bb1f Binary files /dev/null and b/Penguloon/Content/Enemies/red.png differ diff --git a/Penguloon/Content/Enemies/yellow.png b/Penguloon/Content/Enemies/yellow.png new file mode 100644 index 0000000..dc4fc03 Binary files /dev/null and b/Penguloon/Content/Enemies/yellow.png differ 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 @@ + + + + + + + GWENT.ttf + + + 128 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + 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 @@ + + + + + + + GWENT.ttf + + + 16 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + 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 @@ + + + + + + + GWENT.ttf + + + 24 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + 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 @@ + + + + + + + GWENT.ttf + + + 36 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + 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 @@ + + + + + + + GWENT.ttf + + + 48 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + 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 @@ + + + + + + + GWENT.ttf + + + 72 + + + 0 + + + true + + + + + + + + + + + + ~ + + + + diff --git a/Penguloon/Content/Fonts/GWENT/GWENT.ttf b/Penguloon/Content/Fonts/GWENT/GWENT.ttf new file mode 100644 index 0000000..639d955 Binary files /dev/null and b/Penguloon/Content/Fonts/GWENT/GWENT.ttf differ diff --git a/Penguloon/Content/Objects/cannon.png b/Penguloon/Content/Objects/cannon.png new file mode 100644 index 0000000..cb25c49 Binary files /dev/null and b/Penguloon/Content/Objects/cannon.png differ diff --git a/Penguloon/Content/Objects/penguin1.png b/Penguloon/Content/Objects/penguin1.png new file mode 100644 index 0000000..e7ee2c3 Binary files /dev/null and b/Penguloon/Content/Objects/penguin1.png differ diff --git a/Penguloon/Content/Objects/penguin2.png b/Penguloon/Content/Objects/penguin2.png new file mode 100644 index 0000000..7c2afec Binary files /dev/null and b/Penguloon/Content/Objects/penguin2.png differ diff --git a/Penguloon/Content/Sounds/baseline.wav b/Penguloon/Content/Sounds/baseline.wav new file mode 100644 index 0000000..0e8eeb0 Binary files /dev/null and b/Penguloon/Content/Sounds/baseline.wav differ diff --git a/Penguloon/Content/Sounds/click.wav b/Penguloon/Content/Sounds/click.wav new file mode 100644 index 0000000..3364b09 Binary files /dev/null and b/Penguloon/Content/Sounds/click.wav differ diff --git a/Penguloon/Content/SplashArt/1.png b/Penguloon/Content/SplashArt/1.png new file mode 100644 index 0000000..4091ca6 Binary files /dev/null and b/Penguloon/Content/SplashArt/1.png differ diff --git a/Penguloon/Content/Tiles/ice.png b/Penguloon/Content/Tiles/ice.png new file mode 100644 index 0000000..b4ba6d8 Binary files /dev/null and b/Penguloon/Content/Tiles/ice.png differ diff --git a/Penguloon/Content/Tiles/waterCornerLeftDown.png b/Penguloon/Content/Tiles/waterCornerLeftDown.png new file mode 100644 index 0000000..31c1fea Binary files /dev/null and b/Penguloon/Content/Tiles/waterCornerLeftDown.png differ diff --git a/Penguloon/Content/Tiles/waterCornerLeftTop.png b/Penguloon/Content/Tiles/waterCornerLeftTop.png new file mode 100644 index 0000000..980b0e6 Binary files /dev/null and b/Penguloon/Content/Tiles/waterCornerLeftTop.png differ diff --git a/Penguloon/Content/Tiles/waterCornerRightDown.png b/Penguloon/Content/Tiles/waterCornerRightDown.png new file mode 100644 index 0000000..a28e63a Binary files /dev/null and b/Penguloon/Content/Tiles/waterCornerRightDown.png differ diff --git a/Penguloon/Content/Tiles/waterCornerRightTop.png b/Penguloon/Content/Tiles/waterCornerRightTop.png new file mode 100644 index 0000000..7f44d4a Binary files /dev/null and b/Penguloon/Content/Tiles/waterCornerRightTop.png differ diff --git a/Penguloon/Content/Tiles/waterHorizontal.png b/Penguloon/Content/Tiles/waterHorizontal.png new file mode 100644 index 0000000..881e133 Binary files /dev/null and b/Penguloon/Content/Tiles/waterHorizontal.png differ diff --git a/Penguloon/Content/Tiles/waterVertical.png b/Penguloon/Content/Tiles/waterVertical.png new file mode 100644 index 0000000..8c2cee2 Binary files /dev/null and b/Penguloon/Content/Tiles/waterVertical.png differ diff --git a/Penguloon/Content/UI/background.png b/Penguloon/Content/UI/background.png new file mode 100644 index 0000000..00a8558 Binary files /dev/null and b/Penguloon/Content/UI/background.png differ diff --git a/Penguloon/Content/UI/btnDisabled.png b/Penguloon/Content/UI/btnDisabled.png new file mode 100644 index 0000000..1a0bbfd Binary files /dev/null and b/Penguloon/Content/UI/btnDisabled.png differ diff --git a/Penguloon/Content/UI/btnIdle.png b/Penguloon/Content/UI/btnIdle.png new file mode 100644 index 0000000..f536b99 Binary files /dev/null and b/Penguloon/Content/UI/btnIdle.png differ diff --git a/Penguloon/Content/UI/btnPressed.png b/Penguloon/Content/UI/btnPressed.png new file mode 100644 index 0000000..b7dfe7d Binary files /dev/null and b/Penguloon/Content/UI/btnPressed.png differ diff --git a/Penguloon/Content/UI/progressbar.png b/Penguloon/Content/UI/progressbar.png new file mode 100644 index 0000000..32266ff Binary files /dev/null and b/Penguloon/Content/UI/progressbar.png differ diff --git a/Penguloon/Content/UI/red.png b/Penguloon/Content/UI/red.png new file mode 100644 index 0000000..b1fcae6 Binary files /dev/null and b/Penguloon/Content/UI/red.png differ diff --git a/Penguloon/Content/UI/snowflake.png b/Penguloon/Content/UI/snowflake.png new file mode 100644 index 0000000..7064643 Binary files /dev/null and b/Penguloon/Content/UI/snowflake.png differ 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 TextureDictionary { get; set; } = new Dictionary(); + private static Dictionary FontDictionary { get; set; } = new Dictionary(); + private static Dictionary SoundDictionary { get; set; } = new Dictionary(); + + 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(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(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(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(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(ContentPathManager.TexturePathsPreLoad[i])); + } + + for (int i = 0; i < ContentPathManager.FontPathsPreLoad.Count; i++) + { + FontDictionary.Add(ContentPathManager.FontPathsPreLoad[i], + main.Content.Load(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 TexturePaths { get; set; } = new List() + { + "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 FontPaths { get; set; } = new List() + { + "Fonts/GWENT/16", + "Fonts/GWENT/24", + "Fonts/GWENT/36", + "Fonts/GWENT/48", + "Fonts/GWENT/72", + }; + + public static List SoundPaths { get; set; } = new List() + { + "Sounds/click", + }; + + public static List TexturePathsPreLoad { get; set; } = new List() + { + "UI/progressbar", + "UI/red", + "UI/snowflake", + "UI/background", + }; + + public static List FontPathsPreLoad { get; set; } = new List() + { + "Fonts/GWENT/128", + }; + + public static List SoundPathsPreLoad { get; set; } = new List() + { + "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 OnClick; + public event EventHandler OnMove; + + /// + /// Base constructor. + /// + /// Active Main object. + /// Control position. + /// Control size. + protected ControlBase(SceneBase parentScene, Vector2 position, Vector2 size) + { + this.ParentScene = parentScene; + this.Position = position; + this.Size = size; + } + + /// + /// Draw controls. + /// + /// Delta time. + 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); + } + + /// + /// Update control. + /// + /// Delta time. + /// Finger touch points. + 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 Levels { get; set; } = new List(); + + 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/Game1.cs b/Penguloon/Game1.cs deleted file mode 100644 index b77d9c4..0000000 --- a/Penguloon/Game1.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; - -namespace Penguloon -{ - /// - /// This is the main type for your game. - /// - public class Game1 : Game - { - GraphicsDeviceManager graphics; - SpriteBatch spriteBatch; - - public Game1() - { - graphics = new GraphicsDeviceManager(this); - Content.RootDirectory = "Content"; - - graphics.IsFullScreen = true; - graphics.PreferredBackBufferWidth = 800; - graphics.PreferredBackBufferHeight = 480; - graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; - } - - /// - /// Allows the game to perform any initialization it needs to before starting to run. - /// This is where it can query for any required services and load any non-graphic - /// related content. Calling base.Initialize will enumerate through any components - /// and initialize them as well. - /// - protected override void Initialize() - { - // TODO: Add your initialization logic here - - base.Initialize(); - } - - /// - /// LoadContent will be called once per game and is the place to load - /// all of your content. - /// - protected override void LoadContent() - { - // Create a new SpriteBatch, which can be used to draw textures. - spriteBatch = new SpriteBatch(GraphicsDevice); - - // TODO: use this.Content to load your game content here - } - - /// - /// UnloadContent will be called once per game and is the place to unload - /// game-specific content. - /// - protected override void UnloadContent() - { - // TODO: Unload any non ContentManager content here - } - - /// - /// Allows the game to run logic such as updating the world, - /// checking for collisions, gathering input, and playing audio. - /// - /// Provides a snapshot of timing values. - protected override void Update(GameTime gameTime) - { - if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) - Exit(); - - // TODO: Add your update logic here - - base.Update(gameTime); - } - - /// - /// This is called when the game should draw itself. - /// - /// Provides a snapshot of timing values. - protected override void Draw(GameTime gameTime) - { - GraphicsDevice.Clear(Color.CornflowerBlue); - - // TODO: Add your drawing code here - - base.Draw(gameTime); - } - } -} 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/Main.cs b/Penguloon/Main.cs new file mode 100644 index 0000000..b2844fc --- /dev/null +++ b/Penguloon/Main.cs @@ -0,0 +1,121 @@ +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 +{ + /// + /// This is the main type for your game. + /// + public class Main : Game + { + private GraphicsDeviceManager _graphics; + private SpriteBatch _spriteBatch; + private Resources _resources; + + public GraphicsDeviceManager Graphics + { + get => _graphics; + set => _graphics = value; + } + + public SpriteBatch SpriteBatch + { + 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.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight; + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize() + { + SceneManager.Initialize(this); + StaticUIValues.Initialize(this); + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + SpriteBatch = new SpriteBatch(GraphicsDevice); + + ContentManager.LoadContent(this); + + // TODO: use this.Content to load your game content here + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// game-specific content. + /// + protected override void UnloadContent() + { + // TODO: Unload any non ContentManager content here + ContentManager.DisposeContent(); + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update(GameTime gameTime) + { + var delta = (float)gameTime.ElapsedGameTime.TotalSeconds; + + TouchLocation[] touchLocations = TouchPanel.GetState().ToArray(); + + SceneManager.Update(delta, touchLocations); + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + var delta = (float)gameTime.ElapsedGameTime.TotalSeconds; + + GraphicsDevice.Clear(Color.Black); + + SpriteBatch.Begin(); + + SceneManager.Draw(delta); + + 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 @@ - + @@ -19,10 +19,10 @@ armeabi-v7a%3bx86 .m4a - v8.0 + v4.4 Android Properties\AndroidManifest.xml - True + false true @@ -34,6 +34,9 @@ 4 True None + false + false + false pdbonly @@ -58,10 +61,27 @@ - - + + + + + + + + + + + + + + + + + + + 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 @@ + + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {6C46FE18-F5D6-4255-A202-475C1AB5EDAE} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + Penguloon + Penguloon + 512 + true + Resources\Resource.Designer.cs + Off + armeabi-v7a%3bx86 + .m4a + + v4.4 + Android + Properties\AndroidManifest.xml + True + + + true + full + false + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + DEBUG;TRACE;ANDROID + prompt + 4 + True + None + + + pdbonly + true + bin\$(MonoGamePlatform)\$(Platform)\$(Configuration)\ + TRACE;ANDROID + prompt + 4 + False + SdkOnly + + + + + + + + + + + $(MonoGameInstallDirectory)\MonoGame\v3.0\Assemblies\Android\MonoGame.Framework.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 @@ + + + + + \ 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 //------------------------------------------------------------------------------ // // 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. // //------------------------------------------------------------------------------ +[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 @@ - Hello World, Click Me! Penguloon + + + Play + + + Back 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; } + + /// + /// Initialize scene manager. + /// + public static void Initialize(Main main) + { + LoadingScene = new LoadingScene(main); + } + + /// + /// Draw selected scene. + /// + /// Delta time. + 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; + } + } + + /// + /// Update selected scene. + /// + /// Delta time. + /// Finger touch points. + 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); + } + + /// + /// Draw progress bar. + /// + 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 SnowflakeList { get; set; } = new List(); + public DateTime LastSnowflakeSpawn { get; set; } + public int SnowflakeSpawnDelayMS { get; set; } = 1000; + public float SnowflakeRotation { get; set; } = 0f; + + public Main Main { get; set; } + + public List Controls = new List(); + + /// + /// Base constructor. + /// + /// active Main object. + protected SceneBase(Main main) + { + this.Main = main; + CreateControls(); + } + + /// + /// Draw this scene. + /// + /// Delta time. + public virtual void Draw(float deltaTime) + { + for (int i = 0; i < Controls.Count; i++) + Controls[i].Draw(deltaTime); + } + + /// + /// Update this scene. + /// + /// Delta time. + /// Finger touch locations. + 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); + } + } + + /// + /// Draw text at given parameters. + /// + /// + /// + /// + /// + /// + /// + 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)); + } + + /// + /// Create the controls for this scene. + /// + 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 -- cgit v1.2.3-70-g09d2