Beispiel #1
0
 // 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);
 }
Beispiel #2
0
 public JSFGamePiece(JSFPieceDefinition newPd, JSFBoard newMaster, int type, Vector3 newPosition)
 {
     pd       = newPd;
     master   = newMaster;
     slotNum  = type;
     position = newPosition;
 }
Beispiel #3
0
 // converts a piece that is here to be a special piece
 public void convertToSpecial(JSFPieceDefinition pd)
 {
     if (isFilled)
     {
         piece.pd.performPower(arrayRef);             // trigger specials if any
     }
     piece.destroy();
     piece.specialMe(pd);
 }
Beispiel #4
0
    // for board reset when no more moves
    public void resetMe(JSFPieceDefinition pieceType, int skinNum)
    {
        if (pd.ignoreReset)         // non-resettable piece
        {
            return;
        }

        pd      = pieceType;
        slotNum = skinNum;
        dressMe();
    }
Beispiel #5
0
    // 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);
    }
Beispiel #6
0
 // sets the piece that is here to be a special piece
 public void setSpecialPiece(JSFPieceDefinition pd)
 {
     if (panel.pnd.hasStartingPiece)
     {
         piece.removePiece();
         if (pd.isSpecial)             // if it's a special type, define the appropriate skin
         {
             piece.slotNum = pd.skinToUseDuringSpawn(arrayRef[0], arrayRef[1]);
         }
         piece.pd = pd;             // sets the pd type
     }
 }
Beispiel #7
0
 // for external scripts to call, destroys the game piece with validation checks
 public void destroy()
 {
     if (pd != null)
     {
         if (!pd.isSpecial)                   // not a special piece... it is a colored piece
         {
             master.gm.matchCount[slotNum]++; // increase the type count that is destroyed.
         }
         pd.onPieceDestroyed(this);           // call the piece type onDestroy function (if any)
         pd = null;                           // null the piece attribute here
         master.gm.animScript.doAnim(JSFanimType.GLOBALDESTROY, master.arrayRef[0], master.arrayRef[1]);
     }
     destroyCall();
 }
Beispiel #8
0
 // 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;
     }
 }
Beispiel #9
0
 // converts this piece to a special piece
 public void specialMe(JSFPieceDefinition specialType)
 {
     pd = specialType;
     dressMe();
 }
Beispiel #10
0
 // method to remove the piece as we dont need it anymore...
 // no validation or checks performed.. just remove it and reset!
 public void removePiece()
 {
     pd = null;         // null the piece attribute here
     destroyCall();
 }
Beispiel #11
0
 // to create a new piece object when the board is new
 public void createObject(JSFPieceDefinition pd, int skinNum)
 {
     piece     = new JSFGamePiece(pd, this, skinNum, position);
     isFalling = false;
     isActive  = true;
 }
Beispiel #12
0
 // converts a piece that is here to be a special piece
 public void convertToSpecialNoDestroy(JSFPieceDefinition pd, int newSlotNum)
 {
     piece.removePiece();
     piece.slotNum = newSlotNum;
     piece.specialMe(pd);
 }