void Start () { label = GetComponent<UILabel>(); loseIsMoves = (gameLogic.loseConditions is LoseMoves); loseMoves = (gameLogic.loseConditions as LoseMoves); loseTimer = (gameLogic.loseConditions as LoseTimer); if (index == 1) { secondsLabel.gameObject.SetActive(gameLogic.loseConditions is LoseTimer); } UpdateText(); if (index == 1) { label.text = ScoreSystem.FormatScore(currentValue); StartCoroutine(ValueUpdater()); } }
void Start() { label = GetComponent <UILabel>(); loseIsMoves = (gameLogic.loseConditions is LoseMoves); loseMoves = (gameLogic.loseConditions as LoseMoves); loseTimer = (gameLogic.loseConditions as LoseTimer); if (index == 1) { secondsLabel.gameObject.SetActive(gameLogic.loseConditions is LoseTimer); } UpdateText(); if (index == 1) { label.text = ScoreSystem.FormatScore(currentValue); StartCoroutine(ValueUpdater()); } }
IEnumerator FreeFall() { freeFalling = true; yield return(StartCoroutine(DestroyAllTriggerTiles())); LoseMoves loseConditionMoves = loseConditions as LoseMoves; if (loseConditionMoves == null || loseConditionMoves.RemainingMoves == 0) { OnStableBoard += FreeFallFinished; IsBoardStable = false; TryCheckStableBoard(); yield break; } List <Match3BoardPiece> allNormalBoardPieces = new List <Match3BoardPiece>(); SoundEffectController sndDirectionalCreate = SoundManager.Instance["winter_create_sfx"]; float waitTime = 0.5f; while (loseConditionMoves.RemainingMoves > 0) { if (callFreeFallEvent) { callFreeFallEvent = false; OnFreeFall.RaiseEvent(); yield return(new WaitForSeconds(1.5f)); } yield return(new WaitForSeconds(waitTime)); waitTime = Mathf.Clamp(waitTime - 0.03f, 0.03f, 0.5f); allNormalBoardPieces.Clear(); boardData.ApplyActionToAll((boardPiece) => { Match3Tile tile = boardPiece.Tile as Match3Tile; if (tile != null && !tile.IsMoving && tile.IsDestructible && !tile.IsDestroying && tile.GetType() == typeof(NormalTile)) { allNormalBoardPieces.Add(boardPiece as Match3BoardPiece); } }); loseConditions.NewMove(); loseConditionMoves.RemainingMoves--; //because the lose condition is paused at this time if (allNormalBoardPieces.Count <= 0) { continue; } int index = Random.Range(0, allNormalBoardPieces.Count); Match3BoardPiece chosenPiece = allNormalBoardPieces[index]; Match3Tile chosenTile = chosenPiece.Tile as Match3Tile; allNormalBoardPieces.RemoveAt(index); chosenPiece.Tile = (boardRenderer as Match3BoardRenderer).SpawnSpecificTileAt(chosenPiece.BoardPosition.row, chosenPiece.BoardPosition.col, (Random.Range(0, 2) == 0) ? typeof(RowDestroyTile) : typeof(ColumnDestroyTile), TileColorType.None); (chosenPiece.Tile as Match3Tile).TileColor = chosenTile.TileColor; (chosenPiece.Tile as DirectionalDestroyTile).UpdateMaterial(); Destroy(chosenTile.gameObject); ScoreSystem.Instance.AddScore(TweaksSystem.Instance.intValues["MovesScoreMultiplier"], false); SoundManager.Instance.PlayOneShot(sndDirectionalCreate); if (loseConditionMoves.RemainingMoves == 0) { break; } TryCheckStableBoard(); } yield return(new WaitForSeconds(1f)); yield return(StartCoroutine(DestroyAllTriggerTiles())); OnStableBoard += FreeFallFinished; IsBoardStable = false; TryCheckStableBoard(); }