コード例 #1
0
 // function to backtrack the swipe chain
 static void backTrackSelection(JSFBoard board)
 {
     // ==== BACK TRACK SWIPE CODE ====
     if (swipeChain.Contains(board))
     {
         int index = swipeChain.IndexOf(board);
         for (int x = 0; x <= swipeChain.Count - 1 - index; x++)
         {
             JSFRelay.onSwipeRemoved(swipeChain[swipeChain.Count - 1 - x].piece, false);
         }
         swipeChain.RemoveRange(index, swipeChain.Count - index);
         removeSwipeVisuals(index);
         JSFRelay.onSwipeBackTracked(board.piece, false);            // relay call
         if (swipeChain.Count == 0)
         {
             isSwiping = false;
             swipeStart(board);                 // add back this board with its call criterias
         }
         else
         {
             rainbowSwipe = true;              // in case we have changed color before this... revert to this color
             swipeCall(board);                 // add back this board with its call criterias
         }
     }
 }
コード例 #2
0
 public JSFGamePiece(JSFPieceDefinition newPd, JSFBoard newMaster, int type, Vector3 newPosition)
 {
     pd       = newPd;
     master   = newMaster;
     slotNum  = type;
     position = newPosition;
 }
コード例 #3
0
    // randomly assign a special to this board
    void randomSpecialABoard()
    {
        JSFBoard selected = getRandomBoard();

        // play audio visuals
        if (gm.audioScript.convertingSpecialFx.Length > 0)
        {
            gm.audioScript.convertingSpecialFx[Random.Range(0, gm.audioScript.convertingSpecialFx.Length - 1)].play();
        }

        gm.animScript.doAnim(JSFanimType.CONVERTSPEC, selected.arrayRef[0], selected.arrayRef[1]);

        // get the gameobject reference
        GameObject pm = gm.pieceManager;

        switch (Random.Range(0, 3))
        {
        case 0:
            selected.convertToSpecialNoDestroy(pm.GetComponent <JSFHorizontalPiece>(), selected.piece.slotNum);             // convert to H-type
            break;

        case 1:
            selected.convertToSpecialNoDestroy(pm.GetComponent <JSFVerticalPiece>(), selected.piece.slotNum);             // convert to V-type
            break;

        case 2:
            selected.convertToSpecialNoDestroy(pm.GetComponent <JSFBombPiece>(), selected.piece.slotNum);             // convert to T-type
            break;
        }
    }
コード例 #4
0
ファイル: JSFPortalA.cs プロジェクト: lickey10/FlowerPops
    int[] getExitPath(JSFBoard board)
    {
        int[] newRef = new int[] { board.arrayRef[0], board.arrayRef[1] };        // make a copy of the array position

        // compensate for gravity
        switch (gm.currentGravity)
        {
        case JSFGravity.LEFT:
            newRef[0] = newRef[0] - 1;
            break;

        case JSFGravity.RIGHT:
            newRef[0] = newRef[0] + 1;
            break;

        case JSFGravity.DOWN:
            newRef[1] = newRef[1] - 1;
            break;

        case JSFGravity.UP:
            newRef[1] = newRef[1] + 1;
            break;
        }
        return(newRef);
    }
コード例 #5
0
    static void addSwipeLine(int x, int y)
    {
        if (vm.swipeLineObj == null)
        {
            Debug.LogError("Warning : No swipe line object. Check JSFVisualManager.");
            return;             // no object defined
        }
        if (swipeChain.Count < 2)
        {
            return;             // not enough to create a line between two objects yet
        }
        GameObject obj;

        if (gm.usingPoolManager)         // POOLMANAGER CODE
        {
            obj = PoolManager.Pools[JSFUtils.miscPoolName].Spawn(vm.swipeLineObj.transform).gameObject;
        }
        else             // NON-POOLMANAGER CODE
        {
            obj = GameObject.Instantiate(vm.swipeLineObj) as GameObject;
        }
        JSFBoard board = swipeChain[swipeChain.Count - 2];       // get the previous swipe entry

        JSFUtils.creatSwipeLine(obj, gm.getBoardPosition(x, y), board.position, -19.99f);
        swipeLineChain.Add(obj);
    }
コード例 #6
0
ファイル: JSFBoardPanel.cs プロジェクト: lickey10/FlowerPops
    public GameObject defaultPanel; // for visuals - the default panel at the back

    public JSFBoardPanel(JSFPanelDefinition newDefinition, int strength, JSFBoard myMaster)
    {
        master = myMaster;         // set the master script

        // set the type - DO NOT USE setType() as we do not want to initPanels()~!
        pnd        = newDefinition;
        durability = strength;
    }
コード例 #7
0
    // function to add to the swipe chain
    static void swipeAdd(JSFBoard board)
    {
        isSwiping = true;         // swiping is active
        // ==== SWIPE CHAIN CODE ====
        swipeChain.Add(board);
        addVisualChain(board.arrayRef[0], board.arrayRef[1]);

        JSFRelay.onSwipeAdded(board.piece, false);        // relay call
    }
コード例 #8
0
    // function to get the GamePiece reference of previous added swipe chain using index and num of index previous
    public static JSFGamePiece getPrevChainedFromHere(JSFBoard refIndex, int num)
    {
        int newIndex = swipeChain.IndexOf(refIndex) - num;

        if (newIndex >= 0 && newIndex < swipeChain.Count) // if index not out of bounds...
        {
            return(swipeChain[newIndex].piece);           // return the index..
        }
        return(null);                                     // out of bounds, return null
    }
コード例 #9
0
 // function to check for swipe legality (can users swipe?)
 static bool isLegalSwipe(JSFBoard board)
 {
     if (gm.moveOnlyAfterSettle)         // move only after settle?
     {
         if (!gm.checkedPossibleMove)
         {
             return(false);                // not ready to move
         }
     }
     return(gm.canMove && gm.gameState == JSFGameState.GameActive && gm.isLegalSwipe(board));           // meets criteria?
 }
コード例 #10
0
ファイル: JSFBoard.cs プロジェクト: lickey10/FlowerPops
    // neighbouring function to get all boards in this specific direction
    public List <JSFBoard> getAllBoardInDirection(JSFBoardDirection bd)
    {
        List <JSFBoard> list  = new List <JSFBoard>();
        JSFBoard        chain = boardEnumToReference(bd);

        while (chain != null)         // recursively add the boards in the specified direction
        {
            list.Add(chain);
            chain = chain.boardEnumToReference(bd);
        }
        return(list);        // returns the list of boards in the direction
    }
コード例 #11
0
ファイル: JSFBoard.cs プロジェクト: lickey10/FlowerPops
    // neighbouring function to get a board in this specific direction and distance
    public JSFBoard getBoardFromDirection(JSFBoardDirection bd, int distance)
    {
        JSFBoard target = boardEnumToReference(bd); // initial

        for (int x = 1; x < distance; x++)          // recursively find the board in the specified direction
        {
            if (target == null)
            {
                break;                 // no board here... do not continue...
            }
            target = target.boardEnumToReference(bd);
        }
        return(target);
    }
コード例 #12
0
    public static void swipeCall(JSFBoard board)
    {
        // check backtracking?
        if (swipeChain.Contains(board)) // check if we are backtracking the current selection
        {
            hasPowerMerge = false;      // resets any powerMerge status
            rainbowSwipe  = false;      // resets the any swipe status
            limitedSwipe  = false;      // resets the limit of swipe
            backTrackSelection(board);  // default proceeds with back tracking...
            return;                     // do not continue further... backtracked
        }

        // check legality of swipe
        if (!isSwiping || limitedSwipe || !isLegalSwipe(board))
        {
            return;             // not legal... do not continue
        }
        // check distance requirements
        int distance = gm.boardRadiusDistance(board, lastSwipeChainBoard);

        if (distance < board.pd.minSwipeDistance(board.piece) || distance > board.pd.maxSwipeDistance(board.piece))
        {
            return;             // not within distance... do not proceed with swipe...
        }

        // check for powerMerge...
        foreach (JSFBoard checkBoard in swipeChain)
        {
            if (checkBoard.pd.powerMerge(swipeChain, board.piece, checkBoard.piece, board.arrayRef, true) ||
                board.pd.powerMerge(swipeChain, checkBoard.piece, board.piece, board.arrayRef, true)) // powerMerge?
            {
                rainbowSwipe = false;                                                                 // resets the any swipe status
                swipeAdd(board);                                                                      // add to chain
                hasPowerMerge = true;
                return;                                                                               // added as powerMerge...
            }
        }

        // does the pieceDefinition allow to add to swipe chain?
        if (board.pd.addToSwipeChain(board.piece, swipeColor, false) ||   // normal add to swipe OR
            (rainbowSwipe && !board.pd.isSpecial))                        // check for rainbow OR
        {
            if (rainbowSwipe && !board.pd.isSpecial)
            {
                swipeColor = board.piece.slotNum; // change to this color if it was from rainbowSwipe
            }
            rainbowSwipe = false;                 // resets the any swipe status
            swipeAdd(board);                      // add to chain
        }
    }
コード例 #13
0
ファイル: JSFPortalA.cs プロジェクト: lickey10/FlowerPops
 // called by Board during GameManager game-start phase
 // different from Start() as that is unity start, not neccessarily the game is set-up yet
 public override void onGameStart(JSFBoard board)
 {
     for (int x = 0; x < board.gm.boardWidth; x++)
     {
         for (int y = 0; y < board.gm.boardHeight; y++)
         {
             if (board.gm.board[x, y].panel.pnd is JSFPortalB)                        // find the exit pair
             {
                 if (board.gm.board[x, y].panel.durability == board.panel.durability) // matching exit pair
                 {
                     boardA.Add(board);                                               // save the entry pair reference
                     boardB.Add(board.gm.board[x, y]);                                // save the exit pair reference
                 }
             }
         }
     }
 }
コード例 #14
0
    public static void swipeStart(JSFBoard board)
    {
        if (isSwiping)
        {
            validateSwipe();             // prevent refresh bug hack
        }

        if (!isLegalSwipe(board))
        {
            return;             // not a legal swipe... do not proceed with swiping
        }

        if (board.pd.useAsFirstSwipe(board.piece, false))          // check if pieceDefinition allows to swipe start
        {
            isSwiping = true;
            swipeAdd(board);
        }
    }
コード例 #15
0
ファイル: JSFBoard.cs プロジェクト: lickey10/FlowerPops
    // function to set the neighbour of this board
    public void initNeighbourReferences()
    {
        // board position in x & y reference
        int x = arrayRef[0];
        int y = arrayRef[1];

        // null the references first
        top = bottom = left = right = topLeft = topRight = bottomLeft = bottomRight = null;

        if (y + 1 < gm.boardHeight)
        {
            top = gm.board[x, y + 1];          // top reference
            allNeighbourBoards.Add(top);       // add to the neighbourlist
        }
        if (y - 1 >= 0)
        {
            bottom = gm.board[x, y - 1];          // bottom reference
            allNeighbourBoards.Add(bottom);       // add to the neighbourlist
        }

        if (gm.boardType == JSFBoardType.Square)         // exclusive to square types only
        {
            if (x + 1 < gm.boardWidth)
            {
                right = gm.board[x + 1, y];              // right reference
                allNeighbourBoards.Add(right);           // add to the neighbourlist
            }
            if (x - 1 >= 0)
            {
                left = gm.board[x - 1, y];              // left reference
                allNeighbourBoards.Add(left);           // add to the neighbourlist
            }
        }

        if (gm.boardType == JSFBoardType.Square &&
            gm.squareSplashMode == JSFsquareMode.Box9x9Type)            // exclusive to square 9x9 mode only
        {
            if (y - 1 >= 0 && x + 1 < gm.boardWidth)
            {
                bottomRight = gm.board[x + 1, y - 1];            // bottomRight reference
                allNeighbourBoards.Add(bottomRight);             // add to the neighbourlist
            }
            if (y - 1 >= 0 && x - 1 >= 0)
            {
                bottomLeft = gm.board[x - 1, y - 1];            // bottomRight reference
                allNeighbourBoards.Add(bottomLeft);             // add to the neighbourlist
            }
            if (y + 1 < gm.boardHeight && x + 1 < gm.boardWidth)
            {
                topRight = gm.board[x + 1, y + 1];            // bottomRight reference
                allNeighbourBoards.Add(topRight);             // add to the neighbourlist
            }
            if (y + 1 < gm.boardHeight && x - 1 >= 0)
            {
                topLeft = gm.board[x - 1, y + 1];            // bottomRight reference
                allNeighbourBoards.Add(topLeft);             // add to the neighbourlist
            }
        }

        if (gm.boardType == JSFBoardType.Hexagon) // exclusive to Hexagon mode only
        {
            int refY = y;                         // initial value of y
            if (x % 2 == 1)                       // hex correction only
            {
                refY = y - 1;                     // compensate for hex squiggly line
            }
            if (refY >= 0 && refY < gm.boardHeight && x + 1 < gm.boardWidth)
            {
                bottomRight = gm.board[x + 1, refY];              // bottomRight reference
                allNeighbourBoards.Add(bottomRight);              // add to the neighbourlist
            }
            if (refY >= 0 && refY < gm.boardHeight && x - 1 >= 0)
            {
                bottomLeft = gm.board[x - 1, refY];              // bottomRight reference
                allNeighbourBoards.Add(bottomLeft);              // add to the neighbourlist
            }
            if (refY + 1 >= 0 && (refY + 1) < gm.boardHeight && x + 1 < gm.boardWidth)
            {
                topRight = gm.board[x + 1, refY + 1];            // bottomRight reference
                allNeighbourBoards.Add(topRight);                // add to the neighbourlist
            }
            if (refY + 1 >= 0 && (refY + 1) < gm.boardHeight && x - 1 >= 0)
            {
                topLeft = gm.board[x - 1, refY + 1];            // bottomRight reference
                allNeighbourBoards.Add(topLeft);                // add to the neighbourlist
            }
        }
    }
コード例 #16
0
 // called by GameManager when board stabilize and gets a suggestion
 public virtual void onBoardStabilize(JSFBoard board)
 {
     // do nothing...
 }
コード例 #17
0
    //
    //  Virtual functions that users can override
    //  or leave it as default behaviours
    //

    // called by Board during GameManager game-start phase
    // different from Start() as that is unity start, not neccessarily the game is set-up yet
    public virtual void onGameStart(JSFBoard board)
    {
        // do nothing....
    }
コード例 #18
0
 // Optional piece splash function when a piece is destroyed
 public virtual void splashDamage(JSFBoard board)
 {
     // do nothing...
 }
コード例 #19
0
ファイル: aPieceTemplate.cs プロジェクト: lickey10/FlowerPops
 // called by GameManager when player makes the next move
 public override void onPlayerMove(JSFBoard board)
 {
     // default do nothing...
     // your own code here if you need
 }
コード例 #20
0
 // called by GameManager when player makes the next move
 public virtual void onPlayerMove(JSFBoard board)
 {
     // do nothing...
 }
コード例 #21
0
ファイル: aPieceTemplate.cs プロジェクト: lickey10/FlowerPops
 // called by GameManager when board stabilize and gets a suggestion
 public override void onBoardStabilize(JSFBoard board)
 {
     // default do nothing...
     // your own code here if you need
     // think of this as something like "on the next turn"...
 }
コード例 #22
0
 // called by Board during GameManager game-start phase
 // different from Start() as that is unity start, not neccessarily the game is set-up yet
 public override void onGameStart(JSFBoard board)
 {
     // nothing...
 }
コード例 #23
0
ファイル: aPieceTemplate.cs プロジェクト: lickey10/FlowerPops
 // Optional piece splash function when a piece is destroyed
 public override void splashDamage(JSFBoard board)
 {
     // default do nothing...
     // your own code here if you need
     // splash when a match is formed...
 }