Esempio n. 1
0
    private void LockTetInPlace()
    {
        ScoreMult mSM = ScoreMult.None;

        // reset game
        if (aTAP >= 190)
        {
            UnityEngine.Debug.Log("RESET GAME");
            SetUp(mC);
        }
        else
        {
            // is there active tetrino?
            if (aTet.Count > 0)
            {
                for (int i = 0; i < aTet.Count; i++)
                {
                    // piece location normal?
                    if (aTet[i] >= 0 && aTet[i] < allB.Count)
                    {
                        aPS[aTet[i]] = mTet.mPS;
                        allB[aTet[i]].GetComponent <Image>().sprite = tetSprite;
                        allB[aTet[i]].GetComponent <Image>().color  = mTet.mColor;
                        //lTet.Add(aTet[i]);
                    }
                }
                // T SPIN - - - - - - - - - -
                if (mTet.lastMoveWasRotate)
                {
                    mSM = ScoreMult.Twist;
                    if (mTet.mS == TetShape.T)
                    {
                        bool lockedInTSpin = LockedInTSpin();
                        if (lockedInTSpin)
                        {
                            mSM = ScoreMult.TSpin;
                        }
                    }
                }
            }
            aTet.Clear();
            SpawnNewTet();
        }

        RemoveFullLinesForPoints(mSM);
    }
Esempio n. 2
0
    private void RemoveFullLinesForPoints(ScoreMult mSM)
    {
        List <int> killLines = new List <int>();

        for (int i = 0; i < 20; i++)
        {
            int inARow = 0;
            if (aPS[i * cols] != PieceState.Empty)
            {
                for (int i2 = 0; i2 < 10; i2++)
                {
                    if (aPS[i * cols + i2] != PieceState.Empty)
                    {
                        inARow++;
                    }
                }
                if (inARow == 10)
                {
                    UnityEngine.Debug.Log("KILL LINE: " + i);
                    killLines.Add(i);
                }
            }
        }
        if (killLines.Count > 0)
        {
            int thisToGo = killLines.Count - 1;
            if (thisToGo > scorePointsForLines.Count - 1)
            {
                thisToGo = scorePointsForLines.Count - 1;
            }
            int multForTSpin = 1;
            if (mSM == ScoreMult.Twist)
            {
                multForTSpin = 2;
            }
            else if (mSM == ScoreMult.TSpin)
            {
                multForTSpin = 3;
            }
            mScore += scorePointsForLines[thisToGo] * multForTSpin;
            Debug.Log("Score Mult X " + multForTSpin + " From: " + mSM);


            for (int i3 = 0; i3 < killLines.Count; i3++)
            {
                for (int i4 = 0; i4 < 10; i4++)
                {
                    if (killLines[i3] * cols + i4 >= 0 && killLines[i3] * cols + i4 < aPS.Count)
                    {
                        aPS[killLines[i3] * cols + i4] = PieceState.Empty;
                        allB[killLines[i3] * cols + i4].GetComponent <Image>().sprite = emptySprite;
                        allB[killLines[i3] * cols + i4].GetComponent <Image>().color  = Color.white;
                    }
                }
            }
            for (int i5 = 0; i5 < killLines.Count; i5++)
            {
                for (int i7 = (killLines[i5] - i5) * cols; i7 < aPS.Count; i7++)
                {
                    if (i7 < aPS.Count && i7 >= 0)
                    {
                        if (i7 + cols < aPS.Count && i7 + cols >= 0)
                        {
                            aPS[i7] = aPS[i7 + cols];
                            allB[i7].GetComponent <Image>().sprite = allB[i7 + cols].GetComponent <Image>().sprite;
                            allB[i7].GetComponent <Image>().color  = allB[i7 + cols].GetComponent <Image>().color;
                        }
                    }
                }
            }
        }
    }