diff options
Diffstat (limited to 'Penguloon')
| -rw-r--r-- | Penguloon/Content/Content.mgcb | 12 | ||||
| -rw-r--r-- | Penguloon/Content/UI/darkred.png | bin | 0 -> 974 bytes | |||
| -rw-r--r-- | Penguloon/Content/UI/objectinfo.png | bin | 5198 -> 2158 bytes | |||
| -rw-r--r-- | Penguloon/ContentPathManager.cs | 5 | ||||
| -rw-r--r-- | Penguloon/Controls/ButtonUpgradeMenu.cs | 28 | ||||
| -rw-r--r-- | Penguloon/Controls/UpgradeMenu.cs | 166 | ||||
| -rw-r--r-- | Penguloon/Objects/ObjectBase.cs | 39 | ||||
| -rw-r--r-- | Penguloon/Objects/PenguinObject.cs | 3 | ||||
| -rw-r--r-- | Penguloon/Penguloon.csproj | 2 | ||||
| -rw-r--r-- | Penguloon/Resources/Resource.Designer.cs | 75 | ||||
| -rw-r--r-- | Penguloon/Resources/Values/Strings.xml | 3 | ||||
| -rw-r--r-- | Penguloon/Scenes/GameScene.cs | 116 | ||||
| -rw-r--r-- | Penguloon/StaticUIValues.cs | 3 |
13 files changed, 264 insertions, 188 deletions
diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index d6a91dc..0c412ff 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -937,3 +937,15 @@ /processorParam:TextureFormat=Color /build:UI/objectinfo-line.png +#begin UI/darkred.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:UI/darkred.png + diff --git a/Penguloon/Content/UI/darkred.png b/Penguloon/Content/UI/darkred.png Binary files differnew file mode 100644 index 0000000..ab10742 --- /dev/null +++ b/Penguloon/Content/UI/darkred.png diff --git a/Penguloon/Content/UI/objectinfo.png b/Penguloon/Content/UI/objectinfo.png Binary files differindex a7cb05b..45d61cd 100644 --- a/Penguloon/Content/UI/objectinfo.png +++ b/Penguloon/Content/UI/objectinfo.png diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs index 6b7b761..eebe42d 100644 --- a/Penguloon/ContentPathManager.cs +++ b/Penguloon/ContentPathManager.cs @@ -62,8 +62,9 @@ namespace Penguloon "UI/alertBackground", "UI/BtnResetPressed", "UI/BtnResetIdle", - "UI/objectinfo", - "UI/objectinfo-line", + "UI/darkred", + //"UI/objectinfo", + //"UI/objectinfo-line", "UI/speed", "UI/money", diff --git a/Penguloon/Controls/ButtonUpgradeMenu.cs b/Penguloon/Controls/ButtonUpgradeMenu.cs new file mode 100644 index 0000000..c612ac6 --- /dev/null +++ b/Penguloon/Controls/ButtonUpgradeMenu.cs @@ -0,0 +1,28 @@ +using Microsoft.Xna.Framework; +using Penguloon.Scenes; + +namespace Penguloon.Controls +{ + public class ButtonUpgradeMenu : ControlBase + { + public ButtonUpgradeMenu(SceneBase parentScene, Vector2 position, Vector2 size, string text) : base(parentScene, position, size) + { + this.BackgroundIdle = ContentManager.GetTexture("UI/darkred"); + this.BackgroundPressed = ContentManager.GetTexture("UI/red"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/red"); + this.Text = text; + + this.ForeColor = Color.White; + this.BorderColor = Color.Black; + this.BorderWidth = 2; + this.Font = ContentManager.GetFont(StaticUIValues.MenuFont); + + OnClick += Button_OnClick; + } + + private void Button_OnClick(object sender, ClickArgs e) + { + SoundManager.PlayClickSound(); + } + } +}
\ No newline at end of file diff --git a/Penguloon/Controls/UpgradeMenu.cs b/Penguloon/Controls/UpgradeMenu.cs new file mode 100644 index 0000000..6156018 --- /dev/null +++ b/Penguloon/Controls/UpgradeMenu.cs @@ -0,0 +1,166 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input.Touch; +using Penguloon.Levels; +using Penguloon.Objects; +using Penguloon.Scenes; +using System.Collections.Generic; +using System; +using Microsoft.Xna.Framework.Graphics; +namespace Penguloon.Controls +{ + public class UpgradeMenu : ControlBase + { + public LevelBase Level { get; set; } + + public ButtonUpgradeMenu UpgradeMenuSell { get; set; } + + public MessageBox SellConfirmationBox { get; set; } + + public UpgradeMenu(LevelBase level, SceneBase parentScene, Vector2 position, Vector2 size) : base(parentScene, position, size) + { + this.Level = level; + this.BackgroundIdle = ContentManager.GetTexture("UI/objectSelectionBackground"); + this.BackgroundPressed = ContentManager.GetTexture("UI/objectSelectionBackground"); + this.BackgroundDisabled = ContentManager.GetTexture("UI/objectSelectionBackground"); + + Vector2 MsgBoxSize = new Vector2(900, 550); + + UpgradeMenuSell = new ButtonUpgradeMenu(parentScene, + new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight), + new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), parentScene.Main.Resources.GetString(Resource.String.UpgradeMenuSell)); + + SellConfirmationBox = new MessageBox(parentScene, + new Vector2((StaticUIValues.ScreenViewport.X / 2) - (MsgBoxSize.X / 2), (StaticUIValues.ScreenViewport.Y / 2) - (MsgBoxSize.Y / 2)), + MsgBoxSize, parentScene.Main.Resources.GetString(Resource.String.IngameOptionsQuitConfirmation)); + + UpgradeMenuSell.OnClick += UpgradeMenuSell_OnClick; + } + + private void UpgradeMenuSell_OnClick(object sender, ClickArgs e) + { + SellConfirmationBox.State = IngameOptionsState.Show; + SellConfirmationBox.ShowTime = DateTime.Now; + } + + public override void Draw(float deltaTime) + { + //background + ParentScene.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)); + + if (Level.SelectedObject != null) + { + for (int i = 0; i < Level.SelectedObject.UpgradeList.Count; i++) + { + Level.SelectedObject.UpgradeList[i].Draw(ParentScene.Main.SpriteBatch, i); + } + } + + UpgradeMenuSell.Draw(deltaTime); + + //border + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"), + destinationRectangle: new Rectangle(Level.Map.MapWidth, + 0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y)); + + //border above button + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), + destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4, + (int)StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth, + (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth)); + + //border under text + ParentScene.Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), + destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4, + StaticUIValues.IngameUITextAreaHeight, (int)StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth - 5), StaticUIValues.BorderWidth)); + + ParentScene.DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), ParentScene.Main.Resources.GetString(Resource.String.IngameGold) + ": " + Level.Money, + 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); + + ParentScene.DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), ParentScene.Main.Resources.GetString(Resource.String.IngameWave) + ": " + Level.Map.WaveManager.CurrentWave.ToString(), + 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); + + ParentScene.DrawText(ContentManager.GetFont(StaticUIValues.IngameFont), ParentScene.Main.Resources.GetString(Resource.String.IngameHealth) + ": " + Level.Health, + 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); + + SellConfirmationBox.Draw(deltaTime); + } + + + public override void Update(float deltaTime, TouchLocation[] touchLocations) + { + UpgradeMenuSell.Update(deltaTime, touchLocations); + SellConfirmationBox.Update(deltaTime, touchLocations); + + int startY = StaticUIValues.IngameUITextAreaHeight + StaticUIValues.BorderWidth; + + if (Level.SelectedObject != null) + { + // for each available upgrade in selected object + for (int i = 0; i < Level.SelectedObject.UpgradeList.Count; i++) + { + Level.SelectedObject.UpgradeList[i].State = Objects.UpgradeState.Idle; + + Rectangle upgradeBox = new Rectangle( + (int)Level.Map.MapWidth, + startY + (int)StaticUIValues.UpgradePanelSize.Y * i, + (int)StaticUIValues.UpgradePanelSize.X, + (int)StaticUIValues.UpgradePanelSize.Y); + + for (int x = 0; x < touchLocations.Length; x++) + { + // if finger is released on upgrade box + if (touchLocations[x].State == TouchLocationState.Released) + { + if (upgradeBox.Contains(touchLocations[x].Position.ToPoint())) + { + // continue of we cant afford this upgrade + if (Level.SelectedObject.UpgradeList[i].Cost > Level.Money) + { + SoundManager.PlayUnavailableSound(); + continue; + } + + Level.SelectedObject.UpgradeList[i].Click(); + + // pay upgrade cost + Level.Money -= Level.SelectedObject.UpgradeList[i].Cost; + + // play buy sound here + SoundManager.PlayUpgradeSound(); + + // insert next upgrade if present + if (Level.SelectedObject.UpgradeList[i].NextUgrade != null) + { + Level.SelectedObject.UpgradeList.Insert(i, Level.SelectedObject.UpgradeList[i].NextUgrade); + + // remove clicked upgrade + if (Level.SelectedObject.UpgradeList.Count > i + 1) + Level.SelectedObject.UpgradeList.RemoveAt(i + 1); + } + else + // remove clicked upgrade + if (Level.SelectedObject.UpgradeList.Count > i) + Level.SelectedObject.UpgradeList.RemoveAt(i); + } + } + else + { + if (upgradeBox.Contains(touchLocations[x].Position.ToPoint())) + { + Level.SelectedObject.UpgradeList[i].State = Objects.UpgradeState.Pressed; + } + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/Penguloon/Objects/ObjectBase.cs b/Penguloon/Objects/ObjectBase.cs index c71b5e3..d1ed0d4 100644 --- a/Penguloon/Objects/ObjectBase.cs +++ b/Penguloon/Objects/ObjectBase.cs @@ -48,36 +48,14 @@ namespace Penguloon.Objects public List<ObjectUpgrade> UpgradeList { get; set; } = new List<ObjectUpgrade>(); + public SpriteFont InfoPanelFont { get; set; } + public ObjectBase(Vector2 position, Map map) { this.Map = map; this.Position = position; - this.AttackSpeedMSBase = AttackSpeedMS; - this.RangeBase = Range; - CreateUpgrades(); - - SetInfoPanel(); - } - - private void SetInfoPanel() - { - InfoPanelTexture = ContentManager.GetTexture("UI/objectinfo"); - InfoPanelLineTexture = ContentManager.GetTexture("UI/objectinfo-line"); - - // align right - if (Position.X < 450) - { - InfoPanelPos = new Vector2(Position.X + (TileSpanX * Map.TileWidth), Position.Y); - InfoPanelRotation = 3.14f; - } - // align left - else - { - InfoPanelPos = new Vector2(Position.X - StaticUIValues.ObjectInfoPanelSize.X, Position.Y); - InfoPanelRotation = 0f; - } } public ObjectBase(Map map) @@ -217,19 +195,6 @@ namespace Penguloon.Objects destinationRectangle: rangeCircleRec, origin: new Vector2(RangeCircle.Width / 2, RangeCircle.Height / 2)); } - - DrawInfoPanel(); - } - - private void DrawInfoPanel() - { - if (!Selected) return; - - Map.ParentScene.Main.SpriteBatch.Draw(InfoPanelTexture, destinationRectangle: - new Rectangle(InfoPanelPos.ToPoint(), StaticUIValues.ObjectInfoPanelSize.ToPoint())); - - Map.ParentScene.Main.SpriteBatch.Draw(InfoPanelLineTexture, destinationRectangle: - new Rectangle(Position.ToPoint(), StaticUIValues.ObjectInfoPanelLineSize.ToPoint()), rotation: InfoPanelRotation); } public abstract void DrawUnique(float deltaTime); diff --git a/Penguloon/Objects/PenguinObject.cs b/Penguloon/Objects/PenguinObject.cs index 5310262..de48e4c 100644 --- a/Penguloon/Objects/PenguinObject.cs +++ b/Penguloon/Objects/PenguinObject.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using Penguloon.Levels; using Penguloon.Projectiles; +using System; using System.Collections.Generic; namespace Penguloon.Objects @@ -37,7 +38,7 @@ namespace Penguloon.Objects public override void DrawUnique(float deltaTime) { - + } public override void UpdateUnique(float deltaTime) diff --git a/Penguloon/Penguloon.csproj b/Penguloon/Penguloon.csproj index 2181059..bb13d69 100644 --- a/Penguloon/Penguloon.csproj +++ b/Penguloon/Penguloon.csproj @@ -65,6 +65,7 @@ <Compile Include="ContentManager.cs" /> <Compile Include="ContentPathManager.cs" /> <Compile Include="Controls\Alert.cs" /> + <Compile Include="Controls\ButtonUpgradeMenu.cs" /> <Compile Include="Controls\ButtonReset.cs" /> <Compile Include="Controls\Button.cs" /> <Compile Include="Controls\ButtonIngame.cs" /> @@ -74,6 +75,7 @@ <Compile Include="Controls\MessageBox.cs" /> <Compile Include="Controls\ObjectSelector.cs" /> <Compile Include="Controls\SpeedButton.cs" /> + <Compile Include="Controls\UpgradeMenu.cs" /> <Compile Include="Enemies\BlueBalloon.cs" /> <Compile Include="Enemies\DarkRainbowBalloon.cs" /> <Compile Include="Enemies\EnemyBase.cs" /> diff --git a/Penguloon/Resources/Resource.Designer.cs b/Penguloon/Resources/Resource.Designer.cs index c4c15b9..2858436 100644 --- a/Penguloon/Resources/Resource.Designer.cs +++ b/Penguloon/Resources/Resource.Designer.cs @@ -90,20 +90,20 @@ namespace Penguloon // aapt resource value: 0x7f03000e public const int IngameHealth = 2130903054; - // aapt resource value: 0x7f03001b - public const int IngameNo = 2130903067; + // aapt resource value: 0x7f03001c + public const int IngameNo = 2130903068; // aapt resource value: 0x7f03000c public const int IngameOptions = 2130903052; - // aapt resource value: 0x7f030017 - public const int IngameOptionsContinue = 2130903063; - // aapt resource value: 0x7f030018 - public const int IngameOptionsQuit = 2130903064; + public const int IngameOptionsContinue = 2130903064; // aapt resource value: 0x7f030019 - public const int IngameOptionsQuitConfirmation = 2130903065; + public const int IngameOptionsQuit = 2130903065; + + // aapt resource value: 0x7f03001a + public const int IngameOptionsQuitConfirmation = 2130903066; // aapt resource value: 0x7f03000d public const int IngameStart = 2130903053; @@ -111,8 +111,8 @@ namespace Penguloon // aapt resource value: 0x7f030010 public const int IngameWave = 2130903056; - // aapt resource value: 0x7f03001a - public const int IngameYes = 2130903066; + // aapt resource value: 0x7f03001b + public const int IngameYes = 2130903067; // aapt resource value: 0x7f030005 public const int LevelSelectionBack = 2130903045; @@ -129,53 +129,56 @@ namespace Penguloon // aapt resource value: 0x7f030004 public const int MenuBtnSupport = 2130903044; + // aapt resource value: 0x7f030014 + public const int ObjectCannon = 2130903060; + // aapt resource value: 0x7f030013 - public const int ObjectCannon = 2130903059; + public const int ObjectGoldPenguin = 2130903059; - // aapt resource value: 0x7f030012 - public const int ObjectGoldPenguin = 2130903058; + // aapt resource value: 0x7f030015 + public const int ObjectHospital = 2130903061; - // aapt resource value: 0x7f030014 - public const int ObjectHospital = 2130903060; + // aapt resource value: 0x7f030017 + public const int ObjectKingPenguin = 2130903063; // aapt resource value: 0x7f030016 - public const int ObjectKingPenguin = 2130903062; + public const int ObjectMortar = 2130903062; - // aapt resource value: 0x7f030015 - public const int ObjectMortar = 2130903061; + // aapt resource value: 0x7f030012 + public const int ObjectPenguin = 2130903058; - // aapt resource value: 0x7f030011 - public const int ObjectPenguin = 2130903057; + // aapt resource value: 0x7f030025 + public const int StatsBestKills = 2130903077; - // aapt resource value: 0x7f030024 - public const int StatsBestKills = 2130903076; + // aapt resource value: 0x7f030026 + public const int StatsBestRound = 2130903078; - // aapt resource value: 0x7f030025 - public const int StatsBestRound = 2130903077; + // aapt resource value: 0x7f030024 + public const int StatsBestStatsTitle = 2130903076; - // aapt resource value: 0x7f030023 - public const int StatsBestStatsTitle = 2130903075; + // aapt resource value: 0x7f03001d + public const int StatsLevel = 2130903069; - // aapt resource value: 0x7f03001c - public const int StatsLevel = 2130903068; + // aapt resource value: 0x7f030022 + public const int StatsTotalGames = 2130903074; // aapt resource value: 0x7f030021 - public const int StatsTotalGames = 2130903073; + public const int StatsTotalKills = 2130903073; - // aapt resource value: 0x7f030020 - public const int StatsTotalKills = 2130903072; + // aapt resource value: 0x7f030023 + public const int StatsTotalMoneySpent = 2130903075; - // aapt resource value: 0x7f030022 - public const int StatsTotalMoneySpent = 2130903074; + // aapt resource value: 0x7f030020 + public const int StatsTotalStatsTitle = 2130903072; // aapt resource value: 0x7f03001f - public const int StatsTotalStatsTitle = 2130903071; + public const int SupportDonate = 2130903071; // aapt resource value: 0x7f03001e - public const int SupportDonate = 2130903070; + public const int SupportRate = 2130903070; - // aapt resource value: 0x7f03001d - public const int SupportRate = 2130903069; + // aapt resource value: 0x7f030011 + public const int UpgradeMenuSell = 2130903057; static String() { diff --git a/Penguloon/Resources/Values/Strings.xml b/Penguloon/Resources/Values/Strings.xml index aa5679f..a860f3f 100644 --- a/Penguloon/Resources/Values/Strings.xml +++ b/Penguloon/Resources/Values/Strings.xml @@ -26,6 +26,9 @@ <string name="IngameGold">Gold</string> <string name="IngameWave">Wave</string> + <!-- UpgradeMen --> + <string name="UpgradeMenuSell">Sell</string> + <!-- objects info text --> <string name="ObjectPenguin">This penguin does not like \n balloons</string> <string name="ObjectGoldPenguin">This gold penguin shoots \n even faster than regular \n penguins</string> diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs index 0f65f1a..3aa8511 100644 --- a/Penguloon/Scenes/GameScene.cs +++ b/Penguloon/Scenes/GameScene.cs @@ -20,6 +20,8 @@ namespace Penguloon.Scenes public ObjectSelector ObjectSeletor { get; set; } + public UpgradeMenu UpgradeMenu { get; set; } + public GameScene(Main main, LevelBase level) : base(main) { this.Level = level; @@ -28,7 +30,6 @@ namespace Penguloon.Scenes StartRoundBtn = new ButtonIngame(this, new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight), new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), Main.Resources.GetString(Resource.String.IngameStart)); - OptionsBtn = new ButtonIngame(this, new Vector2(Level.Map.MapWidth + StaticUIValues.BorderWidth, StaticUIValues.ScreenViewport.Y - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.IngameUIPlayButtonHeight - StaticUIValues.BorderWidth), new Vector2(StaticUIValues.ScreenViewport.X - (Level.Map.MapWidth + StaticUIValues.BorderWidth), StaticUIValues.IngameUIPlayButtonHeight), Main.Resources.GetString(Resource.String.IngameOptions)); @@ -47,6 +48,8 @@ namespace Penguloon.Scenes (StaticUIValues.ScreenViewport.Y / 2) - (StaticUIValues.IngameOptionsSize.Y / 2)), StaticUIValues.IngameOptionsSize); + UpgradeMenu = new UpgradeMenu(Level, this, new Vector2(), new Vector2()); + ChangeSpeedBtn.OnClick += ChangeSpeedBtn_OnClick; StartRoundBtn.OnClick += StartRoundBtn_OnClick; OptionsBtn.OnClick += OptionsBtn_OnClick; @@ -116,54 +119,13 @@ namespace Penguloon.Scenes // show upgrade menu of object is selected else { - DrawUpgradeUI(); + UpgradeMenu.Draw(deltaTime); } // draw "game over" controls here IngameEndStats.Draw(deltaTime); } - 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)); - - if (Level.SelectedObject != null) - { - for (int i = 0; i < Level.SelectedObject.UpgradeList.Count; i++) - { - Level.SelectedObject.UpgradeList[i].Draw(Main.SpriteBatch, i); - } - } - - //border - Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border"), - destinationRectangle: new Rectangle(Level.Map.MapWidth, - 0, StaticUIValues.BorderWidth, (int)StaticUIValues.ScreenViewport.Y)); - - //border under text - Main.SpriteBatch.Draw(ContentManager.GetTexture("UI/border-horizontal"), - destinationRectangle: new Rectangle(Level.Map.MapWidth + StaticUIValues.BorderWidth - 4, - StaticUIValues.IngameUITextAreaHeight, (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 + 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 + 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 + 5, 0), - new Vector2(StaticUIValues.ScreenViewport.X - Level.Map.MapWidth - StaticUIValues.BorderWidth, StaticUIValues.IngameUITextAreaHeight), - TextAllignment.LeftBottom, Color.White, Color.Black, 2); - } - private void DrawUI(float deltaTime) { //background @@ -229,7 +191,7 @@ namespace Penguloon.Scenes // update upgrade menu here else { - UpdateUpgradeMenu(touchLocations); + UpgradeMenu.Update(deltaTime, touchLocations); } if (StartRoundBtn.ControlState == ControlState.Disabled && !Level.Map.WaveManager.RoundActive && !Level.Finished) @@ -240,71 +202,5 @@ namespace Penguloon.Scenes this.Level.Update(deltaTime * Speed, touchLocations); } - - private void UpdateUpgradeMenu(TouchLocation[] touchLocations) - { - int startY = StaticUIValues.IngameUITextAreaHeight + StaticUIValues.BorderWidth; - - if (Level.SelectedObject != null) - { - // for each available upgrade in selected object - for (int i = 0; i < Level.SelectedObject.UpgradeList.Count; i++) - { - Level.SelectedObject.UpgradeList[i].State = Objects.UpgradeState.Idle; - - Rectangle upgradeBox = new Rectangle( - (int)Level.Map.MapWidth, - startY + (int)StaticUIValues.UpgradePanelSize.Y * i, - (int)StaticUIValues.UpgradePanelSize.X, - (int)StaticUIValues.UpgradePanelSize.Y); - - for (int x = 0; x < touchLocations.Length; x++) - { - // if finger is released on upgrade box - if (touchLocations[x].State == TouchLocationState.Released) - { - if (upgradeBox.Contains(touchLocations[x].Position.ToPoint())) - { - // continue of we cant afford this upgrade - if (Level.SelectedObject.UpgradeList[i].Cost > Level.Money) - { - SoundManager.PlayUnavailableSound(); - continue; - } - - Level.SelectedObject.UpgradeList[i].Click(); - - // pay upgrade cost - Level.Money -= Level.SelectedObject.UpgradeList[i].Cost; - - // play buy sound here - SoundManager.PlayUpgradeSound(); - - // insert next upgrade if present - if (Level.SelectedObject.UpgradeList[i].NextUgrade != null) - { - Level.SelectedObject.UpgradeList.Insert(i, Level.SelectedObject.UpgradeList[i].NextUgrade); - - // remove clicked upgrade - if (Level.SelectedObject.UpgradeList.Count > i + 1) - Level.SelectedObject.UpgradeList.RemoveAt(i + 1); - } - else - // remove clicked upgrade - if (Level.SelectedObject.UpgradeList.Count > i) - Level.SelectedObject.UpgradeList.RemoveAt(i); - } - } - else - { - if (upgradeBox.Contains(touchLocations[x].Position.ToPoint())) - { - Level.SelectedObject.UpgradeList[i].State = Objects.UpgradeState.Pressed; - } - } - } - } - } - } } }
\ No newline at end of file diff --git a/Penguloon/StaticUIValues.cs b/Penguloon/StaticUIValues.cs index d7910a5..7df454d 100644 --- a/Penguloon/StaticUIValues.cs +++ b/Penguloon/StaticUIValues.cs @@ -45,8 +45,7 @@ namespace Penguloon public static Vector2 UpgradePanelSize { get; set; } - public static Vector2 ObjectInfoPanelSize { get; set; } = new Vector2(100, 120); - public static Vector2 ObjectInfoPanelLineSize { get; set; } = new Vector2(50, 20); + public static Vector2 ObjectInfoPanelSize { get; set; } = new Vector2(220, 300); public static void Initialize(Main main) { |
