diff --git a/Entities/Archetypes/PlayerBuilder.cs b/Entities/Archetypes/PlayerBuilder.cs index 0d6d9ea..acfc0e6 100644 --- a/Entities/Archetypes/PlayerBuilder.cs +++ b/Entities/Archetypes/PlayerBuilder.cs @@ -15,11 +15,15 @@ internal static void Create(World world, Vector2 startPos) var playerComponent = new Player(); player.Set(playerComponent); - var ship = new Ship(HullType.Small, BoatColor.Dead, Team.November); + var ship = new Ship(HullType.Large, BoatColor.Dead, Team.November); ship.Sail = SailStatus.Closed; ship.Cannons.Add(CannonBuilder.Create(Utilities.Data.CannonType.TrustyRusty, BoatSide.Starboard, 1)); ship.Cannons.Add(CannonBuilder.Create(Utilities.Data.CannonType.TrustyRusty, BoatSide.Port, 1)); + ship.Cannons.Add(CannonBuilder.Create(Utilities.Data.CannonType.TrustyRusty, BoatSide.Starboard, 2)); + ship.Cannons.Add(CannonBuilder.Create(Utilities.Data.CannonType.TrustyRusty, BoatSide.Port, 2)); + ship.Cannons.Add(CannonBuilder.Create(Utilities.Data.CannonType.TrustyRusty, BoatSide.Starboard, 3)); + ship.Cannons.Add(CannonBuilder.Create(Utilities.Data.CannonType.TrustyRusty, BoatSide.Port, 3)); player.Set(ship); diff --git a/Scenes/Levels/Systems/InventoryManagementSystem.cs b/Scenes/Levels/Systems/InventoryManagementSystem.cs index 11f819b..dff7a4d 100644 --- a/Scenes/Levels/Systems/InventoryManagementSystem.cs +++ b/Scenes/Levels/Systems/InventoryManagementSystem.cs @@ -6,6 +6,7 @@ using NovemberPirates.Scenes.Levels.DataManagers; using NovemberPirates.Systems; using NovemberPirates.Utilities; +using NovemberPirates.Utilities.ContentData; using NovemberPirates.Utilities.Data; using Raylib_CsLo; using System.Numerics; @@ -27,9 +28,11 @@ internal override void UpdateNoCamera(World world) if (singleton.InventoryOpen) { var playerShip = playerEntity.Get(); + var realShipSprite = playerEntity.Get(); var inventoryFrame = new Vector2(Raylib.GetScreenWidth() / 2, Raylib.GetScreenHeight() / 2); Raylib.DrawText("Inventory", 0, 0, 24, Raylib.BLUE); + Raylib.DrawRectangle( (int)(Raylib.GetScreenWidth() / 2 - inventoryFrame.X / 2), (int)(Raylib.GetScreenHeight() / 2 - inventoryFrame.Y / 2), @@ -42,13 +45,52 @@ internal override void UpdateNoCamera(World world) var heightOffset = 180; var lineOffset = 30; + // Left Side + + var shipSprite = ShipSpriteBuilder.GenerateBoat(new BoatOptions(playerShip)); + shipSprite.RotationOffset = 180; + + var leftCenter = new Vector2(leftAlignment - inventoryFrame.X / 4, inventoryFrame.Y); + shipSprite.Position = leftCenter; + shipSprite.Scale = 4f; + shipSprite.Draw(); + + var shipChanged = false; + + for (int i = 0; i < playerShip.Cannons.Count; i++) + { + var cannon = playerShip.Cannons[i]; + + var rect = new Rectangle( + (int)(leftCenter.X + (cannon.Placement == BoatSide.Port ? 40 : -120)), + (int)(leftCenter.Y + (cannon.Position.Y * 4) - 130), + 70, 60); + + Raylib.DrawRectangleLines((int)rect.X, (int)rect.Y, (int)rect.width, (int)rect.height, Raylib.BLACK); + + if (Raylib.IsMouseButtonPressed(MouseButton.MOUSE_BUTTON_LEFT) && Raylib.CheckCollisionPointRec(Raylib.GetMousePosition(), rect)) + { + playerShip.Cannons.Remove(cannon); + InventoryManager.Instance.Inventory.Add(TradeableGoodsData.GetGood((TradeableGoodsNames)cannon.CannonType)); + shipChanged = true || shipChanged; + } + } + if (shipChanged) + { + Console.WriteLine("Ship Changed"); + var newboat = ShipSpriteBuilder.GenerateBoat(new BoatOptions(playerShip)); + newboat.Position = realShipSprite.Position; + newboat.Rotation = realShipSprite.Rotation; + playerEntity.Set(newboat); + } + Raylib.DrawText($"Crew: {playerShip.Crew} / {ShipData.Instance.Data[$"{playerShip.BoatType}{Stats.InitialCrew}"]}", rightAlignment, Raylib.GetScreenHeight() / 2 - heightOffset, 24, Raylib.WHITE); heightOffset -= lineOffset; Raylib.DrawText($"Hull: {playerShip.HullHealth} / {ShipData.Instance.Data[$"{playerShip.BoatType}{Stats.HullHealth}"]} ", rightAlignment, Raylib.GetScreenHeight() / 2 - heightOffset, 24, Raylib.WHITE); heightOffset -= lineOffset; - Raylib.DrawText($"Hull: {playerShip.SailHealth} / {ShipData.Instance.Data[$"{playerShip.BoatType}{Stats.SailHealth}"]} ", rightAlignment, Raylib.GetScreenHeight() / 2 - heightOffset, 24, Raylib.WHITE); + Raylib.DrawText($"Sails: {playerShip.SailHealth} / {ShipData.Instance.Data[$"{playerShip.BoatType}{Stats.SailHealth}"]} ", rightAlignment, Raylib.GetScreenHeight() / 2 - heightOffset, 24, Raylib.WHITE); heightOffset -= lineOffset; Raylib.DrawText($"Gold: {InventoryManager.Instance.Gold} ", rightAlignment, Raylib.GetScreenHeight() / 2 - heightOffset, 24, Raylib.WHITE); @@ -60,15 +102,6 @@ internal override void UpdateNoCamera(World world) Raylib.DrawText($"{invGroup.Key}: {invGroup.Count()}", rightAlignment, Raylib.GetScreenHeight() / 2 - heightOffset, 24, Raylib.WHITE); heightOffset -= lineOffset; } - - - var texture = ShipSpriteBuilder.GenerateBoat(new BoatOptions(playerShip)); - - Raylib.DrawTexturePro(texture.Texture, - new Rectangle(0, 0, texture.Texture.width, texture.Texture.height), - new Rectangle(inventoryFrame.X / 2 + 50, inventoryFrame.Y / 2 + 50, (inventoryFrame.X / 2) - 100, inventoryFrame.Y - 100), - new Vector2(0, 0), 0, Raylib.WHITE); - } } } diff --git a/Utilities/ContentData/ShipData.cs b/Utilities/ContentData/ShipData.cs index f9edbc0..0e456c2 100644 --- a/Utilities/ContentData/ShipData.cs +++ b/Utilities/ContentData/ShipData.cs @@ -73,7 +73,7 @@ internal void SaveToJson() { $"{HullType.Medium}{ShipAbilities.FullSail}", 10 }, { $"{HullType.Medium}{ShipAbilities.OneCannon}", 5 }, { $"{HullType.Medium}{ShipAbilities.TwoCannon}", 7 }, - + { $"{HullType.Medium}{Stats.RowingSpeed}", 100}, { $"{HullType.Medium}{Stats.TurningSpeed}", 100}, diff --git a/Utilities/ContentData/TradeableGoodsData.cs b/Utilities/ContentData/TradeableGoodsData.cs index da2f50b..a68b0c6 100644 --- a/Utilities/ContentData/TradeableGoodsData.cs +++ b/Utilities/ContentData/TradeableGoodsData.cs @@ -1,4 +1,6 @@ -namespace NovemberPirates.Utilities.ContentData +using NovemberPirates.Utilities.Data; + +namespace NovemberPirates.Utilities.ContentData { internal class TradeableGoodsData { @@ -19,6 +21,11 @@ private void LoadPrices() Goods.Add(TradeableGoodsNames.Weapons, new TradeableGood { Name = "Weapons", Price = 20 }); Goods.Add(TradeableGoodsNames.FineGoods, new TradeableGood { Name = "Fine Goods", Price = 40 }); Goods.Add(TradeableGoodsNames.Gems, new TradeableGood { Name = "Gems", Price = 80 }); + + //Cannon Prices + Goods.Add(TradeableGoodsNames.TrustyRusty, new TradeableGood { Name = "Trusty Rusty", Price = 100 }); + Goods.Add(TradeableGoodsNames.PvtPepper, new TradeableGood { Name = "Pvt Pepper", Price = 200 }); + Goods.Add(TradeableGoodsNames.BFC1700, new TradeableGood { Name = "BFC 1700", Price = 400 }); } static internal TradeableGood GetGood(TradeableGoodsNames name) @@ -32,8 +39,12 @@ internal class TradeableGood internal string Name; internal int Price; } + internal enum TradeableGoodsNames { + TrustyRusty = CannonType.TrustyRusty, + PvtPepper = CannonType.PvtPepper, + BFC1700 = CannonType.BFC1700, Lumber, Food, Material, @@ -41,4 +52,11 @@ internal enum TradeableGoodsNames FineGoods, Gems, } + + internal enum UpgradeOptions + { + HullArmor, // HP Increase + SailDurability, // Sail HP Increase + RudderStrength, // Turn Speed + } } diff --git a/Utilities/ShipSpriteBuilder.cs b/Utilities/ShipSpriteBuilder.cs index ec12e21..1bb1ea1 100644 --- a/Utilities/ShipSpriteBuilder.cs +++ b/Utilities/ShipSpriteBuilder.cs @@ -146,7 +146,14 @@ internal BoatOptions(Ship ship) : this(ship.BoatType, ship.BoatColor, ship.Sail, internal string ToKey() { - return $"{Hull}-{Color}-{Sails}-{Condition}"; + Cannons.Sort(delegate (Cannon x, Cannon y) + { + return (int)x.Placement * x.Row - (int)y.Placement * y.Row; + }); + var cannonKey = string.Join("", Cannons.Select(x => $"{(int)x.Placement}{x.Row}")); + + var key = $"{Hull}-{Color}-{Sails}-{Condition}-{cannonKey}"; + return key; } }