private void PopulateNextTets() { // get one of each shape to add to queue List <TetShape> addToNextTets = new List <TetShape>(); foreach (TetShape x in Enum.GetValues(typeof(TetShape))) { addToNextTets.Add(x); } // shuffle for (int i = 0; i < addToNextTets.Count; i++) { TetShape temp = addToNextTets[i]; int randomIndex = UnityEngine.Random.Range(i, addToNextTets.Count); addToNextTets[i] = addToNextTets[randomIndex]; addToNextTets[randomIndex] = temp; } for (int i2 = 0; i2 < addToNextTets.Count; i2++) { nextTets.Add(addToNextTets[i2]); } mUniRx.DoTetPreview(); }
// set up tet for preview public void SetUpPreviewTet(int thisP, TetShape tS) { List <Vector2Int> tI = new List <Vector2Int>(); Color tCP = Color.white; switch (tS) { case TetShape.I: tCP = Color.cyan; tI.Add(new Vector2Int(-1, 0)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(1, 0)); tI.Add(new Vector2Int(2, 0)); break; case TetShape.J: tCP = Color.blue; tI.Add(new Vector2Int(-1, 1)); tI.Add(new Vector2Int(-1, 0)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(1, 0)); break; case TetShape.L: tCP = new Color(1.0f, 0.45f, 0.0f, 1.0f); // orange tI.Add(new Vector2Int(1, 1)); tI.Add(new Vector2Int(-1, 0)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(1, 0)); break; case TetShape.O: tCP = Color.yellow; tI.Add(new Vector2Int(0, 1)); tI.Add(new Vector2Int(1, 1)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(1, 0)); break; case TetShape.S: tCP = Color.green; tI.Add(new Vector2Int(-1, 0)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(0, 1)); tI.Add(new Vector2Int(1, 1)); break; case TetShape.T: tCP = new Color(0.5f, 0.0f, 0.5f, 1.0f); // purple tI.Add(new Vector2Int(0, 1)); tI.Add(new Vector2Int(-1, 0)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(1, 0)); break; case TetShape.Z: tCP = Color.red; tI.Add(new Vector2Int(-1, 1)); tI.Add(new Vector2Int(0, 1)); tI.Add(new Vector2Int(0, 0)); tI.Add(new Vector2Int(1, 0)); break; } mTetris.SetUpTetPreview(thisP, tI, tCP); }
// set up tet to drop public void SetUpTet(TetShape tS, int sP) { anchorPos = sP; mS = tS; mPL.Clear(); mPDir.Clear(); switch (mS) { case TetShape.I: mPS = PieceState.Cyan; mColor = Color.cyan; mPDir.Add(new Vector2Int(-1, 0)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(1, 0)); mPDir.Add(new Vector2Int(2, 0)); break; case TetShape.J: mPS = PieceState.Blue; mColor = Color.blue; mPDir.Add(new Vector2Int(-1, 1)); mPDir.Add(new Vector2Int(-1, 0)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(1, 0)); break; case TetShape.L: mPS = PieceState.Orange; mColor = new Color(1.0f, 0.45f, 0.0f, 1.0f); // orange mPDir.Add(new Vector2Int(1, 1)); mPDir.Add(new Vector2Int(-1, 0)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(1, 0)); break; case TetShape.O: mPS = PieceState.Yellow; mColor = Color.yellow; mPDir.Add(new Vector2Int(0, 1)); mPDir.Add(new Vector2Int(1, 1)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(1, 0)); break; case TetShape.S: mPS = PieceState.Green; mColor = Color.green; mPDir.Add(new Vector2Int(-1, 0)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(0, 1)); mPDir.Add(new Vector2Int(1, 1)); break; case TetShape.T: mPS = PieceState.Purple; mColor = new Color(0.5f, 0.0f, 0.5f, 1.0f); // purple //mColor = Color.magenta; mPDir.Add(new Vector2Int(0, 1)); mPDir.Add(new Vector2Int(-1, 0)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(1, 0)); break; case TetShape.Z: mPS = PieceState.Red; mColor = Color.red; mPDir.Add(new Vector2Int(-1, 1)); mPDir.Add(new Vector2Int(0, 1)); mPDir.Add(new Vector2Int(0, 0)); mPDir.Add(new Vector2Int(1, 0)); break; } foreach (Vector2Int dInfo in mPDir) { Vector2Int useAsDInfo = new Vector2Int(0, 0); if (rotS == 0) { useAsDInfo = new Vector2Int(dInfo.x, dInfo.y); } else if (rotS == 1) { useAsDInfo = new Vector2Int(dInfo.y, dInfo.x * -1); } else if (rotS == 2) { useAsDInfo = new Vector2Int(dInfo.x * -1, dInfo.y * -1); } else if (rotS == 3) { useAsDInfo = new Vector2Int(dInfo.y * -1, dInfo.x); } int addThis = 0; addThis += useAsDInfo.x; addThis += useAsDInfo.y * cols; mPL.Add(addThis); } lSRotS = rotS; mTetState = TetState.Falling; // immediate fall happens here -- DropDown(); imSet = true; }