summaryrefslogtreecommitdiff
path: root/Penguloon/Levels
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/Levels')
-rw-r--r--Penguloon/Levels/IceLevel.cs2
-rw-r--r--Penguloon/Levels/LevelBase.cs44
2 files changed, 45 insertions, 1 deletions
diff --git a/Penguloon/Levels/IceLevel.cs b/Penguloon/Levels/IceLevel.cs
index d041095..4532774 100644
--- a/Penguloon/Levels/IceLevel.cs
+++ b/Penguloon/Levels/IceLevel.cs
@@ -11,7 +11,7 @@ namespace Penguloon.Levels
public IceLevel() : base()
{
this.SplashArt = ContentManager.GetTexture("SplashArt/1");
- this.Money = 350;
+ this.Money = 12350;
this.Health = 200;
this.ID = 1;
this.MinimumLevel = 1;
diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs
index d2eb1ba..a5afa43 100644
--- a/Penguloon/Levels/LevelBase.cs
+++ b/Penguloon/Levels/LevelBase.cs
@@ -7,6 +7,7 @@ using Penguloon.Controls;
using System.Collections.Generic;
using Penguloon.Objects;
using Microsoft.Xna.Framework.Input;
+using System.Linq;
namespace Penguloon.Levels
{
@@ -43,6 +44,8 @@ namespace Penguloon.Levels
public bool NewPR { get; set; } = false;
+ public ObjectBase SelectedObject { get; set; } = null;
+
public LevelBase()
{
@@ -150,6 +153,47 @@ namespace Penguloon.Levels
CheckForLevelUp();
PrevTouchLocations = touchLocations;
+
+ CheckForObjectSelect(touchLocations);
+ }
+
+ private void CheckForObjectSelect(TouchLocation[] touchLocations)
+ {
+ bool found = false;
+ for (int i = 0; i < touchLocations.Length; i++)
+ {
+ if (touchLocations[i].State != TouchLocationState.Pressed) continue;
+
+ int tileX = (int)(touchLocations[i].Position.X / Map.TileWidth) * Map.TileWidth;
+ int tileY = (int)(touchLocations[i].Position.Y / Map.TileHeight) * Map.TileHeight;
+
+ for (int x = 0; x < Map.Objects.Count; x++)
+ {
+ Rectangle objectRec = new Rectangle(Map.Objects[x].Position.ToPoint(),
+ new Point(Map.Objects[x].TileSpanX * Map.TileWidth, Map.Objects[x].TileSpanY * Map.TileHeight));
+
+ if (objectRec.Contains(tileX, tileY))
+ {
+ if (!Map.Objects[x].Selected)
+ {
+ Map.Objects[x].Selected = true;
+ SelectedObject = Map.Objects[x];
+ found = true;
+ }
+ else
+ {
+ Map.Objects[x].Selected = false;
+ }
+ }
+ else if (tileX < StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth)
+ {
+ Map.Objects[x].Selected = false;
+ }
+ }
+ }
+
+ if (!found && !Map.Objects.Any(e => e.Selected))
+ SelectedObject = null;
}
int lastLevelCheck;