summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraldrikboy <aldrikboy@gmail.com>2017-12-22 20:30:25 +0100
committeraldrikboy <aldrikboy@gmail.com>2017-12-22 20:30:25 +0100
commit1276593bfbbfcdbac24b48cf8b574da25945d763 (patch)
tree3d9e8a4153b5b369184b7c7de55461bd1573d30a
parent12c565cbb7208b44bd7654289bbac2824901f118 (diff)
ZULUL
-rw-r--r--Penguloon/Content/Content.mgcb108
-rw-r--r--Penguloon/Content/Objects/cannon.pngbin1475 -> 5706 bytes
-rw-r--r--Penguloon/Content/Objects/penguin1.pngbin1946 -> 12317 bytes
-rw-r--r--Penguloon/Content/Objects/penguin2.pngbin2323 -> 18328 bytes
-rw-r--r--Penguloon/Content/UI/btnDisabledIngame.pngbin0 -> 4076 bytes
-rw-r--r--Penguloon/Content/UI/btnIdleIngame.pngbin0 -> 1146 bytes
-rw-r--r--Penguloon/Content/UI/btnPressedIngame.pngbin0 -> 1144 bytes
-rw-r--r--Penguloon/Content/UI/objectSelectionBackground.pngbin0 -> 857 bytes
-rw-r--r--Penguloon/Content/UI/objectSelectionBorder.pngbin0 -> 857 bytes
-rw-r--r--Penguloon/ContentManager.cs6
-rw-r--r--Penguloon/ContentPathManager.cs5
-rw-r--r--Penguloon/Controls/Button.cs2
-rw-r--r--Penguloon/Controls/ButtonIngame.cs28
-rw-r--r--Penguloon/Controls/ObjectSelector.cs145
-rw-r--r--Penguloon/Controls/SpeedButton.cs28
-rw-r--r--Penguloon/Levels/IceLevel.cs4
-rw-r--r--Penguloon/Levels/LevelBase.cs42
-rw-r--r--Penguloon/Levels/Map.cs35
-rw-r--r--Penguloon/Levels/WaveManager.cs26
-rw-r--r--Penguloon/Objects/CannonObject.cs9
-rw-r--r--Penguloon/Objects/GoldPenguinObject.cs9
-rw-r--r--Penguloon/Objects/ObjectBase.cs45
-rw-r--r--Penguloon/Objects/PenguinObject.cs9
-rw-r--r--Penguloon/Penguloon.csproj3
-rw-r--r--Penguloon/Scenes/GameScene.cs67
25 files changed, 511 insertions, 60 deletions
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
--- a/Penguloon/Content/Objects/cannon.png
+++ b/Penguloon/Content/Objects/cannon.png
Binary files differ
diff --git a/Penguloon/Content/Objects/penguin1.png b/Penguloon/Content/Objects/penguin1.png
index e7ee2c3..48a75b7 100644
--- a/Penguloon/Content/Objects/penguin1.png
+++ b/Penguloon/Content/Objects/penguin1.png
Binary files differ
diff --git a/Penguloon/Content/Objects/penguin2.png b/Penguloon/Content/Objects/penguin2.png
index 7c2afec..b9e55ac 100644
--- a/Penguloon/Content/Objects/penguin2.png
+++ b/Penguloon/Content/Objects/penguin2.png
Binary files differ
diff --git a/Penguloon/Content/UI/btnDisabledIngame.png b/Penguloon/Content/UI/btnDisabledIngame.png
new file mode 100644
index 0000000..f6095a5
--- /dev/null
+++ b/Penguloon/Content/UI/btnDisabledIngame.png
Binary files differ
diff --git a/Penguloon/Content/UI/btnIdleIngame.png b/Penguloon/Content/UI/btnIdleIngame.png
new file mode 100644
index 0000000..23ea7bf
--- /dev/null
+++ b/Penguloon/Content/UI/btnIdleIngame.png
Binary files differ
diff --git a/Penguloon/Content/UI/btnPressedIngame.png b/Penguloon/Content/UI/btnPressedIngame.png
new file mode 100644
index 0000000..3ce16f7
--- /dev/null
+++ b/Penguloon/Content/UI/btnPressedIngame.png
Binary files differ
diff --git a/Penguloon/Content/UI/objectSelectionBackground.png b/Penguloon/Content/UI/objectSelectionBackground.png
new file mode 100644
index 0000000..3476eab
--- /dev/null
+++ b/Penguloon/Content/UI/objectSelectionBackground.png
Binary files differ
diff --git a/Penguloon/Content/UI/objectSelectionBorder.png b/Penguloon/Content/UI/objectSelectionBorder.png
new file mode 100644
index 0000000..17408a1
--- /dev/null
+++ b/Penguloon/Content/UI/objectSelectionBorder.png
Binary files 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<Tuple<ObjectBase, int>> Objects { get; set; } = new List<Tuple<ObjectBase, int>>();
+
+ 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<ObjectBase,int>(new PenguinObject(Map), 250));
+ Objects.Add(new Tuple<ObjectBase, int>(new GoldPenguinObject(Map), 360));
+ Objects.Add(new Tuple<ObjectBase, int>(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<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 10) }, 500));
- /* 2 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 25) }, 500));
- /* 3 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 25), new Tuple<Type, int>(typeof(BlueBalloon), 7) }, 500));
- /* 4 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(BlueBalloon), 25), new Tuple<Type, int>(typeof(BlueBalloon), 12) }, 500));
- /* 5 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(BlueBalloon), 7), new Tuple<Type, int>(typeof(BlueBalloon), 20) }, 500));
-
-
+ /* 1 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 10) }, 1000));
+ /* 2 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 25) }, 1000));
+ /* 3 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 25), new Tuple<Type, int>(typeof(BlueBalloon), 7) }, 1000));
+ /* 4 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 25), new Tuple<Type, int>(typeof(BlueBalloon), 12) }, 1000));
+ /* 5 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(RedBalloon), 7), new Tuple<Type, int>(typeof(BlueBalloon), 20) }, 1000));
+
+ /* 6 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(YellowBalloon), 10) }, 800));
+ /* 7 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(YellowBalloon), 25) }, 800));
+ /* 8 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(YellowBalloon), 25), new Tuple<Type, int>(typeof(GreenBalloon), 7) }, 800));
+ /* 9 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(YellowBalloon), 25), new Tuple<Type, int>(typeof(GreenBalloon), 12) }, 800));
+ /* 10 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(YellowBalloon), 7), new Tuple<Type, int>(typeof(GreenBalloon), 20) }, 800));
+
+ /* 11 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(OrangeBalloon), 10) }, 500));
+ /* 12 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(OrangeBalloon), 25) }, 500));
+ /* 13 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(OrangeBalloon), 25), new Tuple<Type, int>(typeof(PurpleBalloon), 7) }, 500));
+ /* 14 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(OrangeBalloon), 25), new Tuple<Type, int>(typeof(PurpleBalloon), 12) }, 500));
+ /* 15 */ Waves.Add(new Wave(new List<Tuple<Type, int>>() { new Tuple<Type, int>(typeof(OrangeBalloon), 7), new Tuple<Type, int>(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 @@
<Compile Include="ContentManager.cs" />
<Compile Include="ContentPathManager.cs" />
<Compile Include="Controls\Button.cs" />
+ <Compile Include="Controls\ButtonIngame.cs" />
<Compile Include="Controls\ControlBase.cs" />
+ <Compile Include="Controls\ObjectSelector.cs" />
+ <Compile Include="Controls\SpeedButton.cs" />
<Compile Include="Enemies\BlueBalloon.cs" />
<Compile Include="Enemies\DarkRainbowBalloon.cs" />
<Compile Include="Enemies\EnemyBase.cs" />
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