Ejemplo n.º 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
         }
     }
 }
Ejemplo n.º 2
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
    }
Ejemplo n.º 3
0
    }                                    // easy reference for arrayRef[1]

    void OnMouseUpAsButton()
    {
        JSFRelay.onPieceClick(x, y);
    }
Ejemplo n.º 4
0
 void OnMouseUpAsButton()
 {
     JSFRelay.onPanelClick(x, y);
 }
Ejemplo n.º 5
0
    // function to validate the swipe chain
    public static void validateSwipe()
    {
        bool validateStatus = false;
        int  swipeNum       = currentSwipeCount;
        int  comboTracker   = 0;

        if (gm.gameState == JSFGameState.GameActive &&               // game has not ended...
            (swipeChain.Count >= gm.minSwipeMatch || hasPowerMerge)) // meet the minimum required length

        {
            if (gm.audioScript.matchSoundFx.Length > 0)
            {
                //for(int x = 0; x < swipeChain.Count; x++)
                //gm.audioScript.matchSoundFx[Random.Range(0, gm.audioScript.matchSoundFx.Length - 1)].play();

                gm.audioScript.PlayMatchSound(swipeChain.Count);
            }

            gm.playerMadeAMove();
            if (hasPowerMerge)                                       // perform powerMerges if there is...
            {
                List <JSFBoard> mergeCheck  = new List <JSFBoard>(); // a power merge check list
                bool            powerMerged = false;
                for (int w = swipeChain.Count - 1; w >= 0; w--)
                {
                    mergeCheck.Clear();                        // clear the list for each check
                    mergeCheck.AddRange(swipeChain);           // copy the current list
                    mergeCheck.Remove(swipeChain[w]);          // as to not check itself
                    mergeCheck.Reverse();                      // reverse the list to start from last swiped
                    foreach (JSFBoard innerLoop in mergeCheck) // check against all swiped pieceDefinitions
                    {
                        if (innerLoop.pd.powerMerge(swipeChain, swipeChain[w].piece, innerLoop.piece, swipeChain[w].arrayRef, false) ||
                            swipeChain[w].pd.powerMerge(swipeChain, innerLoop.piece, swipeChain[w].piece, swipeChain[w].arrayRef, false))
                        {
                            powerMerged = true;                // powerMerge called...
                            break;                             // done power merging... ( break inner loop )
                        }
                    }
                    if (powerMerged)
                    {
                        break;                         // done power merging... ( break outer loop too )
                    }
                }
            }

            foreach (JSFBoard board in swipeChain)
            {
                comboTracker++;
                if (comboTracker > gm.minSwipeMatch)
                {
                    gm.increaseCombo();                      // increases combo by 1 for each after the min swipe num
                }
                if (board.isFilled)                          // if not already destroyed by power merge
                {
                    JSFRelay.onSwipeValidating(board.piece); // relay call
                }
            }
            validateStatus = true;             // swipe chain has been validated...
        }
        else
        {
            swipeChain.Reverse();             // change order from back to front...
            foreach (JSFBoard board in swipeChain)
            {
                JSFRelay.onSwipeFailed(board.piece);                 // calls the individual swipeFailed function
            }
            if (swipeNum > 1)
            {
                if (gm.audioScript.badMoveSoundFx.Length > 0)
                {
                    gm.audioScript.badMoveSoundFx[Random.Range(0, gm.audioScript.badMoveSoundFx.Length - 1)].play();
                }
            }
        }
        swipeChain.Clear();
        removeSwipeVisuals(0);
        limitedSwipe  = false;                               // reset swipe limit
        hasPowerMerge = false;                               // reset powerMerge status
        rainbowSwipe  = false;                               // resets the any swipe status
        isSwiping     = false;                               // disable swiping after validated
        JSFRelay.onSwipeValidated(validateStatus, swipeNum); // relay call
    }