From 1276593bfbbfcdbac24b48cf8b574da25945d763 Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Fri, 22 Dec 2017 20:30:25 +0100 Subject: ZULUL --- Penguloon/Content/Content.mgcb | 108 +++++++++++---- Penguloon/Content/Objects/cannon.png | Bin 1475 -> 5706 bytes Penguloon/Content/Objects/penguin1.png | Bin 1946 -> 12317 bytes Penguloon/Content/Objects/penguin2.png | Bin 2323 -> 18328 bytes Penguloon/Content/UI/btnDisabledIngame.png | Bin 0 -> 4076 bytes Penguloon/Content/UI/btnIdleIngame.png | Bin 0 -> 1146 bytes Penguloon/Content/UI/btnPressedIngame.png | Bin 0 -> 1144 bytes Penguloon/Content/UI/objectSelectionBackground.png | Bin 0 -> 857 bytes Penguloon/Content/UI/objectSelectionBorder.png | Bin 0 -> 857 bytes Penguloon/ContentManager.cs | 6 - Penguloon/ContentPathManager.cs | 5 + Penguloon/Controls/Button.cs | 2 +- Penguloon/Controls/ButtonIngame.cs | 28 ++++ Penguloon/Controls/ObjectSelector.cs | 145 +++++++++++++++++++++ Penguloon/Controls/SpeedButton.cs | 28 ++++ Penguloon/Levels/IceLevel.cs | 4 +- Penguloon/Levels/LevelBase.cs | 42 +++++- Penguloon/Levels/Map.cs | 35 ++++- Penguloon/Levels/WaveManager.cs | 26 ++-- Penguloon/Objects/CannonObject.cs | 9 ++ Penguloon/Objects/GoldPenguinObject.cs | 9 ++ Penguloon/Objects/ObjectBase.cs | 45 ++++++- Penguloon/Objects/PenguinObject.cs | 9 ++ Penguloon/Penguloon.csproj | 3 + Penguloon/Scenes/GameScene.cs | 67 ++++++++-- 25 files changed, 511 insertions(+), 60 deletions(-) create mode 100644 Penguloon/Content/UI/btnDisabledIngame.png create mode 100644 Penguloon/Content/UI/btnIdleIngame.png create mode 100644 Penguloon/Content/UI/btnPressedIngame.png create mode 100644 Penguloon/Content/UI/objectSelectionBackground.png create mode 100644 Penguloon/Content/UI/objectSelectionBorder.png create mode 100644 Penguloon/Controls/ButtonIngame.cs create mode 100644 Penguloon/Controls/ObjectSelector.cs create mode 100644 Penguloon/Controls/SpeedButton.cs (limited to 'Penguloon') diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index 3cc76a5..11c9cde 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -97,30 +97,6 @@ /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 @@ -443,3 +419,87 @@ /processorParam:Quality=Best /build:Sounds/pop.wav +#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/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 UI/objectSelectionBackground.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/objectSelectionBackground.png + +#begin UI/objectSelectionBorder.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/objectSelectionBorder.png + +#begin UI/btnDisabledIngame.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/btnDisabledIngame.png + +#begin UI/btnIdleIngame.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/btnIdleIngame.png + +#begin UI/btnPressedIngame.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/btnPressedIngame.png + diff --git a/Penguloon/Content/Objects/cannon.png b/Penguloon/Content/Objects/cannon.png index cb25c49..f274119 100644 Binary files a/Penguloon/Content/Objects/cannon.png and b/Penguloon/Content/Objects/cannon.png differ diff --git a/Penguloon/Content/Objects/penguin1.png b/Penguloon/Content/Objects/penguin1.png index e7ee2c3..48a75b7 100644 Binary files a/Penguloon/Content/Objects/penguin1.png and b/Penguloon/Content/Objects/penguin1.png differ diff --git a/Penguloon/Content/Objects/penguin2.png b/Penguloon/Content/Objects/penguin2.png index 7c2afec..b9e55ac 100644 Binary files a/Penguloon/Content/Objects/penguin2.png and b/Penguloon/Content/Objects/penguin2.png differ diff --git a/Penguloon/Content/UI/btnDisabledIngame.png b/Penguloon/Content/UI/btnDisabledIngame.png new file mode 100644 index 0000000..f6095a5 Binary files /dev/null and b/Penguloon/Content/UI/btnDisabledIngame.png differ diff --git a/Penguloon/Content/UI/btnIdleIngame.png b/Penguloon/Content/UI/btnIdleIngame.png new file mode 100644 index 0000000..23ea7bf Binary files /dev/null and b/Penguloon/Content/UI/btnIdleIngame.png differ diff --git a/Penguloon/Content/UI/btnPressedIngame.png b/Penguloon/Content/UI/btnPressedIngame.png new file mode 100644 index 0000000..3ce16f7 Binary files /dev/null and b/Penguloon/Content/UI/btnPressedIngame.png differ diff --git a/Penguloon/Content/UI/objectSelectionBackground.png b/Penguloon/Content/UI/objectSelectionBackground.png new file mode 100644 index 0000000..3476eab Binary files /dev/null and b/Penguloon/Content/UI/objectSelectionBackground.png differ diff --git a/Penguloon/Content/UI/objectSelectionBorder.png b/Penguloon/Content/UI/objectSelectionBorder.png new file mode 100644 index 0000000..17408a1 Binary files /dev/null and b/Penguloon/Content/UI/objectSelectionBorder.png differ diff --git a/Penguloon/ContentManager.cs b/Penguloon/ContentManager.cs index ad34ac3..e7077f8 100644 --- a/Penguloon/ContentManager.cs +++ b/Penguloon/ContentManager.cs @@ -42,8 +42,6 @@ namespace Penguloon LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); LoadPercentageF = (itemsLoaded / totalItemsToLoad); - - Thread.Sleep(25); } for (int i = 0; i < ContentPathManager.TexturePaths.Count; i++) @@ -53,8 +51,6 @@ namespace Penguloon LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); LoadPercentageF = (itemsLoaded / totalItemsToLoad); - - Thread.Sleep(25); } for (int i = 0; i < ContentPathManager.FontPaths.Count; i++) @@ -64,8 +60,6 @@ namespace Penguloon LoadPercentage = (int)((itemsLoaded / totalItemsToLoad) * 100); LoadPercentageF = (itemsLoaded / totalItemsToLoad); - - Thread.Sleep(25); } DoneLoading = true; diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs index 8569905..3db46b5 100644 --- a/Penguloon/ContentPathManager.cs +++ b/Penguloon/ContentPathManager.cs @@ -34,8 +34,13 @@ namespace Penguloon "UI/btnDisabled", "UI/btnIdle", "UI/btnPressed", + "UI/btnDisabledIngame", + "UI/btnIdleIngame", + "UI/btnPressedIngame", "UI/border", "UI/border-horizontal", + "UI/objectSelectionBackground", + "UI/objectSelectionBorder", "SplashArt/1", diff --git a/Penguloon/Controls/Button.cs b/Penguloon/Controls/Button.cs index 121321c..757b87d 100644 --- a/Penguloon/Controls/Button.cs +++ b/Penguloon/Controls/Button.cs @@ -3,7 +3,7 @@ using Penguloon.Scenes; namespace Penguloon.Controls { - class Button : ControlBase + public class Button : ControlBase { public Button(SceneBase parentScene, Vector2 position, Vector2 size, string text) : base(parentScene, position, size) { diff --git a/Penguloon/Controls/ButtonIngame.cs b/Penguloon/Controls/ButtonIngame.cs new file mode 100644 index 0000000..acb05e0 --- /dev/null +++ b/Penguloon/Controls/ButtonIngame.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public class ButtonIngame : ControlBase + { + public ButtonIngame(SceneBase parentScene, Vector2 position, Vector2 size, string text) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/btnIdleIngame"); + this.BackgroundPressed = ContentManager.GetTexture("UI/btnPressedIngame"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/btnDisabledIngame"); + this.Text = text; + + this.ForeColor = Color.Gray; + this.BorderColor = Color.Black; + this.BorderWidth = 2; + 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/ObjectSelector.cs b/Penguloon/Controls/ObjectSelector.cs new file mode 100644 index 0000000..44b68c3 --- /dev/null +++ b/Penguloon/Controls/ObjectSelector.cs @@ -0,0 +1,145 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Levels; +using Penguloon.Objects; +using Penguloon.Scenes; +using System.Collections.Generic; +using System; + +namespace Penguloon.Controls +{ + public enum State + { + Selected, + Idle, + } + + public class ObjectSelector : ControlBase + { + public State State { get; set; } + + public int SelectedObjectIndex { get; set; } = -1; + + public Map Map { get; set; } + + public List> Objects { get; set; } = new List>(); + + public ObjectSelector(Map map, SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) + { + this.Map = map; + this.BackgroundIdle = ContentManager.GetTexture("UI/objectSelectionBackground"); + this.BackgroundPressed = ContentManager.GetTexture("UI/objectSelectionBackground"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/objectSelectionBackground"); + + this.OnClick += ObjectSelector_OnClick; + + LoadObjects(); + } + + private void ObjectSelector_OnClick(object sender, ClickArgs e) + { + int rows = 4; + + if (Objects.Count > 8) + { + rows = (int)Math.Ceiling((double)Objects.Count / 2); + } + + int width = (int)Size.X / 2; + int height = (int)Size.Y / rows; + + int oddX = (int)Position.X; + int evenX = (int)Position.X + width; + + Rectangle fingerRec = new Rectangle((int)e.ClickPosition.X, (int)e.ClickPosition.Y, 1, 1); + + for (int i = 0; i < Objects.Count; i++) + { + if (Objects[i].Item2 > Map.Level.Money) continue; + + int posX = ((i + 1) % 2 != 0) ? oddX : evenX; + int posY = (i / 2) * height; + + Rectangle rec = new Rectangle(posX, (int)Position.Y + posY, width, height); + + if (fingerRec.Intersects(rec)) + { + if (SelectedObjectIndex != i) + { + SelectedObjectIndex = i; + State = State.Selected; + } + else + { + SelectedObjectIndex = -1; + State = State.Idle; + } + return; + } + } + } + + private void LoadObjects() + { + Objects.Add(new Tuple(new PenguinObject(Map), 250)); + Objects.Add(new Tuple(new GoldPenguinObject(Map), 360)); + Objects.Add(new Tuple(new CannonObject(Map), 650)); + } + + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + base.Update(deltaTime, touchLocations); + } + + public override void Draw(float deltaTime) + { + base.Draw(deltaTime); + + int rows = 4; + + if(Objects.Count > 8) + { + rows = (int)Math.Ceiling((double)Objects.Count / 2); + } + + int width = (int)Size.X / 2; + int height = (int)Size.Y / rows; + + int oddX = (int)Position.X; + int evenX = (int)Position.X + width; + + int padding = 15; + + for (int i = 0; i < Objects.Count; i++) + { + int posX = ((i+1) % 2 != 0) ? oddX : evenX; + int posY = (i / 2) * height; + + if(State == State.Selected && i == SelectedObjectIndex) + { + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/red"), + destinationRectangle: new Rectangle(posX, (int)Position.Y + posY, width, height)); + } + + int widthToDraw = height - (padding * 2); + + ParentScene.Main.SpriteBatch.Draw(Objects[i].Item1.Texture, + destinationRectangle: new Rectangle(posX + (width - widthToDraw) / 2, (int)Position.Y + posY + padding, widthToDraw, height - (padding * 2))); + + ParentScene.DrawText(ContentManager.GetFont("Fonts/GWENT/36"), Objects[i].Item2.ToString(), new Vector2(posX, (int)Position.Y + posY), + new Vector2(width, height), TextAllignment.CenterBottom, Color.White, Color.Black, 2); + } + + // Draw borders + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/objectSelectionBorder"), + destinationRectangle: new Rectangle(evenX - 2, (int)Position.Y, 4, (int)Size.Y)); + + for(int x = 1; x < rows; x++) + { + // Draw borders + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/objectSelectionBorder"), + destinationRectangle: new Rectangle(oddX, (int)Position.Y + (x * height), (int)Size.X, 4)); + } + } + } +} \ No newline at end of file diff --git a/Penguloon/Controls/SpeedButton.cs b/Penguloon/Controls/SpeedButton.cs new file mode 100644 index 0000000..ee11d95 --- /dev/null +++ b/Penguloon/Controls/SpeedButton.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public class SpeedButton : ControlBase + { + public SpeedButton(SceneBase parentScene, Vector2 position, Vector2 size, string text) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture(""); + this.BackgroundPressed = ContentManager.GetTexture(""); + this.BackgroundDisabled = ContentManager.GetTexture(""); + this.Text = text; + + this.ForeColor = Color.White; + this.BorderColor = Color.Black; + this.BorderWidth = 2; + 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/Levels/IceLevel.cs b/Penguloon/Levels/IceLevel.cs index d9be5bb..615924f 100644 --- a/Penguloon/Levels/IceLevel.cs +++ b/Penguloon/Levels/IceLevel.cs @@ -64,8 +64,8 @@ namespace Penguloon.Levels { OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO,OO }, }; - Map.Objects.Add(new GoldPenguinObject(new Vector2(0, 0), Map)); - Map.Objects.Add(new GoldPenguinObject(new Vector2(Map.TileWidth * 2, Map.TileHeight * 4), Map)); + //Map.Objects.Add(new GoldPenguinObject(new Vector2(0, 0), Map)); + //Map.Objects.Add(new GoldPenguinObject(new Vector2(Map.TileWidth * 2, Map.TileHeight * 4), Map)); Map.Objects.Add(new GoldPenguinObject(new Vector2(Map.TileWidth * 1, Map.TileHeight * 8), Map)); } } diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs index 5698cfa..7fc1f76 100644 --- a/Penguloon/Levels/LevelBase.cs +++ b/Penguloon/Levels/LevelBase.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input.Touch; using Penguloon.Scenes; @@ -6,7 +7,7 @@ namespace Penguloon.Levels { public abstract class LevelBase { - public SceneBase ParentScene { get; set; } + public GameScene ParentScene { get; set; } public Texture2D SplashArt { get; set; } @@ -29,7 +30,7 @@ namespace Penguloon.Levels public abstract void CreateMap(); - public virtual void Initialize(SceneBase sceneBase) + public virtual void Initialize(GameScene sceneBase) { this.ParentScene = sceneBase; CreateMap(); @@ -52,6 +53,41 @@ namespace Penguloon.Levels } UpdateUnique(deltaTime, touchLocations); + CheckForObjectPlacement(touchLocations); + } + + private void CheckForObjectPlacement(TouchLocation[] touchLocations) + { + if (ParentScene.ObjectSeletor.State == Controls.State.Idle || ParentScene.ObjectSeletor.SelectedObjectIndex == -1) return; + + for(int i = 0; i < touchLocations.Length; i++) + { + if (touchLocations[i].Position.X > Map.MapWidth) return; + if (touchLocations[i].Position.Y > Map.MapHeight) return; + + int tileX = (int)touchLocations[i].Position.X / Map.TileWidth; + int tileY = (int)touchLocations[i].Position.Y / Map.TileHeight; + + if (Map.TileMap[tileY, tileX].Direction != Direction.None) return; + + int posToSpawnX = tileX * Map.TileWidth; + int posToSpawnY = tileY * Map.TileHeight; + + // check if there isnt an object already + for (int x = 0; x < Map.Objects.Count; x++) + { + if (Map.Objects[x].Position == new Vector2(posToSpawnX, posToSpawnY)) + return; + } + + Money -= ParentScene.ObjectSeletor.Objects[ParentScene.ObjectSeletor.SelectedObjectIndex].Item2; + + Map.SpawnObject(ParentScene.ObjectSeletor.Objects[ParentScene.ObjectSeletor.SelectedObjectIndex].Item1.GetType(), + new Vector2(posToSpawnX, posToSpawnY)); + + ParentScene.ObjectSeletor.State = Controls.State.Idle; + ParentScene.ObjectSeletor.SelectedObjectIndex = -1; + } } public virtual void DrawUnique(float deltaTime) diff --git a/Penguloon/Levels/Map.cs b/Penguloon/Levels/Map.cs index 5248a25..2e90874 100644 --- a/Penguloon/Levels/Map.cs +++ b/Penguloon/Levels/Map.cs @@ -10,7 +10,7 @@ namespace Penguloon.Levels { public class Map { - // 18 x 12 + // 18 x 13 public Tile[,] TileMap { get; set; } public int MapWidth { get; private set; } @@ -41,9 +41,19 @@ namespace Penguloon.Levels MapHeight = (int)(StaticUIValues.ScreenViewport.Y); TileWidth = MapWidth / 18; - TileHeight = MapHeight / 13; + + if (TileWidth * 13 > MapHeight) + { + TileHeight = MapHeight / 13; + TileWidth = TileHeight; + } + else + { + TileHeight = TileWidth; + } MapWidth = TileWidth * 18; + MapHeight = TileHeight * 13; WaveManager = new WaveManager(this); } @@ -94,7 +104,7 @@ namespace Penguloon.Levels if(Enemies.Count == 0 && WaveManager.DoneSpawning && WaveManager.RoundActive) { WaveManager.RoundActive = false; - Level.Money += (WaveManager.CurrentWave * 11); + Level.Money += (WaveManager.CurrentWave * 30); } } @@ -159,6 +169,25 @@ namespace Penguloon.Levels Enemies.Insert(index, b); } } + + public void SpawnObject(Type type, Vector2 pos) + { + if (type == typeof(PenguinObject)) + { + var b = new PenguinObject(pos, this); + Objects.Add(b); + } + if (type == typeof(GoldPenguinObject)) + { + var b = new GoldPenguinObject(pos, this); + Objects.Add(b); + } + if (type == typeof(CannonObject)) + { + var b = new CannonObject(pos, this); + Objects.Add(b); + } + } } public class Tile diff --git a/Penguloon/Levels/WaveManager.cs b/Penguloon/Levels/WaveManager.cs index 022b5d2..b7dd192 100644 --- a/Penguloon/Levels/WaveManager.cs +++ b/Penguloon/Levels/WaveManager.cs @@ -26,13 +26,23 @@ namespace Penguloon.Levels private void CreateWaves() { - /* 1 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 10) }, 500)); - /* 2 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 25) }, 500)); - /* 3 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 25), new Tuple(typeof(BlueBalloon), 7) }, 500)); - /* 4 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(BlueBalloon), 25), new Tuple(typeof(BlueBalloon), 12) }, 500)); - /* 5 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(BlueBalloon), 7), new Tuple(typeof(BlueBalloon), 20) }, 500)); - - + /* 1 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 10) }, 1000)); + /* 2 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 25) }, 1000)); + /* 3 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 25), new Tuple(typeof(BlueBalloon), 7) }, 1000)); + /* 4 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 25), new Tuple(typeof(BlueBalloon), 12) }, 1000)); + /* 5 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(RedBalloon), 7), new Tuple(typeof(BlueBalloon), 20) }, 1000)); + + /* 6 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(YellowBalloon), 10) }, 800)); + /* 7 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(YellowBalloon), 25) }, 800)); + /* 8 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(YellowBalloon), 25), new Tuple(typeof(GreenBalloon), 7) }, 800)); + /* 9 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(YellowBalloon), 25), new Tuple(typeof(GreenBalloon), 12) }, 800)); + /* 10 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(YellowBalloon), 7), new Tuple(typeof(GreenBalloon), 20) }, 800)); + + /* 11 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(OrangeBalloon), 10) }, 500)); + /* 12 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(OrangeBalloon), 25) }, 500)); + /* 13 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(OrangeBalloon), 25), new Tuple(typeof(PurpleBalloon), 7) }, 500)); + /* 14 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(OrangeBalloon), 25), new Tuple(typeof(PurpleBalloon), 12) }, 500)); + /* 15 */ Waves.Add(new Wave(new List>() { new Tuple(typeof(OrangeBalloon), 7), new Tuple(typeof(PurpleBalloon), 20) }, 500)); } public void StartSpawningEnemies() @@ -54,7 +64,7 @@ namespace Penguloon.Levels for(int x = 0; x < Waves[waveToSpawn].EnemiesToSpawn[i].Item2; x++) { Map.SpawnEnemy(Waves[waveToSpawn].EnemiesToSpawn[i].Item1); - Thread.Sleep(Waves[waveToSpawn].SpawnDelayMS); + Thread.Sleep(Waves[waveToSpawn].SpawnDelayMS / (int)Map.Level.ParentScene.Speed); } } diff --git a/Penguloon/Objects/CannonObject.cs b/Penguloon/Objects/CannonObject.cs index f3cf7ff..916e617 100644 --- a/Penguloon/Objects/CannonObject.cs +++ b/Penguloon/Objects/CannonObject.cs @@ -16,6 +16,15 @@ namespace Penguloon.Objects this.AttackSpeedMS = 2500; } + public CannonObject(Map map) : base(map) + { + this.Texture = ContentManager.GetTexture("Objects/cannon"); + this.TileSpanX = 1; + this.TileSpanY = 1; + this.Range = Map.TileWidth * 3f; + this.AttackSpeedMS = 2500; + } + public override void DrawUnique(float deltaTime) { diff --git a/Penguloon/Objects/GoldPenguinObject.cs b/Penguloon/Objects/GoldPenguinObject.cs index fc5eb62..c406e2c 100644 --- a/Penguloon/Objects/GoldPenguinObject.cs +++ b/Penguloon/Objects/GoldPenguinObject.cs @@ -16,6 +16,15 @@ namespace Penguloon.Objects this.AttackSpeedMS = 500; } + public GoldPenguinObject(Map map) : base(map) + { + this.Texture = ContentManager.GetTexture("Objects/penguin2"); + this.TileSpanX = 1; + this.TileSpanY = 1; + this.Range = Map.TileWidth * 2.5f; + this.AttackSpeedMS = 500; + } + public override void DrawUnique(float deltaTime) { diff --git a/Penguloon/Objects/ObjectBase.cs b/Penguloon/Objects/ObjectBase.cs index c72788e..cde206d 100644 --- a/Penguloon/Objects/ObjectBase.cs +++ b/Penguloon/Objects/ObjectBase.cs @@ -36,6 +36,11 @@ namespace Penguloon.Objects this.Position = position; } + public ObjectBase(Map map) + { + this.Map = map; + } + public void Update(float deltaTime) { this.Center = new Vector2(Position.X + ((TileSpanX * Map.TileWidth) / 2), Position.Y + ((TileSpanY * Map.TileHeight) / 2)); @@ -47,7 +52,7 @@ namespace Penguloon.Objects { Rotation = (float)GetRotation(Map.Enemies[i].Box.Center.ToVector2()); - if ((DateTime.Now - LastAttack).TotalMilliseconds > AttackSpeedMS) + if ((DateTime.Now - LastAttack).TotalMilliseconds > (AttackSpeedMS / (int)Map.Level.ParentScene.Speed)) { LastAttack = DateTime.Now; SpawnUnique(); @@ -61,6 +66,40 @@ namespace Penguloon.Objects Projectiles[i].Update(deltaTime); UpdateUnique(deltaTime); + RemoveUselessProjectiles(); + } + + private void RemoveUselessProjectiles() + { + for (int i = 0; i < Projectiles.Count; i++) + { + if (i < Projectiles.Count) + { + if (Projectiles[i].Position.X < -50) + { + Projectiles.Remove(Projectiles[i]); + return; + } + + if (Projectiles[i].Position.X > StaticUIValues.ScreenViewport.X + 50) + { + Projectiles.Remove(Projectiles[i]); + return; + } + + if (Projectiles[i].Position.Y < -50) + { + Projectiles.Remove(Projectiles[i]); + return; + } + + if (Projectiles[i].Position.Y > StaticUIValues.ScreenViewport.Y + 50) + { + Projectiles.Remove(Projectiles[i]); + return; + } + } + } } public abstract void UpdateUnique(float deltaTime); @@ -91,8 +130,8 @@ namespace Penguloon.Objects rotation: (float)rot, origin: new Vector2(Texture.Width / 2, Texture.Height / 2)); - Map.ParentScene.Main.SpriteBatch.Draw(RangeCircle, - destinationRectangle: new Rectangle((int)rec.X - ((int)Range), (int)rec.Y - ((int)Range), (int)Range * 2, (int)Range * 2)); + //Map.ParentScene.Main.SpriteBatch.Draw(RangeCircle, + // destinationRectangle: new Rectangle((int)rec.X - ((int)Range), (int)rec.Y - ((int)Range), (int)Range * 2, (int)Range * 2)); } public abstract void DrawUnique(float deltaTime); diff --git a/Penguloon/Objects/PenguinObject.cs b/Penguloon/Objects/PenguinObject.cs index adbdc7e..abb3c3a 100644 --- a/Penguloon/Objects/PenguinObject.cs +++ b/Penguloon/Objects/PenguinObject.cs @@ -16,6 +16,15 @@ namespace Penguloon.Objects this.AttackSpeedMS = 1000; } + public PenguinObject(Map map) : base(map) + { + this.Texture = ContentManager.GetTexture("Objects/penguin1"); + this.TileSpanX = 1; + this.TileSpanY = 1; + this.Range = Map.TileWidth * 2; + this.AttackSpeedMS = 1000; + } + public override void DrawUnique(float deltaTime) { diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index 8e3e22a..4e8ed6c 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -65,7 +65,10 @@ + + + diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs index 3ab7c28..0647539 100644 --- a/Penguloon/Scenes/GameScene.cs +++ b/Penguloon/Scenes/GameScene.cs @@ -3,31 +3,67 @@ using Microsoft.Xna.Framework.Input.Touch; using Penguloon.Controls; using Penguloon.Levels; using Penguloon.Scenes; +using System; namespace Penguloon.Scenes { - internal class GameScene : SceneBase + public class GameScene : SceneBase { public LevelBase Level { get; set; } - public Button StartRoundBtn { get; set; } + public float Speed { get; set; } = 1f; + + public ButtonIngame StartRoundBtn { get; set; } + public SpeedButton ChangeSpeedBtn { get; set; } + public ButtonIngame OptionsBtn { get; set; } + + public ObjectSelector ObjectSeletor { get; set; } public GameScene(Main main, LevelBase level) : base(main) { this.Level = level; this.Level.Initialize(this); - StartRoundBtn = new Button(this, + StartRoundBtn = new ButtonIngame(this, new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight), new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), "Start"); + OptionsBtn = new ButtonIngame(this, + new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth), + new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), "Options"); + + ChangeSpeedBtn = new SpeedButton(this, + new Vector2(Level.Map.MapWidth - 200, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight), + new Vector2(200, StaticUIValues.IngameUIPlayButtonHeight), "X1"); + + ChangeSpeedBtn.OnClick += ChangeSpeedBtn_OnClick; StartRoundBtn.OnClick += StartRoundBtn_OnClick; + + ObjectSeletor = new ObjectSelector(level.Map, this, + new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.IngameUITextAreaHeight + StaticUIValues.BorderWidth), + new Vector2((int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), + StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUITextAreaHeight - StaticUIValues.BorderWidth - StaticUIValues.BorderWidth - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth - StaticUIValues.IngameUIPlayButtonHeight)); + + } + + private void ChangeSpeedBtn_OnClick(object sender, ClickArgs e) + { + switch (Speed) + { + case 1f: Speed = 2f; break; + case 2f: Speed = 3f; break; + case 3f: Speed = 1f; break; + + default: Speed = 1f; break; + } + + ChangeSpeedBtn.Text = "X" + Math.Round(Speed, 0).ToString(); } private void StartRoundBtn_OnClick(object sender, ClickArgs e) { Level.Map.WaveManager.StartSpawningEnemies(); - Button btn = (Button)sender; + ButtonIngame btn = (ButtonIngame)sender; btn.ControlState = ControlState.Disabled; } @@ -49,6 +85,9 @@ namespace Penguloon.Scenes DrawUI(deltaTime); StartRoundBtn.Draw(deltaTime); + ObjectSeletor.Draw(deltaTime); + ChangeSpeedBtn.Draw(deltaTime); + OptionsBtn.Draw(deltaTime); } private void DrawUI(float deltaTime) @@ -56,24 +95,29 @@ namespace Penguloon.Scenes //background Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/red"), destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth, - 0, StaticUIValues.IngameUIWidth, (int)StaticUIValues.ScreenViewport.Y)); + 0, (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), (int)StaticUIValues.ScreenViewport.Y)); //border Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"), destinationRectangle: new Rectangle(Level.Map.MapWidth, 0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y)); - - + //border under text Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4, - StaticUIValues.IngameUITextAreaHeight, StaticUIValues.IngameUIWidth, StaticUIValues.BorderWidth)); + StaticUIValues.IngameUITextAreaHeight, (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth)); + + //border above options + Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), + destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4, + (int)StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth, + (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth)); //border above button Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4, (int)StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth, - StaticUIValues.IngameUIWidth, StaticUIValues.BorderWidth)); + (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth)); DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), "Gold: " + Level.Money, new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, 10), @@ -98,6 +142,9 @@ namespace Penguloon.Scenes { base.Update(deltaTime, touchLocations); StartRoundBtn.Update(deltaTime, touchLocations); + ObjectSeletor.Update(deltaTime, touchLocations); + ChangeSpeedBtn.Update(deltaTime, touchLocations); + OptionsBtn.Update(deltaTime, touchLocations); } if (StartRoundBtn.ControlState == ControlState.Disabled && !Level.Map.WaveManager.RoundActive && !Level.Finished) @@ -106,7 +153,7 @@ namespace Penguloon.Scenes Level.Map.WaveManager.FinishRound(); } - this.Level.Update(deltaTime, touchLocations); + this.Level.Update(deltaTime * Speed, touchLocations); } } } \ No newline at end of file -- cgit v1.2.3-70-g09d2