summaryrefslogtreecommitdiff
path: root/Penguloon/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/Objects')
-rw-r--r--Penguloon/Objects/ObjectUpgrade.cs35
-rw-r--r--Penguloon/Objects/PenguinObject.cs6
2 files changed, 34 insertions, 7 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));
diff --git a/Penguloon/Objects/PenguinObject.cs b/Penguloon/Objects/PenguinObject.cs
index 0fc1078..7d3f259 100644
--- a/Penguloon/Objects/PenguinObject.cs
+++ b/Penguloon/Objects/PenguinObject.cs
@@ -29,8 +29,10 @@ namespace Penguloon.Objects
public override void CreateUpgrades()
{
- UpgradeList.Add(new ObjectUpgrade(100, UpgradeType.PopCount, "+1 pop", null));
- UpgradeList.Add(new ObjectUpgrade(100, UpgradeType.Speed, "+15 Speed", null));
+ ObjectUpgrade upg = new ObjectUpgrade(100, UpgradeType.PopCount, "+2 pop", null, Map.Level);
+
+ UpgradeList.Add(new ObjectUpgrade(100, UpgradeType.PopCount, "+1 pop", upg, Map.Level));
+ UpgradeList.Add(new ObjectUpgrade(100, UpgradeType.Speed, "+15 Speed", null, Map.Level));
}
public override void DrawUnique(float deltaTime)