summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraldrikboy <aldrikboy@gmail.com>2018-01-14 13:42:38 +0100
committeraldrikboy <aldrikboy@gmail.com>2018-01-14 13:42:38 +0100
commit8d30b5ac461e95cabfc74e46b610beabd81cb460 (patch)
treeffe44142cf340670a824111728fb1f2e51653c4d
parent9c9aba58a63315d7b02bd8bf50fc98c18be93ede (diff)
upgrade menu
-rw-r--r--Penguloon/Levels/IceLevel.cs2
-rw-r--r--Penguloon/Levels/LevelBase.cs44
-rw-r--r--Penguloon/Objects/ObjectBase.cs15
-rw-r--r--Penguloon/Scenes/GameScene.cs48
4 files changed, 97 insertions, 12 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;
diff --git a/Penguloon/Objects/ObjectBase.cs b/Penguloon/Objects/ObjectBase.cs
index 6474afe..aef4e6a 100644
--- a/Penguloon/Objects/ObjectBase.cs
+++ b/Penguloon/Objects/ObjectBase.cs
@@ -35,6 +35,8 @@ namespace Penguloon.Objects
public bool ShouldRotate { get; set; } = true;
+ public bool Selected { get; set; } = false;
+
public ObjectBase(Vector2 position, Map map)
{
this.Map = map;
@@ -162,6 +164,19 @@ namespace Penguloon.Objects
destinationRectangle: rec,
rotation: (float)rot,
origin: new Vector2(Texture.Width / 2, Texture.Height / 2));
+
+ if (Selected)
+ {
+ Rectangle rangeCircleRec = new Rectangle(
+ (int)Position.X + ((TileSpanX * Map.TileWidth) / 2),
+ (int)Position.Y + ((TileSpanY * Map.TileHeight) / 2),
+ (int)(Range * 2), (int)(Range * 2));
+
+ if (RangeCircle != null)
+ Map.ParentScene.Main.SpriteBatch.Draw(RangeCircle,
+ destinationRectangle: rangeCircleRec,
+ origin: new Vector2(RangeCircle.Width / 2, RangeCircle.Height / 2));
+ }
}
public abstract void DrawUnique(float deltaTime);
diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs
index 40a7650..06c171c 100644
--- a/Penguloon/Scenes/GameScene.cs
+++ b/Penguloon/Scenes/GameScene.cs
@@ -104,13 +104,34 @@ namespace Penguloon.Scenes
this.Level.Draw(deltaTime);
- DrawUI(deltaTime);
+ if (Level.SelectedObject == null)
+ {
+ DrawUI(deltaTime);
+
+ StartRoundBtn.Draw(deltaTime);
+ ObjectSeletor.Draw(deltaTime);
+ ChangeSpeedBtn.Draw(deltaTime);
+ OptionsBtn.Draw(deltaTime);
+ OptionsMenu.Draw(deltaTime);
+ }
+ // show upgrade menu of object is selected
+ else
+ {
+ DrawUpgradeUI();
+ }
+ }
+
+ private void DrawUpgradeUI()
+ {
+ //background
+ Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/objectSelectionBackground"),
+ destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth,
+ 0, (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), (int)StaticUIValues.ScreenViewport.Y));
- StartRoundBtn.Draw(deltaTime);
- ObjectSeletor.Draw(deltaTime);
- ChangeSpeedBtn.Draw(deltaTime);
- OptionsBtn.Draw(deltaTime);
- OptionsMenu.Draw(deltaTime);
+ //border
+ Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"),
+ destinationRectangle: new Rectangle(Level.Map.MapWidth,
+ 0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y));
}
private void DrawUI(float deltaTime)
@@ -143,17 +164,17 @@ namespace Penguloon.Scenes
(int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth));
DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), Main.Resources.GetString(Resource.String.IngameGold) + ": " + Level.Money,
- new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, 10),
+ new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth + 5, 10),
new Vector2(StaticUIValues.ScreenViewport.X - Level.Map.MapWidth - StaticUIValues.BorderWidth, StaticUIValues.IngameUITextAreaHeight),
TextAllignment.LeftTop, Color.White, Color.Black, 2);
DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), Main.Resources.GetString(Resource.String.IngameWave) + ": " + Level.Map.WaveManager.CurrentWave.ToString(),
- new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, 0),
+ new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth + 5, 0),
new Vector2(StaticUIValues.ScreenViewport.X - Level.Map.MapWidth - StaticUIValues.BorderWidth, StaticUIValues.IngameUITextAreaHeight),
TextAllignment.LeftMiddle, Color.White, Color.Black, 2);
DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), Main.Resources.GetString(Resource.String.IngameHealth) + ": " + Level.Health,
- new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, 0),
+ new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth + 5, 0),
new Vector2(StaticUIValues.ScreenViewport.X - Level.Map.MapWidth - StaticUIValues.BorderWidth, StaticUIValues.IngameUITextAreaHeight),
TextAllignment.LeftBottom, Color.White, Color.Black, 2);
@@ -164,7 +185,7 @@ namespace Penguloon.Scenes
public override void Update(float deltaTime, TouchLocation[] touchLocations)
{
// We shouldn't update controls when the game is finished to prevent the user from placing any more objects
- if (!Level.Finished)
+ if (!Level.Finished && Level.SelectedObject == null)
{
base.Update(deltaTime, touchLocations);
StartRoundBtn.Update(deltaTime, touchLocations);
@@ -174,10 +195,15 @@ namespace Penguloon.Scenes
OptionsMenu.Update(deltaTime, touchLocations);
}
// update finished controls here
- else
+ else if (Level.Finished)
{
IngameEndStats.Update(deltaTime, touchLocations);
}
+ // update upgrade menu here
+ else
+ {
+
+ }
if (StartRoundBtn.ControlState == ControlState.Disabled && !Level.Map.WaveManager.RoundActive && !Level.Finished)
{