コード例 #1
0
 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));
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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);
     }
 }
コード例 #5
0
        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));
                }
            }
        }
コード例 #6
0
 public void ShowLeaderboardUI()
 {
     GPGSManager.ShowLeaderboardUI();
 }
コード例 #7
0
 public void ShowAchievementsUI()
 {
     GPGSManager.ShowAchievementsUI();
 }
コード例 #8
0
 private void InitializeSignInOrOutGPGSButtonColor()
 {
     uiManager.SetGPGSButtonSprite(GPGSManager.Authenticated());
 }