public void SaveDataToCloudAndToLocalMemory() { SaveGridStateToLocalData(); LocalDataManager.WriteLocalData(GameManager.CurrentLocalData); if (!BestsWasChanged) { return; } GPGSManager.AddScoreToLeaderboard(SideLength, GameManager.CurrentLocalData.BestScores[SideLength - 3]); GPGSManager.WriteDataToCloud(GameManager.dataName, Converter.ToByteArray(GameManager.CurrentLocalData.BestScores)); }
private bool MoveUnit(Unit unit, Side side) { if (CheckIfAtExtremePosition(unit, side)) { return(false); } Unit nextUnit = FindNextUnit(unit, side); if (nextUnit.IsEmpty) { MoveToExtremePosition(unit, side); drawer.UpdateUnitPosition(unit); return(true); } if (nextUnit.Value != unit.Value || nextUnit.WasChanged) { if (CheckIfCanPushToNextUnit(unit, nextUnit, side)) { PushToNextUnit(unit, nextUnit, side); drawer.UpdateUnitPosition(unit); return(true); } return(false); } if (nextUnit.Value == unit.Value) { JoinUnits(unit, nextUnit, side); drawer.UpdateUnitPosition(unit, () => { unitsPool.Enqueue(unit); drawer.HideUnit(unit); }); drawer.IncrementUnit(nextUnit); Data.Score += nextUnit.Value; GameManager.UpdateScoreText(); GPGSManager.UnlockAchievement(nextUnit.Value, SideLength); return(true); } return(false); }
private void Awake() { Instance = this; LocalDataManager.ReadLocalData(data => { CurrentLocalData = data ?? new LocalData(); menuGameMode = CurrentLocalData.LastGameMode; uiManager.UpdateModeText(); }); if (!PlayerPrefs.HasKey("GameWasPlayed")) { PlayerPrefs.SetInt("DataWasReadFromCloud", 0); } GPGSManager.Initialize(); GPGSManager.SignIn(InitializeSignInOrOutGPGSButtonColor, dataName, OnDataRead); }
public void SignInOrOutGPGS() { if (GPGSManager.Authenticated()) { uiManager.OpenMessageBox( () => { GPGSManager.SignOut(); InitializeSignInOrOutGPGSButtonColor(); GridManager.State = GridState.Nothing; }, () => { }, "All your local data will be erased, are you sure you want to sign out?"); } else { GPGSManager.SignIn(InitializeSignInOrOutGPGSButtonColor, dataName, OnDataRead); } }
private void OnDataRead(byte[] data) { int[] dataInt = Converter.ToIntArray(data); bool dataIsEmpty = dataInt.All(element => element == 0); if (!dataIsEmpty) { CurrentLocalData.BestScores = dataInt; LocalDataManager.WriteLocalData(CurrentLocalData); GridManager.State = GridState.Nothing; } else { bool localDataIsEmpty = CurrentLocalData.BestScores.All(element => element == 0); if (!localDataIsEmpty) { GPGSManager.WriteDataToCloud(dataName, Converter.ToByteArray(CurrentLocalData.BestScores)); } } }
public void ShowLeaderboardUI() { GPGSManager.ShowLeaderboardUI(); }
public void ShowAchievementsUI() { GPGSManager.ShowAchievementsUI(); }
private void InitializeSignInOrOutGPGSButtonColor() { uiManager.SetGPGSButtonSprite(GPGSManager.Authenticated()); }