From 6996be0fc143085b6aa459f2eb7b288ac1617c0b Mon Sep 17 00:00:00 2001 From: aldrikboy Date: Tue, 16 Jan 2018 14:49:40 +0100 Subject: upgrade sounds --- Penguloon/Content/Content.mgcb | 48 +++++++++++++++++++++++++++++++ Penguloon/Content/Sounds/unavailable.wav | Bin 0 -> 28806 bytes Penguloon/Content/Sounds/upgrade.wav | Bin 0 -> 67196 bytes Penguloon/Content/UI/objectinfo-line.png | Bin 0 -> 3258 bytes Penguloon/Content/UI/objectinfo.png | Bin 0 -> 5198 bytes Penguloon/Content/UI/radar.png | Bin 0 -> 10677 bytes Penguloon/ContentPathManager.cs | 5 ++++ Penguloon/Levels/LevelBase.cs | 2 +- Penguloon/Objects/ObjectBase.cs | 33 +++++++++++++++++++++ Penguloon/Objects/ObjectUpgrade.cs | 15 ++++++++-- Penguloon/Objects/PenguinObject.cs | 4 +-- Penguloon/Scenes/GameScene.cs | 16 +++++++---- Penguloon/SoundManager.cs | 28 ++++++++++++++++++ Penguloon/StaticUIValues.cs | 3 ++ 14 files changed, 144 insertions(+), 10 deletions(-) create mode 100644 Penguloon/Content/Sounds/unavailable.wav create mode 100644 Penguloon/Content/Sounds/upgrade.wav create mode 100644 Penguloon/Content/UI/objectinfo-line.png create mode 100644 Penguloon/Content/UI/objectinfo.png create mode 100644 Penguloon/Content/UI/radar.png (limited to 'Penguloon') diff --git a/Penguloon/Content/Content.mgcb b/Penguloon/Content/Content.mgcb index 4ccf085..d6a91dc 100644 --- a/Penguloon/Content/Content.mgcb +++ b/Penguloon/Content/Content.mgcb @@ -889,3 +889,51 @@ /processorParam:TextureFormat=Color /build:UI/money.png +#begin Sounds/upgrade.wav +/importer:WavImporter +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Sounds/upgrade.wav + +#begin Sounds/unavailable.wav +/importer:WavImporter +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Sounds/unavailable.wav + +#begin UI/radar.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/radar.png + +#begin UI/objectinfo.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/objectinfo.png + +#begin UI/objectinfo-line.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/objectinfo-line.png + diff --git a/Penguloon/Content/Sounds/unavailable.wav b/Penguloon/Content/Sounds/unavailable.wav new file mode 100644 index 0000000..6528b33 Binary files /dev/null and b/Penguloon/Content/Sounds/unavailable.wav differ diff --git a/Penguloon/Content/Sounds/upgrade.wav b/Penguloon/Content/Sounds/upgrade.wav new file mode 100644 index 0000000..151462d Binary files /dev/null and b/Penguloon/Content/Sounds/upgrade.wav differ diff --git a/Penguloon/Content/UI/objectinfo-line.png b/Penguloon/Content/UI/objectinfo-line.png new file mode 100644 index 0000000..47f6108 Binary files /dev/null and b/Penguloon/Content/UI/objectinfo-line.png differ diff --git a/Penguloon/Content/UI/objectinfo.png b/Penguloon/Content/UI/objectinfo.png new file mode 100644 index 0000000..a7cb05b Binary files /dev/null and b/Penguloon/Content/UI/objectinfo.png differ diff --git a/Penguloon/Content/UI/radar.png b/Penguloon/Content/UI/radar.png new file mode 100644 index 0000000..d8fabe7 Binary files /dev/null and b/Penguloon/Content/UI/radar.png differ diff --git a/Penguloon/ContentPathManager.cs b/Penguloon/ContentPathManager.cs index 0d1ed6d..6b7b761 100644 --- a/Penguloon/ContentPathManager.cs +++ b/Penguloon/ContentPathManager.cs @@ -62,11 +62,14 @@ namespace Penguloon "UI/alertBackground", "UI/BtnResetPressed", "UI/BtnResetIdle", + "UI/objectinfo", + "UI/objectinfo-line", "UI/speed", "UI/money", "UI/heart", "UI/explosion", + "UI/radar", "SplashArt/locked", "SplashArt/1", @@ -104,6 +107,8 @@ namespace Penguloon "Sounds/gameover", "Sounds/pop", "Sounds/placeobject", + "Sounds/upgrade", + "Sounds/unavailable", }; public static List TexturePathsPreLoad { get; set; } = new List() diff --git a/Penguloon/Levels/LevelBase.cs b/Penguloon/Levels/LevelBase.cs index a5afa43..93622c5 100644 --- a/Penguloon/Levels/LevelBase.cs +++ b/Penguloon/Levels/LevelBase.cs @@ -185,7 +185,7 @@ namespace Penguloon.Levels Map.Objects[x].Selected = false; } } - else if (tileX < StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth) + else if (tileX < Map.MapWidth) { Map.Objects[x].Selected = false; } diff --git a/Penguloon/Objects/ObjectBase.cs b/Penguloon/Objects/ObjectBase.cs index e5d9fe5..ee2b04c 100644 --- a/Penguloon/Objects/ObjectBase.cs +++ b/Penguloon/Objects/ObjectBase.cs @@ -11,13 +11,22 @@ namespace Penguloon.Objects public abstract class ObjectBase { public int AttackSpeedMS { get; set; } + public int AttackSpeedMSBase { get; set; } + public DateTime LastAttack { get; set; } public float Range { get; set; } + public float RangeBase { get; set; } public Texture2D Texture { get; set; } public Texture2D TextureBase { get; set; } public Texture2D RangeCircle { get; set; } + + public Texture2D InfoPanelTexture { get; set; } + public Texture2D InfoPanelLineTexture { get; set; } + public Vector2 InfoPanelPos { get; set; } + public float InfoPanelRotation { get; set; } = -0f; + public float Rotation { get; set; } = -0f; public Vector2 Position { get; set; } @@ -44,7 +53,31 @@ namespace Penguloon.Objects 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"); + + InfoPanelPos = new Vector2(); + + // alight right + if (Position.X < 450) + { + + } + // alight left + else + { + + } } public ObjectBase(Map map) diff --git a/Penguloon/Objects/ObjectUpgrade.cs b/Penguloon/Objects/ObjectUpgrade.cs index 278a1fb..a72edd4 100644 --- a/Penguloon/Objects/ObjectUpgrade.cs +++ b/Penguloon/Objects/ObjectUpgrade.cs @@ -21,6 +21,7 @@ namespace Penguloon.Objects PopCount, Speed, Money, + Range, } public enum UpgradeState @@ -66,6 +67,7 @@ namespace Penguloon.Objects 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; + case UpgradeType.Range: Icon = ContentManager.GetTexture("UI/radar"); break; } } @@ -80,6 +82,10 @@ namespace Penguloon.Objects SpriteFont font = ContentManager.GetFont(StaticUIValues.IngameFont); int textHeight = (int)font.MeasureString(Text).Y; + int textWidth = (int)font.MeasureString(Text).X; + + int costHeight = (int)font.MeasureString("$" + Cost.ToString() + ",-").Y; + int costWidth = (int)font.MeasureString("$" + Cost.ToString() + ",-").X; if (State == UpgradeState.Idle) spriteBatch.Draw(Background, destinationRectangle: new Rectangle( @@ -101,8 +107,13 @@ namespace Penguloon.Objects (int)StaticUIValues.UpgradePanelSize.Y / 2)); spriteBatch.DrawString(ContentManager.GetFont(StaticUIValues.IngameFont), - Text, new Vector2(ParentLevel.Map.MapWidth + StaticUIValues.BorderWidth + 90, - startY + ((int)StaticUIValues.UpgradePanelSize.Y * index) + (int)(StaticUIValues.UpgradePanelSize.Y / 2) - textHeight / 2), + Text, new Vector2(StaticUIValues.ScreenViewport.X - 20 - textWidth, + startY + ((int)StaticUIValues.UpgradePanelSize.Y * index) + (int)(StaticUIValues.UpgradePanelSize.Y / 3) - textHeight / 2), + Color.FromNonPremultiplied(20, 20, 20, 255)); + + spriteBatch.DrawString(ContentManager.GetFont(StaticUIValues.IngameFont), + "$" + Cost.ToString() + ",-", new Vector2(StaticUIValues.ScreenViewport.X - 20 - costWidth, + startY + ((int)StaticUIValues.UpgradePanelSize.Y * index) + (int)(StaticUIValues.UpgradePanelSize.Y / 2) + (int)(StaticUIValues.UpgradePanelSize.Y / 4) - costHeight / 2), Color.FromNonPremultiplied(20, 20, 20, 255)); spriteBatch.Draw(ContentManager.GetTexture("UI/objectSelectionBorder"), diff --git a/Penguloon/Objects/PenguinObject.cs b/Penguloon/Objects/PenguinObject.cs index 7d3f259..5310262 100644 --- a/Penguloon/Objects/PenguinObject.cs +++ b/Penguloon/Objects/PenguinObject.cs @@ -29,10 +29,10 @@ namespace Penguloon.Objects public override void CreateUpgrades() { - ObjectUpgrade upg = new ObjectUpgrade(100, UpgradeType.PopCount, "+2 pop", null, Map.Level); + ObjectUpgrade upg = new ObjectUpgrade(12341234, 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)); + UpgradeList.Add(new ObjectUpgrade(100, UpgradeType.Range, "+15 Range", null, Map.Level)); } public override void DrawUnique(float deltaTime) diff --git a/Penguloon/Scenes/GameScene.cs b/Penguloon/Scenes/GameScene.cs index ac29989..0f65f1a 100644 --- a/Penguloon/Scenes/GameScene.cs +++ b/Penguloon/Scenes/GameScene.cs @@ -2,7 +2,6 @@ using Microsoft.Xna.Framework.Input.Touch; using Penguloon.Controls; using Penguloon.Levels; -using Penguloon.Scenes; using System; namespace Penguloon.Scenes @@ -253,11 +252,8 @@ namespace Penguloon.Scenes { Level.SelectedObject.UpgradeList[i].State = Objects.UpgradeState.Idle; - // continue of we cant afford this upgrade - if (Level.SelectedObject.UpgradeList[i].Cost > Level.Money) continue; - Rectangle upgradeBox = new Rectangle( - (int)StaticUIValues.ScreenViewport.X - StaticUIValues.IngameUIWidth, + (int)Level.Map.MapWidth, startY + (int)StaticUIValues.UpgradePanelSize.Y * i, (int)StaticUIValues.UpgradePanelSize.X, (int)StaticUIValues.UpgradePanelSize.Y); @@ -269,11 +265,21 @@ namespace Penguloon.Scenes { 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) { diff --git a/Penguloon/SoundManager.cs b/Penguloon/SoundManager.cs index 92ba973..ddc32fa 100644 --- a/Penguloon/SoundManager.cs +++ b/Penguloon/SoundManager.cs @@ -10,6 +10,8 @@ namespace Penguloon public static SoundEffectInstance BtnClick3 { get; set; } public static SoundEffectInstance PlaceObject { get; set; } public static SoundEffectInstance GameOver { get; set; } + public static SoundEffectInstance Upgrade { get; set; } + public static SoundEffectInstance Unavailable { get; set; } public static void StartBaseline() { @@ -85,6 +87,32 @@ namespace Penguloon GameOver.Play(); } + public static void PlayUpgradeSound() + { + if (Upgrade == null) + { + SoundEffect effect = ContentManager.GetSound("Sounds/upgrade"); + Upgrade = effect.CreateInstance(); + Upgrade.Volume = 1f; + Upgrade.IsLooped = false; + } + + Upgrade.Play(); + } + + public static void PlayUnavailableSound() + { + if (Unavailable == null) + { + SoundEffect effect = ContentManager.GetSound("Sounds/unavailable"); + Unavailable = effect.CreateInstance(); + Unavailable.Volume = 1f; + Unavailable.IsLooped = false; + } + + Unavailable.Play(); + } + public static void PlayBalloonPopSound() { SoundEffect popEffect = ContentManager.GetSound("Sounds/pop"); diff --git a/Penguloon/StaticUIValues.cs b/Penguloon/StaticUIValues.cs index 230b29c..bfce477 100644 --- a/Penguloon/StaticUIValues.cs +++ b/Penguloon/StaticUIValues.cs @@ -45,6 +45,9 @@ namespace Penguloon public static Vector2 UpgradePanelSize { get; set; } + public static Vector2 ObjectInfoPanelSize { get; set; } = new Vector2(350, 400); + public static Vector2 ObjectInfoPanelLineSize { get; set; } = new Vector2(350, 100); + public static void Initialize(Main main) { ScreenViewport = main.GraphicsDevice.Viewport.Bounds.Size.ToVector2(); -- cgit v1.2.3-70-g09d2