Пример #1
0
        public void HandleTranslateRequest(UnityEngine.Vector3 movementVector)
        {
            if (mCurrentShape == null)
                                return;

                        //Move current shape
                        mTetrisGrid.HandleTranslateRequest (mCurrentShape, movementVector);

                        //Check for end game condition
                        if (mTetrisGrid.GetRowBlockCount (0) > 0) {
                                NotifyObservers (ClassicTetrisStateUpdate.GameEnded);
                                return;
                        }

                        //Check if a shape was placed. If so, check for full rows, spawn new shape
                        if (mTetrisGrid.WasShapeAddedToScene) {
                                //Delete full rows
                                foreach (int row in mTetrisGrid.GetFullRows ()) {
                                        UnityEngine.Debug.Log ("Row " + row + " is full. Deleting now..." + ++mDebugId);
                                        NotifyObservers (ClassicTetrisStateUpdate.RowDeleted);
                                        mTetrisGrid.DeleteRow (row);
                                }

                                mCurrentShape = mPreviewShape;
                                mCurrentShape.TranslateToInitialPosition ();
                                mPreviewShape = mFactory.SpawnRandomizedTetrisShape (mRulesetOption);
                                NotifyObservers (ClassicTetrisStateUpdate.GeneratedNewShape);
                        }
        }
Пример #2
0
 public void Initialize(int rowCount, int columnCount, int rulesetOption)
 {
     mTetrisGrid.Initialize (rowCount, columnCount);
                 mRulesetOption = rulesetOption;
                 mCurrentShape = mFactory.SpawnRandomizedTetrisShape (mRulesetOption);
                 mCurrentShape.TranslateToInitialPosition ();
                 mPreviewShape = mFactory.SpawnRandomizedTetrisShape (mRulesetOption);
 }