From 884103d805270bd776b7a485d9431401c0c05594 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sun, 30 Mar 2025 18:50:13 +0000
Subject: [PATCH] #16 added ores to player inventory #14 show inventory in UI
---
Assets/Scripts/Managers/GameManager.cs | 55 +++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs
index 13f8eb3..e0670dd 100644
--- a/Assets/Scripts/Managers/GameManager.cs
+++ b/Assets/Scripts/Managers/GameManager.cs
@@ -10,6 +10,8 @@
public class GameManager : SettingsManager
{
+ public static bool GameIsPaused = false;
+
public GameObject damageTextPrefab;
public GameObject healthTextPrefab;
public Canvas playerUI;
@@ -20,9 +22,11 @@
public GenerateTileMap generateTileMap;
[NonSerialized]
public List<Vector3Int> destroyedTiles = new List<Vector3Int>();
+ public GameObject pickups;
private void Awake()
{
+ GameIsPaused = false;
SoundManager.instance.ChangeMusic(SoundName.MusicHappy);
LoadTileMaps(SaveSystem.isGameLoaded);
}
@@ -31,7 +35,7 @@
private void LoadTileMaps(bool loadFromSave)
{
generateTileMap = tilemap.GetComponent<GenerateTileMap>();
- pauseMenuUI.GetComponent<PauseMenu>().Pause();
+ PauseGame();
levelChanger.GetComponent<Animator>().SetBool("SceneLoading", true);
if (loadFromSave)
{
@@ -66,7 +70,7 @@
}
public void GameLoaded()
{
- pauseMenuUI.GetComponent<PauseMenu>().Resume();
+ ResumeGame();
pauseMenuUI.GetComponent<Animator>().SetTrigger("GameLoaded");
}
@@ -129,14 +133,49 @@
//Debug.Log(tilemap.HasTile(cellCoord));
if (tilemap.HasTile(cellCoord))
{
- tilemap.SetTile(cellCoord, null);
- destroyedTiles.Add(cellCoord);
- Vector3 moveToPosition = grid.CellToWorld(cellCoord);
- moveToPosition.x += 0.5f;
- moveToPosition.y += 0.5f;
- CharacterEvents.characterDrillingToPosition.Invoke(moveToPosition);
+ GameObject tileGameObject = tilemap.GetInstantiatedObject(cellCoord);
+ if (tileGameObject?.GetComponent<Drillable>()?.isDrillable ?? false)
+ {
+ Vector3 cellWorldPosition = grid.CellToWorld(cellCoord);
+ // middle of tile
+ cellWorldPosition.x += 0.5f;
+ cellWorldPosition.y += 0.5f;
+ if (tileGameObject?.GetComponent<Dropable>()?.isDropable ?? false)
+ {
+ // Change no drops, only inventory
+ //Instantiate(tileGameObject?.GetComponent<Dropable>().dropable, cellWorldPosition, Quaternion.identity, pickups.transform);
+ Inventory playerInventory = contact.rigidbody.gameObject.GetComponent<Inventory>();
+ if (playerInventory != null)
+ {
+ playerInventory.AddItem(tileGameObject?.GetComponent<Dropable>().dropable);
+ }
+ }
+ tilemap.SetTile(cellCoord, null);
+ destroyedTiles.Add(cellCoord);
+ CharacterEvents.characterDrillingToPosition.Invoke(cellWorldPosition, drillDirection);
+ }
+ else
+ {
+ //CharacterEvents.characterDrillingToPositionAbort.Invoke(moveToPosition);
+ }
}
}
#endregion
+
+ #region GameState
+
+ public static void PauseGame()
+ {
+ Time.timeScale = 0f;
+ GameIsPaused = true;
+ //GameStateEvents.gameStatePauseChanged.Invoke(GameIsPaused);
+ }
+ public static void ResumeGame()
+ {
+ Time.timeScale = 1f;
+ GameIsPaused = false;
+ //GameStateEvents.gameStatePauseChanged.Invoke(GameIsPaused);
+ }
+ #endregion
}
--
Gitblit v1.10.0