summaryrefslogtreecommitdiff
path: root/Penguloon/Levels
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 /Penguloon/Levels
parent12c565cbb7208b44bd7654289bbac2824901f118 (diff)
ZULUL
Diffstat (limited to 'Penguloon/Levels')
-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
4 files changed, 91 insertions, 16 deletions
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);
}
}