コード例 #1
0
    void CheckPatternComplete() // Called on Finger Lift
    {
        //Debug.Log("Checking " + recordedRuneIndexes.Count + " recorded rune indexes against " +
        //currentRunePattern.allIntsInPattern.Count + " Runes needed");

        int correctMatches = 0;

        // Reverse for loop to check and remove matching numbers
        for (int i = recordedRuneIndexes.Count - 1; i > -1; i--)
        {
            foreach (int patternRuneInt in currentRunePattern.allIntsInPattern)
            {
                if (recordedRuneIndexes[i] == patternRuneInt)
                {
                    //Debug.Log("Matched " + patternRuneInt + " with " + recordedRuneIndexes[i]);
                    correctMatches++;
                    recordedRuneIndexes.Remove((recordedRuneIndexes[i]));
                    break;
                }
                else
                {
                    // nothing
                }
            }
        }

        //Debug.Log((currentRunePattern.allIntsInPattern.Count - recordedRuneIndexes.Count) + " matches left");

        //Debug.Log(correctMatches + "Correct Matches. " + currentRunePattern.allIntsInPattern.Count + " Matches needed");

        // Pattern Complete!
        //if (correctMatches == currentRunePattern.allIntsInPattern.Count)
        if (currentRunePattern.allIntsInPattern.Count - correctMatches == 0)
        {
            // Debug.Log("Pattern Complete");

            if (currentPatternInList < allRunePatterns.Count - 1)
            {
                currentPatternInList++;
            }
            else
            {
                currentPatternInList = 0;
            }

            currentRunePattern = allRunePatterns[currentPatternInList];
            headerText.text    = "New Pattern!";

            //Reset!
            ResetLine();
            ShowRunePattern();
        }
        else // Pattern Failed
        {
            headerText.text = "Try Again!";
            ResetLine();
        }
    }
コード例 #2
0
    void SaveRunePattern()
    {
        // Debug.Log("Saving Rune Pattern...");
        RunePattern newPattern = ScriptableObject.CreateInstance(typeof(RunePattern)) as RunePattern;

        // Add all of the int pairs before sorting out the individual ints
        newPattern.runeIntPairs.AddRange(validRunePairings);

        foreach (IntPair intPair in newPattern.runeIntPairs)
        {
            // Stop double up between int 1 and previous int 2
            if (newPattern.allIntsInPattern.Count == 0 ||
                intPair.int1 != newPattern.allIntsInPattern[newPattern.allIntsInPattern.Count - 1])
            {
                newPattern.allIntsInPattern.Add(intPair.int1);
            }

            newPattern.allIntsInPattern.Add(intPair.int2);
        }

        // string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath("Assets/RunePatterns" + "/New " + typeof(RunePattern).ToString() + ".asset");
        //AssetDatabase.CreateAsset(newPattern, assetPathAndName);
    }