| | |
| | | using UnityEngine; |
| | | using UnityEngine.InputSystem; |
| | | using UnityEngine.SceneManagement; |
| | | using UnityEngine.Tilemaps; |
| | | |
| | | public class GameManager : SettingsManager |
| | | { |
| | |
| | | public GameObject healthTextPrefab; |
| | | public Canvas playerUI; |
| | | public Canvas pauseMenuUI; |
| | | public Tilemap tilemap; |
| | | |
| | | private void Awake() |
| | | { |
| | |
| | | // add listen events |
| | | CharacterEvents.characterDamaged += (CharacterTookDamange); |
| | | CharacterEvents.characterHealed += (CharacterHealed); |
| | | CharacterEvents.characterDrill += (CharacterDrill); |
| | | |
| | | } |
| | | |
| | |
| | | // remove listen events |
| | | CharacterEvents.characterDamaged -= (CharacterTookDamange); |
| | | CharacterEvents.characterHealed -= (CharacterHealed); |
| | | CharacterEvents.characterDrill -= (CharacterDrill); |
| | | } |
| | | |
| | | public void CharacterTookDamange(GameObject character, int damageReceived) |
| | |
| | | tmpText.text = healthRestored.ToString(); |
| | | |
| | | } |
| | | public void CharacterDrill(ContactPoint2D contact, DrillDirection drillDirection) |
| | | { |
| | | Vector3Int cellCoord = tilemap.transform.GetComponentInParent<GridLayout>().WorldToCell(contact.point); |
| | | switch(drillDirection) |
| | | { |
| | | case DrillDirection.Left: |
| | | cellCoord.x = cellCoord.x - 1; |
| | | break; |
| | | case DrillDirection.Right: |
| | | cellCoord.x = cellCoord.x + 1; |
| | | break; |
| | | case DrillDirection.Down: |
| | | cellCoord.y = cellCoord.y - 1; |
| | | break; |
| | | } |
| | | tilemap.SetTile(cellCoord, null); |
| | | } |
| | | public void GameLoaded() |
| | | { |
| | | pauseMenuUI.GetComponent<Animator>().SetTrigger("GameLoaded"); |