// to spawn a new object dropping out of the box by gravity public void spawnNew(JSFPieceDefinition pd, Vector3 pos, float dropSpeed, int skinNum) { isActive = true; piece = new JSFGamePiece(pd, this, skinNum, position - pos); piece.init(); applyTweening(dropSpeed); }
// spawn a new piece on the board itself (appear mode) which scales from small to big public void spawnNewAppear(JSFPieceDefinition pd, float appearSpeed, int skinNum) { isActive = true; piece = new JSFGamePiece(pd, this, skinNum, position); piece.init(); LeanTween.cancel(piece.thisPiece); // cancel any active tweens on this object float scaleSize = piece.thisPiece.transform.localScale.x; piece.thisPiece.transform.localScale = Vector3.zero; // appear from scale 0 LeanTween.value(piece.thisPiece, appearTweeningSubFunction, 0f, scaleSize, appearSpeed).setOnUpdateParam(piece.thisPiece); }
// reset the board when no more moves public void reset(JSFPieceDefinition pd, int skinNum) { if (panel.isFillable()) // if the panel can hold a game piece { if (isFilled) { piece.resetMe(pd, skinNum); // reset it } else // game piece was stolen by another board and the reference is wrong. create a new piece { piece = new JSFGamePiece(pd, this, skinNum, position); piece.init(); } isFalling = false; isActive = true; } }