| | |
| | | |
| | | public class GameManager : SettingsManager |
| | | { |
| | | public static bool GameIsPaused = false; |
| | | |
| | | public GameObject damageTextPrefab; |
| | | public GameObject healthTextPrefab; |
| | | public Canvas playerUI; |
| | |
| | | |
| | | private void Awake() |
| | | { |
| | | GameIsPaused = false; |
| | | SoundManager.instance.ChangeMusic(SoundName.MusicHappy); |
| | | LoadTileMaps(SaveSystem.isGameLoaded); |
| | | } |
| | |
| | | private void LoadTileMaps(bool loadFromSave) |
| | | { |
| | | generateTileMap = tilemap.GetComponent<GenerateTileMap>(); |
| | | pauseMenuUI.GetComponent<PauseMenu>().Pause(); |
| | | PauseGame(); |
| | | levelChanger.GetComponent<Animator>().SetBool("SceneLoading", true); |
| | | if (loadFromSave) |
| | | { |
| | |
| | | } |
| | | public void GameLoaded() |
| | | { |
| | | pauseMenuUI.GetComponent<PauseMenu>().Resume(); |
| | | ResumeGame(); |
| | | pauseMenuUI.GetComponent<Animator>().SetTrigger("GameLoaded"); |
| | | } |
| | | |
| | |
| | | if (tileGameObject?.GetComponent<Dropable>()?.isDropable ?? false) |
| | | { |
| | | // Change no drops, only inventory |
| | | Instantiate(tileGameObject?.GetComponent<Dropable>().dropable, cellWorldPosition, Quaternion.identity, pickups.transform); |
| | | //Debug.Log(.name); |
| | | |
| | | //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); |
| | |
| | | } |
| | | #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 |
| | | } |