public void Initialize(PlayerData data) { Instance = this; _playerData = data; OnShovelsChange?.Invoke(_playerData.Shovels); OnTreasuresChange?.Invoke(_playerData.Treasures); if (_playerData.Treasures >= _playerData.TargetTreasures) { OnGameEnded?.Invoke(); } }
bool IPlayer.TryUseShovel() { if (_playerData.Treasures >= _playerData.TargetTreasures) { return(false); } if (_playerData.Shovels > 0) { _playerData.Shovels--; OnShovelsChange?.Invoke(_playerData.Shovels); DataManager.Instance.SetPlayerData(_playerData); return(true); } else { OnGameEnded?.Invoke(); return(false); } }