private static void LoadGameData(LocalData data) { LocalSaveSystem.SaveLocalData(data); var charactersData = data.Characters; var platformsData = data.Platforms; var gameData = DataManager.Instance.GameData; foreach (var characterData in charactersData) { var character = gameData.Characters.FirstOrDefault(c => c.Id == characterData.Id); if (character != null) { character.IsPurchased = characterData.IsPurchased; character.IsSelected = characterData.IsSelected; character.IsEffectEnabled = characterData.IsEffectEnabled; } } foreach (var platformData in platformsData) { var platform = gameData.Platforms.FirstOrDefault(p => p.Id == platformData.Id); if (platform != null) { platform.IsPurchased = platformData.IsPurchased; platform.IsActive = platformData.IsActive; } } gameData.HighScore = data.HighScore; gameData.Coins = data.Coins; }
public void SaveMusicVolumeChanges() { var data = LocalSaveSystem.LoadLocalData(); data.Settings.MusicVolume = musicSlider.value; LocalSaveSystem.SaveLocalData(data); }
public void SaveSoundsVolumeChanges() { var data = LocalSaveSystem.LoadLocalData(); data.Settings.SoundsVolume = soundsSlider.value; LocalSaveSystem.SaveLocalData(data); }
private void ToggleShadows(bool value) { var localData = LocalSaveSystem.LoadLocalData(); localData.Settings.Shadows = value; QualitySettings.shadows = value ? ShadowQuality.HardOnly : ShadowQuality.Disable; LocalSaveSystem.SaveLocalData(localData); }
private void ToggleAntialiasing(bool value) { var localData = LocalSaveSystem.LoadLocalData(); localData.Settings.Antialiasing = value; QualitySettings.antiAliasing = value ? (int)AntiAliasing.Enabled : (int)AntiAliasing.Disabled; LocalSaveSystem.SaveLocalData(localData); }
private void TogglePlatformActive(bool value) { var localData = LocalSaveSystem.LoadLocalData(); localData.Platforms.First(p => p.Id == _currentPlatform.Id).IsActive = value; _currentPlatform.IsActive = value; LocalSaveSystem.SaveLocalData(localData); PlatformsPageEventSystem.Instance.ActivatePlatform(_currentPlatform); }
private void ToggleCharacterEffect(bool value) { var localData = LocalSaveSystem.LoadLocalData(); localData.Characters.First(c => c.Id == _currentCharacter.Id).IsEffectEnabled = value; _currentCharacter.IsEffectEnabled = value; LocalSaveSystem.SaveLocalData(localData); _currentCharacter.Prefab.GetComponent <Effect>().enabled = value; platformWithPlayer.transform.GetChild(0).GetComponent <Effect>().enabled = value; }
private void ValidatePurchase() { var totalCoins = _gameData.Coins; var characterPrice = _currentCharacter.Price; if (totalCoins >= characterPrice) { var localData = LocalSaveSystem.LoadLocalData(); localData.SaveTime = DateTime.Now.Ticks; localData.Coins -= characterPrice; _gameData.Coins -= characterPrice; localData.Characters.First(c => c.Id == _currentCharacter.Id).IsPurchased = true; _currentCharacter.IsPurchased = true; if (PlayGamesServices.IsAuthenticated && InternetConnection.Available()) { PlayGamesServices.SaveCloudData(CloudData.FromLocalData(localData)); } LocalSaveSystem.SaveLocalData(localData); effectToggle.onValueChanged.RemoveAllListeners(); buyButton.onClick.RemoveAllListeners(); selectButton.onClick.RemoveAllListeners(); failureMessage.gameObject.SetActive(false); effectToggle.gameObject.SetActive(true); buyButton.gameObject.SetActive(false); selectButton.gameObject.SetActive(true); effectToggle.isOn = _currentCharacter.IsEffectEnabled; effectToggle.onValueChanged.AddListener(ToggleCharacterEffect); selectButton.onClick.AddListener(SelectCharacter); CharactersPageEventSystem.Instance.PurchaseCharacter(_currentCharacter); StoreEventSystem.Instance.SuccessfulPurchase(); } else { var buyButtonTransform = buyButton.GetComponent <RectTransform>(); buyButtonTransform.DOKill(true); buyButtonTransform.DOPunchPosition(new Vector3(15, 0, 0), 0.5f); failureMessage.gameObject.SetActive(true); var failureMessageTransform = failureMessage.GetComponent <RectTransform>(); failureMessageTransform.DOKill(true); failureMessageTransform.GetComponent <RectTransform>().DOPunchScale(new Vector3(0.125f, 0, 0), 0.25f, 2); } }
private void SyncLocalWithCloud() { var localData = LocalSaveSystem.LoadLocalData(); localData.Synchronized = true; LocalSaveSystem.SaveLocalData(localData); var defaultCloudData = CloudData.FromLocalData(localData); PlayGamesServices.SaveCloudData(defaultCloudData); PlayGamesServices.ReportScore(Gps.LeaderboardHighScore, localData.HighScore); ActivateAccountPanels(new[] { "signed" }); }
private void IncreaseCoins(int coins) { var localData = LocalSaveSystem.LoadLocalData(); localData.SaveTime = DateTime.Now.Ticks; localData.Coins += coins; _gameData.Coins += coins; if (PlayGamesServices.IsAuthenticated && InternetConnection.Available()) { PlayGamesServices.SaveCloudData(CloudData.FromLocalData(localData)); } LocalSaveSystem.SaveLocalData(localData); StoreEventSystem.Instance.SuccessfulPurchase(); }
private void MultiplyCoins() { var multipliedCoins = _earnedCoins * CoinsMultiplayer; earnedCoinsLabel.text = multipliedCoins.ToString(); var localData = LocalSaveSystem.LoadLocalData(); localData.SaveTime = DateTime.Now.Ticks; localData.Coins += multipliedCoins - _earnedCoins; _gameData.Coins += multipliedCoins - _earnedCoins; if (PlayGamesServices.IsAuthenticated && InternetConnection.Available()) { PlayGamesServices.SaveCloudData(CloudData.FromLocalData(localData)); } LocalSaveSystem.SaveLocalData(localData); multiplyCoinsButton.onClick.RemoveAllListeners(); multiplyCoinsButton.gameObject.SetActive(false); }
private void SelectCharacter() { effectToggle.onValueChanged.RemoveAllListeners(); selectButton.onClick.RemoveAllListeners(); failureMessage.gameObject.SetActive(false); selectButton.gameObject.SetActive(false); var localData = LocalSaveSystem.LoadLocalData(); localData.Characters.First(c => c.Id == _gameData.SelectedCharacter.Id).IsSelected = false; _gameData.SelectedCharacter.IsSelected = false; localData.Characters.First(c => c.Id == _currentCharacter.Id).IsSelected = true; _currentCharacter.IsSelected = true; LocalSaveSystem.SaveLocalData(localData); effectToggle.onValueChanged.AddListener(ToggleCharacterEffect); CharactersPageEventSystem.Instance.ChangeSelectedCharacter(_currentCharacter); }
private void SaveProgress() { earnedScoreLabel.text = _earnedScore.ToString(); earnedCoinsLabel.text = _earnedCoins.ToString(); if (_earnedCoins > 0 && InternetConnection.Available()) { multiplyCoinsButton.gameObject.SetActive(true); } var localData = LocalSaveSystem.LoadLocalData(); var highScore = _gameData.HighScore; if (highScore < _earnedScore) { localData.HighScore = _earnedScore; _gameData.HighScore = _earnedScore; newRecordLabel.gameObject.SetActive(true); if (PlayGamesServices.IsAuthenticated && InternetConnection.Available()) { PlayGamesServices.ReportScore(Gps.LeaderboardHighScore, _earnedScore); } } localData.SaveTime = DateTime.Now.Ticks; localData.Coins += _earnedCoins; _gameData.Coins += _earnedCoins; if (PlayGamesServices.IsAuthenticated && InternetConnection.Available()) { PlayGamesServices.SaveCloudData(CloudData.FromLocalData(localData)); } LocalSaveSystem.SaveLocalData(localData); }