miepzerino
2025-03-30 884103d805270bd776b7a485d9431401c0c05594
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;
@@ -24,6 +26,7 @@
    private void Awake()
    {
        GameIsPaused = false;
        SoundManager.instance.ChangeMusic(SoundName.MusicHappy);
        LoadTileMaps(SaveSystem.isGameLoaded);
    }
@@ -32,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)
        {
@@ -67,7 +70,7 @@
    }
    public void GameLoaded()
    {
        pauseMenuUI.GetComponent<PauseMenu>().Resume();
        ResumeGame();
        pauseMenuUI.GetComponent<Animator>().SetTrigger("GameLoaded");
    }
@@ -139,9 +142,13 @@
                cellWorldPosition.y += 0.5f;
                if (tileGameObject?.GetComponent<Dropable>()?.isDropable ?? false)
                {
                    Instantiate(tileGameObject?.GetComponent<Dropable>().dropable, cellWorldPosition, Quaternion.identity, pickups.transform);
                    //Debug.Log(.name);
                    // 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);
@@ -155,4 +162,20 @@
    }
    #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
}