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); }
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(); } }
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; }); }
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(); }