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)); } } }