예제 #1
0
        public void Undo()
        {
            MoveIsOver = false;
            var unitsState = LastMoveWasDone ? LastUnitsState : LastLastUnitsState;

            ClearGrid();
            CreateUnitsFromState(unitsState);
            DrawUnits();

            Data.Score = LastScore;
            GameManager.UpdateScoreText();
            CanUndo = false;
            Wait.ForSeconds(Drawer.TimingsConfig.delayAfterUndo, () => MoveIsOver = true);
        }
예제 #2
0
 public void Pause()
 {
     if (GridManager.State == GridState.GameOver)
     {
         uiManager.SetGameOverAnimation("Out");
         GridManager.State = GridState.Nothing;
         Wait.ForSeconds(GridManager.Drawer.TimingsConfig.delayAfterClearingGridAfterGameOver, GridManager.ClearGrid);
     }
     else
     {
         GridManager.State    = GridState.Pause;
         GridManager.IsActive = false;
         GridManager.SaveDataToCloudAndToLocalMemory();
     }
 }
예제 #3
0
        private void CreateNewUnit()
        {
            Unit unit = GetUnitFromPool();

            unit.Position = GenerateRandomFreePosition();
            unit.Value    = Random.Range(0, 4) == 0 ? 4 : 2;
            Units[unit.Position.x, unit.Position.y] = unit;
            UnitCounter++;

            drawer.SetNewUnitPosNScale(unit);
            MoveIsOver = false;
            Wait.ForSeconds(drawer.TimingsConfig.moveDuration * Drawer.TimingsConfig.appearDelay, () =>
            {
                drawer.DrawNewUnit(unit, false);
                MoveIsOver = true;
            });
        }
예제 #4
0
        public void GameOverMethod()
        {
            uiManager.SetGameOverAnimation("In");

            CurrentLocalData.StateIsSaved[GridManager.SideLength - 3] = false;

            if (Data.Score > CurrentLocalData.BestScores[GridManager.SideLength - 3])
            {
                CurrentLocalData.BestScores[GridManager.SideLength - 3] = Data.Score;
            }
            CurrentLocalData.LastScores[GridManager.SideLength - 3] = 0;

            if (!CurrentLocalData.AdIsShowedInThisGame[GridManager.SideLength - 3])
            {
                CurrentLocalData.AdIsShowedInThisGame[GridManager.SideLength - 3] = true;
                Wait.ForSeconds(GridManager.Drawer.TimingsConfig.delayBeforeShowingAd,
                                adsController.ShowGameOverAd);
            }

            GridManager.SaveDataToCloudAndToLocalMemory();
        }