mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-07 19:05:54 +00:00
Game state manager and restored inventory
This commit is contained in:
parent
f0f49f8fb4
commit
a0ec2f3d74
27 changed files with 1283 additions and 1175 deletions
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.DebugMenu;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot.Collections;
|
||||
using DebugMapSelectData = Cirno.Scripts.Resources.DebugMenu.DebugMapSelectData;
|
||||
|
||||
|
|
@ -26,9 +27,9 @@ public partial class DebugMenu : MenuBase
|
|||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
if (GameManager.Instance is not null)
|
||||
if (GameStateManager.Instance is not null)
|
||||
{
|
||||
GameManager.Instance.GameStateChange += OnGameStateChange;
|
||||
GameStateManager.Instance.GameStateChange += OnGameStateChange;
|
||||
}
|
||||
|
||||
DefaultSelectedButton.GrabFocus();
|
||||
|
|
@ -63,7 +64,7 @@ public partial class DebugMenu : MenuBase
|
|||
{
|
||||
if (state is not GameState.Paused)
|
||||
{
|
||||
GameManager.Instance.GameStateChange -= OnGameStateChange;
|
||||
GameStateManager.Instance.GameStateChange -= OnGameStateChange;
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
|
|
@ -91,9 +92,9 @@ public partial class DebugMenu : MenuBase
|
|||
|
||||
private void ButtonOnPressed(DebugMapSelectResource scene)
|
||||
{
|
||||
if (GameManager.Instance is not null)
|
||||
if (GameStateManager.Instance is not null)
|
||||
{
|
||||
GameManager.Instance.Unpause();
|
||||
GameStateManager.Instance.Unpause();
|
||||
}
|
||||
GlobalState.Instance.GoToScene(scene.ScenePath, scene.StartData);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.UI;
|
||||
|
|
@ -29,7 +30,7 @@ public partial class InventoryMenu : TabContainer
|
|||
{
|
||||
if (Visible)
|
||||
{
|
||||
GameManager.Instance.ChangeState(GameState.Playing);
|
||||
GameStateManager.Instance.ChangeState(GameState.Playing);
|
||||
//CallDeferred(MethodName.HideInventory);
|
||||
}
|
||||
// else
|
||||
|
|
@ -55,9 +56,9 @@ public partial class InventoryMenu : TabContainer
|
|||
//ItemActivated += OnItemSelected;
|
||||
|
||||
// TODO: Move this on the game manager/controller side
|
||||
if (GameManager.Instance is not null)
|
||||
if (GameStateManager.Instance is not null)
|
||||
{
|
||||
GameManager.Instance.GameStateChange += state =>
|
||||
GameStateManager.Instance.GameStateChange += state =>
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Linq;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.UI;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class ItemsMenu : ItemList
|
||||
|
|
@ -53,7 +54,7 @@ public partial class ItemsMenu : ItemList
|
|||
InventoryManager.Instance.TryGetItem(item, out var lootItem);
|
||||
if (!lootItem.Item.Selectable) return;
|
||||
|
||||
GameManager.Instance.ChangeState(GameState.Playing);
|
||||
GameStateManager.Instance.ChangeState(GameState.Playing);
|
||||
|
||||
InventoryManager.Instance.UseItem(item);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.UI;
|
||||
|
||||
public partial class PauseMenu : Control
|
||||
{
|
||||
[Export]
|
||||
public StringName PauseActionName = "pause";
|
||||
|
||||
[ExportGroup("Scenes")]
|
||||
[Export]
|
||||
public string MainMenuScene { get; private set; }
|
||||
|
|
@ -43,9 +41,9 @@ public partial class PauseMenu : Control
|
|||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_gameManager.GameState == GameState.Paused && Input.IsActionJustPressed(PauseActionName))
|
||||
if (GameStateManager.Instance.GameState is GameState.Paused && GlobalInputManager.IsPauseJustPressed())
|
||||
{
|
||||
_gameManager.Unpause();
|
||||
GameStateManager.Instance.Unpause();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,12 +54,12 @@ public partial class PauseMenu : Control
|
|||
|
||||
private void ResumeButtonOnPressed()
|
||||
{
|
||||
_gameManager.Unpause();
|
||||
GameStateManager.Instance.Unpause();
|
||||
}
|
||||
|
||||
private void QuitButtonOnPressed()
|
||||
{
|
||||
_gameManager.Unpause();
|
||||
GameStateManager.Instance.Unpause();
|
||||
GlobalState.Instance.ChangeCursor(true);
|
||||
GlobalState.Instance.GotoScene(MainMenuScene);
|
||||
//GetTree().ChangeSceneToFile(MainMenuScene);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Linq;
|
||||
using Cirno.Scripts.Actors;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
|
|
@ -74,7 +75,7 @@ public partial class VendingMachineUi : CanvasLayer
|
|||
private void Exit()
|
||||
{
|
||||
GD.Print("Closing");
|
||||
GameManager.Instance.ChangeState(GameState.Playing);
|
||||
GameStateManager.Instance.ChangeState(GameState.Playing);
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue