void Start() { instance = this; P_Mons = GameObject.FindGameObjectsWithTag("PURPLE"); P_pieces = GameObject.FindGameObjectsWithTag("PURPLEPIECE"); R_Mons = GameObject.FindGameObjectsWithTag("RED"); R_pieces = GameObject.FindGameObjectsWithTag("REDPIECE"); for (int i = 0; i < P_pieces.Length; i++) { P_Mons[i].SetActive(false); } for (int i = 0; i < R_pieces.Length; i++) { R_Mons[i].SetActive(false); } Invoke("PieceRising", 5.0f); Invoke("SpawnPos", 5.0f); Invoke("Twinkling", 7.0f); Invoke("SpawnParticle", 8.0f); Invoke("RevealMons", 8.0f); }
IEnumerator FallAndWait() { while (_playing) { PieceCtrl current = CurrentPiece(); if (current) { if (current.CanFall(_gridCtrl.SpawnBoundaries, IsCoordFree)) { current.Fall(); } else { current.MakeFull(); var destroyedRows = _rowRemover.Run(); IncreaseScore(destroyedRows); GetComponent <PieceFactory>().AddNext(); if (IsGameLost()) { StopAllCoroutines(); GetComponent <GridCtrl>().FinishGame(); } yield return(new WaitForSeconds(this.CurrentRespawnDelay())); } } yield return(new WaitForSeconds(this.CurrentFallDelay())); } }
void Update() { _piece = CurrentPiece(); if (_input.IsMovingLeft()) { MoveLeft(); } else if (_input.IsMovingRight()) { MoveRight(); } if (_input.IsRotating()) { Rotate(); } }
private List <float> CurrentColumns() { PieceCtrl _piece = CurrentPiece(); List <Vector3> coords; if (_piece) { coords = _piece.PartPositions(); } else { coords = new List <Vector3>(); } return(coords.Select((coord) => coord.x).ToList()); }