diff options
| author | aldrikboy <aldrikboy@gmail.com> | 2018-01-14 15:46:58 +0100 |
|---|---|---|
| committer | aldrikboy <aldrikboy@gmail.com> | 2018-01-14 15:46:58 +0100 |
| commit | a0217e8ffaceb6bc109eec270c754935a54eb404 (patch) | |
| tree | 612a5c6b54148b45a05eb74ea40af541ec69cbb2 /Penguloon/Objects/ObjectUpgrade.cs | |
| parent | 8d30b5ac461e95cabfc74e46b610beabd81cb460 (diff) | |
upgrades
Diffstat (limited to 'Penguloon/Objects/ObjectUpgrade.cs')
| -rw-r--r-- | Penguloon/Objects/ObjectUpgrade.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Penguloon/Objects/ObjectUpgrade.cs b/Penguloon/Objects/ObjectUpgrade.cs new file mode 100644 index 0000000..c1f701a --- /dev/null +++ b/Penguloon/Objects/ObjectUpgrade.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; + +namespace Penguloon.Objects +{ + public enum UpgradeType + { + Health, + PopCount, + Speed, + Money, + } + + public class ObjectUpgrade + { + public int Cost { get; set; } + public ObjectUpgrade NextUgrade { get; set; } + public event EventHandler OnClick; + public UpgradeType Type { get; set; } + public string Text { get; set; } + + private Texture2D Background { get; set; } + private Texture2D Icon { get; set; } + + public ObjectUpgrade(int Cost, UpgradeType Type, string Text, ObjectUpgrade NextUgrade) + { + this.Cost = Cost; + this.Type = Type; + this.Text = Text; + this.NextUgrade = NextUgrade; + + Background = ContentManager.GetTexture("UI/lightred"); + + switch (Type) + { + case UpgradeType.Health: Icon = ContentManager.GetTexture("UI/heart"); break; + case UpgradeType.Money: Icon = ContentManager.GetTexture("UI/money"); break; + case UpgradeType.PopCount: Icon = ContentManager.GetTexture("UI/explosion"); break; + case UpgradeType.Speed: Icon = ContentManager.GetTexture("UI/speed"); break; + } + } + + public void Click() + { + OnClick?.Invoke(this, EventArgs.Empty); + } + + internal void Draw(SpriteBatch spriteBatch, int index) + { + int startY = StaticUIValues.IngameUITextAreaHeight + StaticUIValues.BorderWidth; + + SpriteFont font = ContentManager.GetFont(StaticUIValues.IngameFont); + int textHeight = (int)font.MeasureString(Text).Y; + + spriteBatch.Draw(Background, destinationRectangle: new Rectangle( + (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth, + 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, + 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, + 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, + startY + (int)StaticUIValues.UpgradePanelSize.Y * index + (int)StaticUIValues.UpgradePanelSize.Y - 2, + (int)StaticUIValues.UpgradePanelSize.X, + 2)); + } + } +}
\ No newline at end of file |
