Skip to content

Commit

Permalink
WIP Inventory step 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nhawdge committed Feb 4, 2024
1 parent 814ceac commit ca16e6e
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 7 deletions.
11 changes: 9 additions & 2 deletions NovemberPiratesEngine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NovemberPirates.Scenes;
using NovemberPirates.Scenes.Menus.MainMenu;
using NovemberPirates.Utilities;
using NovemberPirates.Utilities.Data;
using Raylib_CsLo;

Expand All @@ -19,8 +20,8 @@ public void StartGame()
//Raylib.SetConfigFlags(ConfigFlags.FLAG_WINDOW_TOPMOST);
//Raylib.SetConfigFlags(ConfigFlags.FLAG_WINDOW_MAXIMIZED);
//Raylib.SetConfigFlags(ConfigFlags.FLAG_WINDOW_UNDECORATED);
Raylib.InitWindow(0,0, "November Pirates");

Raylib.InitWindow(0, 0, "November Pirates");

var monitor = Raylib.GetCurrentMonitor();
var width = Raylib.GetMonitorWidth(monitor);
Expand All @@ -31,6 +32,12 @@ public void StartGame()
Raylib.SetTargetFPS(60);
Raylib.InitAudioDevice();
Raylib.SetExitKey(0);

if (SettingsManager.Instance.Settings[SettingsManager.SettingKeys.Fullscreen] == 1)
{
Raylib.ToggleFullscreen();
}

Camera = new Camera2D
{
zoom = 1.0f,
Expand Down
14 changes: 14 additions & 0 deletions Scenes/Levels/DataManagers/InventoryManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace NovemberPirates.Scenes.Levels.DataManagers
{
internal class InventoryManager
{
private InventoryManager() { }

public static InventoryManager Instance = new();

public long Gold = 0;
public long Food = 0;
public long Lumber = 0;

}
}
23 changes: 23 additions & 0 deletions Scenes/Levels/Systems/EnemyAISystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Arch.Core;
using NovemberPirates.Systems;

namespace NovemberPirates.Scenes.Levels.Systems
{
internal class EnemyAISystem : GameSystem
{
internal override void Update(World world)
{

}
}

public enum EnemyGoals
{
Sailing,
Trading,
Repairing,
Escaping,
GetReinforcements,
Fighting
}
}
35 changes: 33 additions & 2 deletions Scenes/Levels/Systems/InventorySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
using Arch.Core.Extensions;
using NovemberPirates.Components;
using NovemberPirates.Extensions;
using NovemberPirates.Scenes.Levels.Components;
using NovemberPirates.Scenes.Levels.DataManagers;
using NovemberPirates.Systems;
using NovemberPirates.Utilities;
using Raylib_CsLo;
using System.Numerics;

namespace NovemberPirates.Scenes.Levels.Systems
{
Expand All @@ -16,11 +20,38 @@ internal override void UpdateNoCamera(World world)
var singletonEntity = world.QueryFirst<Singleton>();
var singleton = singletonEntity.Get<Singleton>();

var playerEntity = world.QueryFirst<Player>();
var player = playerEntity.Get<Player>();


if (singleton.InventoryOpen)
{
Console.WriteLine("Inventory Open");
var inventoryFrame = new Vector2(Raylib.GetScreenWidth() / 2, Raylib.GetScreenHeight() / 2);

Raylib.DrawText("Inventory", 0, 0, 24, Raylib.BLUE);
Raylib.DrawRectangle(Raylib.GetScreenWidth() / 2 - 200, Raylib.GetScreenHeight() / 2 - 200, 400, 400, Raylib.Fade(Raylib.BLACK, 0.8f));
Raylib.DrawRectangle(
(int)(Raylib.GetScreenWidth() / 2 - inventoryFrame.X / 2),
(int)(Raylib.GetScreenHeight() / 2 - inventoryFrame.Y / 2),
(int)inventoryFrame.X,
(int)inventoryFrame.Y,
Raylib.Fade(Raylib.BLACK, 0.8f));

var rightAlignment = Raylib.GetScreenWidth() / 2 + 100;
var leftAlignment = inventoryFrame.X + 10;

Raylib.DrawText($"Gold: {InventoryManager.Instance.Gold} ", rightAlignment, Raylib.GetScreenHeight() / 2 - 180, 24, Raylib.WHITE);
Raylib.DrawText($"Lumber: {InventoryManager.Instance.Lumber} ", rightAlignment, Raylib.GetScreenHeight() / 2 - 150, 24, Raylib.WHITE);
Raylib.DrawText($"Food: {InventoryManager.Instance.Food} ", rightAlignment, Raylib.GetScreenHeight() / 2 - 120, 24, Raylib.WHITE);

var playerShip = playerEntity.Get<Ship>();

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

}
}
}
Expand Down
5 changes: 2 additions & 3 deletions Scenes/Levels/Systems/PickupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using NovemberPirates.Components;
using NovemberPirates.Extensions;
using NovemberPirates.Scenes.Levels.Components;
using NovemberPirates.Scenes.Levels.DataManagers;
using NovemberPirates.Systems;
using Raylib_CsLo;
using System.Numerics;
Expand Down Expand Up @@ -54,11 +55,9 @@ internal override void Update(World world)
if (playerSprite.Position.DistanceTo(sprite.Position) < 50)
{
world.Destroy(entity);
var playerShip = player.Get<Ship>();
playerShip.Wood += 1;
InventoryManager.Instance.Lumber += 1;
world.Create<AudioEvent>().Set(new AudioEvent() { Key = Utilities.AudioKey.CollectWood, Position = sprite.Position });
}

});
}
}
Expand Down

0 comments on commit ca16e6e

Please sign in to comment.