Ejemplo n.º 1
0
 private void SetupExternalSelectable()
 {
     Component[] modSelectables = _selectable.GetComponentsInChildren(ModSelectableType, true);
     foreach (Component modSelectable in modSelectables)
     {
         CopySettingsFromProxyMethod.Invoke(modSelectable, null);
     }
 }
Ejemplo n.º 2
0
    private IEnumerable <object> ProcessJenga(KMBombModule module)
    {
        var comp       = GetComponent(module, "JengaModule");
        var fldCorrect = GetIntField(comp, "correct", isPublic: true);
        var fldSprites = GetArrayField <Sprite>(comp, "Characters", isPublic: true);

        KMSelectable mostRecentSelectable   = null;
        KMSelectable firstCorrectSelectable = null;

        KMSelectable[] allSelectables = GetArrayField <KMSelectable>(comp, "JengaPiece", isPublic: true).Get(expectedLength: 20);
        for (int i = 0; i < 20; i++)
        {
            int ix = i;
            allSelectables[ix].OnInteract += delegate()
            {
                mostRecentSelectable = allSelectables[ix];
                return(false);
            };
        }
        int currentCorrect = fldCorrect.Get();

        while (fldCorrect.Get() > 0)
        {
            if (firstCorrectSelectable == null && fldCorrect.Get() != currentCorrect)
            {
                firstCorrectSelectable = mostRecentSelectable;
            }
            currentCorrect = fldCorrect.Get();
            yield return(null);
        }
        _modulesSolved.IncSafe(_Jenga);

        Sprite[] sprites                  = fldSprites.Get(expectedLength: 20);
        Sprite[] spritesOnFirstPress      = firstCorrectSelectable.GetComponentsInChildren <SpriteRenderer>().Select(x => x.sprite).ToArray(); //Always 2 sprites
        Sprite[] prettyLookingSouvSprites = spritesOnFirstPress.Select(spr => JengaSprites[Array.IndexOf(sprites, spr)]).ToArray();
        addQuestion(module, Question.JengaFirstBlock,
                    correctAnswers: prettyLookingSouvSprites,
                    preferredWrongAnswers: JengaSprites);
    }
Ejemplo n.º 3
0
    private bool CheckIfAnswerCorrect(int type, int stage, KMSelectable buttonGuess)
    {
        if (type == 1)
        {
            tempText = buttonGuess.GetComponentsInChildren <TextMesh>()[0].text;
            if (bomb.GetPortCount() % 2 == 0)
            {
                if (tempText == "w" || tempText == "y" || tempText == "m")
                {
                    answerGuess = 0;
                }
                else if (tempText == "q" || tempText == "r" || tempText == "s")
                {
                    answerGuess = 9;
                }
                else if (tempText == "d" || tempText == "t")
                {
                    answerGuess = 8;
                }
                else if (tempText == "i" || tempText == "v" || tempText == "u")
                {
                    answerGuess = 7;
                }
                else if (tempText == "h" || tempText == "x")
                {
                    answerGuess = 6;
                }
                else if (tempText == "a" || tempText == "b" || tempText == "n")
                {
                    answerGuess = 5;
                }
                else if (tempText == "c" || tempText == "k")
                {
                    answerGuess = 4;
                }
                else if (tempText == "j" || tempText == "p" || tempText == "z")
                {
                    answerGuess = 3;
                }
                else if (tempText == "e" || tempText == "f" || tempText == "l")
                {
                    answerGuess = 2;
                }
                else if (tempText == "g" || tempText == "o")
                {
                    answerGuess = 1;
                }
            }
            else
            {
                if (tempText == "a" || tempText == "b")
                {
                    answerGuess = 0;
                }
                else if (tempText == "h" || tempText == "x")
                {
                    answerGuess = 9;
                }
                else if (tempText == "i" || tempText == "v" || tempText == "n")
                {
                    answerGuess = 8;
                }
                else if (tempText == "d" || tempText == "t" || tempText == "u")
                {
                    answerGuess = 7;
                }
                else if (tempText == "q" || tempText == "r")
                {
                    answerGuess = 6;
                }
                else if (tempText == "w" || tempText == "y" || tempText == "s")
                {
                    answerGuess = 5;
                }
                else if (tempText == "g" || tempText == "o" || tempText == "m")
                {
                    answerGuess = 4;
                }
                else if (tempText == "e" || tempText == "f" || tempText == "l")
                {
                    answerGuess = 3;
                }
                else if (tempText == "j" || tempText == "p")
                {
                    answerGuess = 2;
                }
                else if (tempText == "c" || tempText == "k" || tempText == "z")
                {
                    answerGuess = 1;
                }
            }

            if (correctAnswers4[stage - 1] == answerGuess)
            {
                Debug.LogFormat("[Passcodes #{0}] Answered {1} which means {2} which is correct!", moduleId, tempText.ToUpper(), answerGuess);
                return(true);
            }
        }
        if (type == 0)
        {
            tempText = buttonGuess.GetComponentsInChildren <TextMesh>()[0].text;
            if (bomb.GetPortCount() % 2 == 0)
            {
                if (tempText == "w" || tempText == "y" || tempText == "m")
                {
                    answerGuess = 0;
                }
                else if (tempText == "q" || tempText == "r" || tempText == "s")
                {
                    answerGuess = 9;
                }
                else if (tempText == "d" || tempText == "t")
                {
                    answerGuess = 8;
                }
                else if (tempText == "i" || tempText == "v" || tempText == "u")
                {
                    answerGuess = 7;
                }
                else if (tempText == "h" || tempText == "x")
                {
                    answerGuess = 6;
                }
                else if (tempText == "a" || tempText == "b" || tempText == "n")
                {
                    answerGuess = 5;
                }
                else if (tempText == "c" || tempText == "k")
                {
                    answerGuess = 4;
                }
                else if (tempText == "j" || tempText == "p" || tempText == "z")
                {
                    answerGuess = 3;
                }
                else if (tempText == "e" || tempText == "f" || tempText == "l")
                {
                    answerGuess = 2;
                }
                else if (tempText == "g" || tempText == "o")
                {
                    answerGuess = 1;
                }
            }
            else
            {
                if (tempText == "a" || tempText == "b")
                {
                    answerGuess = 0;
                }
                else if (tempText == "h" || tempText == "x")
                {
                    answerGuess = 9;
                }
                else if (tempText == "i" || tempText == "v" || tempText == "n")
                {
                    answerGuess = 8;
                }
                else if (tempText == "d" || tempText == "t" || tempText == "u")
                {
                    answerGuess = 7;
                }
                else if (tempText == "q" || tempText == "r")
                {
                    answerGuess = 6;
                }
                else if (tempText == "w" || tempText == "y" || tempText == "s")
                {
                    answerGuess = 5;
                }
                else if (tempText == "g" || tempText == "o" || tempText == "m")
                {
                    answerGuess = 4;
                }
                else if (tempText == "e" || tempText == "f" || tempText == "l")
                {
                    answerGuess = 3;
                }
                else if (tempText == "j" || tempText == "p")
                {
                    answerGuess = 2;
                }
                else if (tempText == "c" || tempText == "k" || tempText == "z")
                {
                    answerGuess = 1;
                }
            }

            if (correctAnswers6[stage] == answerGuess)
            {
                Debug.LogFormat("[Passcodes #{0}] Answered {1} which means {2} which is correct!", moduleId, tempText.ToUpper(), answerGuess);
                return(true);
            }
        }
        if (type == 1)
        {
            Debug.LogFormat("[Passcodes #{0}] Answered {1} which means {2} which is INCORRECT!!! Correct answer was {3}.", moduleId, tempText.ToUpper(), answerGuess, correctAnswers4[stage - 1]);
        }
        if (type == 0)
        {
            Debug.LogFormat("[Passcodes #{0}] Answered {1} which means {2} which is INCORRECT!!! Correct answer was {3}.", moduleId, tempText.ToUpper(), answerGuess, correctAnswers6[stage]);
        }
        return(false);
    }