summaryrefslogtreecommitdiff
path: root/Penguloon/Objects/ObjectUpgrade.cs
diff options
context:
space:
mode:
authoraldrikboy <aldrikboy@gmail.com>2018-01-15 19:57:56 +0100
committeraldrikboy <aldrikboy@gmail.com>2018-01-15 19:57:56 +0100
commit1f5295752f9052c2b7b64660fa36293f18de73d0 (patch)
tree17af827f212f720f9c2f63aaa02fbe723ea7db2f /Penguloon/Objects/ObjectUpgrade.cs
parenta0217e8ffaceb6bc109eec270c754935a54eb404 (diff)
upgrades working
Diffstat (limited to 'Penguloon/Objects/ObjectUpgrade.cs')
-rw-r--r--Penguloon/Objects/ObjectUpgrade.cs35
1 files changed, 30 insertions, 5 deletions
diff --git a/Penguloon/Objects/ObjectUpgrade.cs b/Penguloon/Objects/ObjectUpgrade.cs
index c1f701a..278a1fb 100644
--- a/Penguloon/Objects/ObjectUpgrade.cs
+++ b/Penguloon/Objects/ObjectUpgrade.cs
@@ -11,6 +11,7 @@ using Android.Views;
using Android.Widget;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
+using Penguloon.Levels;
namespace Penguloon.Objects
{
@@ -22,6 +23,12 @@ namespace Penguloon.Objects
Money,
}
+ public enum UpgradeState
+ {
+ Idle,
+ Pressed,
+ }
+
public class ObjectUpgrade
{
public int Cost { get; set; }
@@ -29,18 +36,29 @@ namespace Penguloon.Objects
public event EventHandler OnClick;
public UpgradeType Type { get; set; }
public string Text { get; set; }
+ public UpgradeState State { get; set; } = UpgradeState.Idle;
private Texture2D Background { get; set; }
+ private Texture2D BackgroundPressed { get; set; }
private Texture2D Icon { get; set; }
- public ObjectUpgrade(int Cost, UpgradeType Type, string Text, ObjectUpgrade NextUgrade)
+ public LevelBase ParentLevel { get; set; }
+
+ public ObjectUpgrade(int Cost, UpgradeType Type, string Text, ObjectUpgrade NextUgrade, LevelBase parentLevel)
{
+ // something is fucked up in staticUiValues.IngameUIWidth but we can workaround that issue with this line
+ StaticUIValues.UpgradePanelSize = new Vector2(
+ StaticUIValues.ScreenViewport.X - parentLevel.Map.MapWidth,
+ StaticUIValues.UpgradePanelSize.Y);
+
this.Cost = Cost;
this.Type = Type;
this.Text = Text;
this.NextUgrade = NextUgrade;
+ this.ParentLevel = parentLevel;
Background = ContentManager.GetTexture("UI/lightred");
+ BackgroundPressed = ContentManager.GetTexture("UI/objectSelectionBackground");
switch (Type)
{
@@ -63,26 +81,33 @@ namespace Penguloon.Objects
SpriteFont font = ContentManager.GetFont(StaticUIValues.IngameFont);
int textHeight = (int)font.MeasureString(Text).Y;
+ if (State == UpgradeState.Idle)
spriteBatch.Draw(Background, destinationRectangle: new Rectangle(
- (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth,
+ ParentLevel.Map.MapWidth + StaticUIValues.BorderWidth,
startY + (int)StaticUIValues.UpgradePanelSize.Y * index,
(int)StaticUIValues.UpgradePanelSize.X,
(int)StaticUIValues.UpgradePanelSize.Y));
+ else
+ spriteBatch.Draw(BackgroundPressed, destinationRectangle: new Rectangle(
+ ParentLevel.Map.MapWidth + StaticUIValues.BorderWidth,
+ startY + (int)StaticUIValues.UpgradePanelSize.Y * index,
+ (int)StaticUIValues.UpgradePanelSize.X,
+ (int)StaticUIValues.UpgradePanelSize.Y));
spriteBatch.Draw(Icon, destinationRectangle: new Rectangle(
- (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth + 20,
+ ParentLevel.Map.MapWidth + StaticUIValues.BorderWidth + 20,
startY + ((int)StaticUIValues.UpgradePanelSize.Y * index) + (int)(StaticUIValues.UpgradePanelSize.Y / 4),
(int)StaticUIValues.UpgradePanelSize.Y / 2,
(int)StaticUIValues.UpgradePanelSize.Y / 2));
spriteBatch.DrawString(ContentManager.GetFont(StaticUIValues.IngameFont),
- Text, new Vector2((int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth + 90,
+ Text, new Vector2(ParentLevel.Map.MapWidth + StaticUIValues.BorderWidth + 90,
startY + ((int)StaticUIValues.UpgradePanelSize.Y * index) + (int)(StaticUIValues.UpgradePanelSize.Y / 2) - textHeight / 2),
Color.FromNonPremultiplied(20, 20, 20, 255));
spriteBatch.Draw(ContentManager.GetTexture("UI/objectSelectionBorder"),
destinationRectangle: new Rectangle(
- (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth,
+ ParentLevel.Map.MapWidth + StaticUIValues.BorderWidth,
startY + (int)StaticUIValues.UpgradePanelSize.Y * index + (int)StaticUIValues.UpgradePanelSize.Y - 2,
(int)StaticUIValues.UpgradePanelSize.X,
2));