Exemplo n.º 1
0
 void releasedBlackSubmit(int p)
 {
     if (!(moduleSolved))
     {
         Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}", moduleId, positions[p]);
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
         Vector3 pos = buttonMesh[p].transform.localPosition;
         pos.y = 0.0169f;
         buttonMesh[p].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
         if (solution[numButtonPresses] == (p + 1))
         {
             if (numButtonPresses % 2 == 0)
             {
                 ledMesh[(int)blackButtonSeq[numButtonPresses / 2]].material = ledColors[3];
             }
             else
             {
                 ledMesh[(int)blackButtonSeq[numButtonPresses / 2]].material = ledColors[1];
             }
             numButtonPresses++;
             if (numButtonPresses == 12)
             {
                 flag         = false;
                 moduleSolved = true;
                 coloredHexabuttons.Solve();
             }
         }
         else
         {
             Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting {1}", moduleId, positions[solution[numButtonPresses] - 1]);
             coloredHexabuttons.Strike();
             hexButtons[6].OnHighlight      = delegate { ledMesh[blackLights[6]].material = ledColors[2]; };
             hexButtons[6].OnHighlightEnded = delegate { ledMesh[blackLights[6]].material = ledColors[0]; };
             foreach (int i in buttonIndex)
             {
                 hexButtons[i].OnInteract       = delegate { coloredHexabuttons.StartCoroutine(pressedBlack(i)); return(false); };
                 hexButtons[i].OnInteractEnded  = null;
                 hexButtons[i].OnHighlight      = delegate { ledMesh[blackLights[i]].material = ledColors[2]; };
                 hexButtons[i].OnHighlightEnded = delegate { ledMesh[blackLights[i]].material = ledColors[0]; };
                 ledMesh[i].material            = ledColors[0];
             }
             numButtonPresses = 0;
             flag             = false;
         }
     }
 }
Exemplo n.º 2
0
 void pressedWhite(int n)
 {
     if (!(moduleSolved))
     {
         Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1} which is the color {2}", moduleId, positions[n], whiteBHC[n]);
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         if (solution[numButtonPresses] == whiteBHC[n])
         {
             Vector3 pos = buttonMesh[n].transform.localPosition;
             pos.y = 0.0126f;
             buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
             hexButtons[n].OnInteract       = null;
             hexButtons[n].OnHighlight      = null;
             hexButtons[n].OnHighlightEnded = null;
             buttonMesh[n].material         = buttonColors["ROYGBP".IndexOf(whiteBHC[n])];
             ledMesh[n].material            = ledColors[1];
             numButtonPresses++;
             if (numButtonPresses == 6)
             {
                 moduleSolved = true;
                 coloredHexabuttons.Solve();
             }
         }
         else
         {
             Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting {1} which is the color {2}", moduleId, positions[whiteBHC.IndexOf(solution[numButtonPresses])], solution[numButtonPresses]);
             coloredHexabuttons.Strike();
             foreach (int i in buttonIndex)
             {
                 Vector3 pos = buttonMesh[i].transform.localPosition;
                 pos.y = 0.0169f;
                 buttonMesh[i].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                 buttonMesh[i].material         = buttonColors[6];
                 hexButtons[i].OnInteract       = delegate { pressedWhite(i); return(false); };
                 hexButtons[i].OnHighlight      = delegate { buttonMesh[i].material = buttonColors["ROYGBP".IndexOf(whiteBHC[i])]; };
                 hexButtons[i].OnHighlightEnded = delegate { buttonMesh[i].material = buttonColors[6]; };
                 ledMesh[i].material            = ledColors[0];
             }
             numButtonPresses = 0;
         }
     }
 }
Exemplo n.º 3
0
 void pressedGreenSubmit(int n)
 {
     if (!(moduleSolved))
     {
         Debug.LogFormat("[Colored Hexabuttons #{0}] User submitted {1}, which plays the note {2}.", moduleId, positions[n], "-0123456789A".IndexOf(greenNotes[n]));
         Audio.PlaySoundAtTransform(notes["0123456789A".IndexOf(greenNotes[n])].name, transform);
         if (solution[numButtonPresses] == greenNotes[n])
         {
             Vector3 pos = buttonMesh[n].transform.localPosition;
             pos.y = 0.0126f;
             buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
             numButtonPresses++;
             hexButtons[n].OnInteract = null;
             ledMesh[n].material      = ledColors[1];
             if (numButtonPresses == 6)
             {
                 flag         = false;
                 moduleSolved = true;
                 coloredHexabuttons.Solve();
             }
         }
         else
         {
             Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting note {1} which is on the {2} button!", moduleId, "-0123456789A".IndexOf(solution[n]), positions[greenNotes.IndexOf(solution[numButtonPresses])]);
             coloredHexabuttons.Strike();
             foreach (int i in buttonIndex)
             {
                 Vector3 pos = buttonMesh[i].transform.localPosition;
                 pos.y = 0.0169f;
                 buttonMesh[i].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                 hexButtons[i].OnInteract      = delegate { pressedGreen(i); return(false); };
                 hexButtons[i].OnInteractEnded = delegate { pressedGreenRelease(i); };
                 ledMesh[i].material           = ledColors[0];
             }
             flag = false;
         }
     }
 }
Exemplo n.º 4
0
 void pressedGraySubmit(int n)
 {
     if (!(moduleSolved))
     {
         Debug.LogFormat("[Colored Hexabuttons #{0}] User submitted {1} which has the value of {2}.", moduleId, positions[n], values[n]);
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         if (values[n] == (numButtonPresses + 1))
         {
             Vector3 pos = buttonMesh[n].transform.localPosition;
             pos.y = 0.0126f;
             buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
             numButtonPresses++;
             hexButtons[n].OnInteract = null;
             ledMesh[n].material      = ledColors[1];
             if (numButtonPresses == 6)
             {
                 flag         = false;
                 moduleSolved = true;
                 coloredHexabuttons.Solve();
             }
         }
         else
         {
             Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting a value of {1}!", moduleId, (numButtonPresses + 1));
             coloredHexabuttons.Strike();
             foreach (int i in buttonIndex)
             {
                 Vector3 pos = buttonMesh[i].transform.localPosition;
                 pos.y = 0.0169f;
                 buttonMesh[i].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                 hexButtons[i].OnInteract = delegate { pressedGray(i); return(false); };
                 ledMesh[i].material      = ledColors[0];
             }
             flag = false;
         }
     }
 }
Exemplo n.º 5
0
 void pressedBlue(int n, int p)
 {
     if (!(moduleSolved))
     {
         Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}, which has a value of {2}.", moduleId, positions[TPOrder.IndexOf((n + ""))], p);
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         if (solution[numButtonPresses] == p)
         {
             Vector3 pos = buttonMesh[n].transform.localPosition;
             pos.y = 0.0126f;
             buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
             hexButtons[n].OnInteract = null;
             ledMesh[n].material      = ledColors[1];
             numButtonPresses++;
             if (numButtonPresses == 6)
             {
                 moduleSolved = true;
                 coloredHexabuttons.Solve();
             }
         }
         else
         {
             Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting a value of {1}!", moduleId, solution[numButtonPresses]);
             coloredHexabuttons.Strike();
             foreach (int i in buttonIndex)
             {
                 hexButtons[i].OnInteract = delegate { pressedBlue(i, blueButtonValues[i]); return(false); };
                 Vector3 pos = buttonMesh[i].transform.localPosition;
                 pos.y = 0.0169f;
                 buttonMesh[i].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                 ledMesh[i].material = ledColors[0];
             }
             numButtonPresses = 0;
         }
     }
 }
    public void run()
    {
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated Color: Purple", moduleId);
        int[][] bins =
        {
            new int[] { 1, 1, 1, 1, 1, 1 },
            new int[] { 1, 1, 1, 1, 1, 1 },
            new int[] { 0, 0, 0, 0, 0, 0 },
        };
        string pos1 = "012345";
        string pos0 = "";
        int    num0 = UnityEngine.Random.Range(2, 5);

        for (int aa = 0; aa < num0; aa++)
        {
            pos0 = pos0 + "" + pos1[UnityEngine.Random.Range(0, pos1.Length)];
            bins[0][pos0[aa] - '0'] = 0;
            pos1 = pos1.Replace(pos0[aa] + "", "");
        }
        string pos2 = "012345";

        for (int aa = 0; aa < 2; aa++)
        {
            int n = pos0[UnityEngine.Random.Range(0, pos0.Length)] - '0';
            bins[1][n] = aa;
            pos0       = pos0.Replace(n + "", "");
            pos2       = pos2.Replace(n + "", "");
        }
        for (int aa = 0; aa < 2; aa++)
        {
            int n = pos1[UnityEngine.Random.Range(0, pos1.Length)] - '0';
            bins[1][n] = aa;
            pos1       = pos1.Replace(n + "", "");
            pos2       = pos2.Replace(n + "", "");
        }
        num0 = UnityEngine.Random.Range(0, 3);
        for (int aa = 0; aa < num0; aa++)
        {
            int n = pos2[UnityEngine.Random.Range(0, pos2.Length)] - '0';
            bins[1][n] = 0;
            pos2       = pos2.Replace(n + "", "");
        }
        string[] opers = { "AND", "OR", "XOR", "NAND", "NOR", "XNOR", "->", "<-" };
        int      oper  = UnityEngine.Random.Range(0, 8);

        for (int aa = 0; aa < 6; aa++)
        {
            switch (oper)
            {
            case 0:                    //AND
                if (bins[0][aa] == 1 && bins[1][aa] == 1)
                {
                    bins[2][aa] = 1;
                }
                break;

            case 1:                    //OR
                if (bins[0][aa] == 1 || bins[1][aa] == 1)
                {
                    bins[2][aa] = 1;
                }
                break;

            case 2:                    //XOR
                if (bins[0][aa] != bins[1][aa])
                {
                    bins[2][aa] = 1;
                }
                break;

            case 3:                    //NAND
                if (!(bins[0][aa] == 1 && bins[1][aa] == 1))
                {
                    bins[2][aa] = 1;
                }
                break;

            case 4:                    //NOR
                if (!(bins[0][aa] == 1 || bins[1][aa] == 1))
                {
                    bins[2][aa] = 1;
                }
                break;

            case 5:                    //XNOR
                if (bins[0][aa] == bins[1][aa])
                {
                    bins[2][aa] = 1;
                }
                break;

            case 6:                    //->
                if (bins[1][aa] == 1 || bins[0][aa] == 0)
                {
                    bins[2][aa] = 1;
                }
                break;

            default:                    //<-
                if (bins[0][aa] == 1 || bins[1][aa] == 0)
                {
                    bins[2][aa] = 1;
                }
                break;
            }
        }
        int[] numbers = { 0, 0, 0 };
        for (int aa = 0; aa < 6; aa++)
        {
            for (int bb = 0; bb < 3; bb++)
            {
                if (bins[bb][aa] == 1)
                {
                    switch (aa)
                    {
                    case 0:
                        numbers[bb] += 32;
                        break;

                    case 1:
                        numbers[bb] += 16;
                        break;

                    case 2:
                        numbers[bb] += 8;
                        break;

                    case 3:
                        numbers[bb] += 4;
                        break;

                    case 4:
                        numbers[bb] += 2;
                        break;

                    default:
                        numbers[bb] += 1;
                        break;
                    }
                }
            }
        }
        voiceMessage = new string[6];
        for (int aa = 0; aa < 3; aa++)
        {
            if (numbers[aa] < 10)
            {
                voiceMessage[aa * 2]       = "0";
                voiceMessage[(aa * 2) + 1] = numbers[aa] + "";
            }
            else
            {
                voiceMessage[aa * 2]       = (numbers[aa] / 10) + "";
                voiceMessage[(aa * 2) + 1] = (numbers[aa] % 10) + "";
            }
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated 6 digit number: {1}{2}{3}{4}{5}{6}", moduleId, voiceMessage[0], voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated left binary: {1}{2}{3}{4}{5}{6}", moduleId, bins[0][0], bins[0][1], bins[0][2], bins[0][3], bins[0][4], bins[0][5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated right binary: {1}{2}{3}{4}{5}{6}", moduleId, bins[1][0], bins[1][1], bins[1][2], bins[1][3], bins[1][4], bins[1][5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Resulting binary: {1}{2}{3}{4}{5}{6}", moduleId, bins[2][0], bins[2][1], bins[2][2], bins[2][3], bins[2][4], bins[2][5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Logic operator used: {1}", moduleId, opers[oper]);
        hexButtons[6].OnInteract = delegate { pressedPurpleCenter(); return(false); };
        solution         = new int[6];
        numButtonPresses = 0;
        for (int aa = 0; aa < 10; aa++)
        {
            for (int bb = 0; bb < 6; bb++)
            {
                if (aa == voiceMessage[bb][0] - '0')
                {
                    solution[bb] = numButtonPresses + 0;
                    numButtonPresses++;
                    if (numButtonPresses == 6)
                    {
                        break;
                    }
                }
            }
            if (numButtonPresses == 6)
            {
                break;
            }
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Buttons to be read in this order: {1} {2} {3} {4} {5} {6}", moduleId, positions[solution[0]], positions[solution[1]], positions[solution[2]], positions[solution[3]], positions[solution[4]], positions[solution[5]]);
        numbers[0] = 0;
        numbers[1] = 0;
        numbers[2] = 0;
        for (int aa = 0; aa < 6; aa++)
        {
            bins[0][aa] = UnityEngine.Random.Range(0, 2);
            bins[1][aa] = UnityEngine.Random.Range(0, 2);
            bins[2][aa] = 0;
            switch (oper)
            {
            case 0:                    //AND
                if (bins[0][aa] == 1 && bins[1][aa] == 1)
                {
                    bins[2][aa] = 1;
                }
                break;

            case 1:                    //OR
                if (bins[0][aa] == 1 || bins[1][aa] == 1)
                {
                    bins[2][aa] = 1;
                }
                break;

            case 2:                    //XOR
                if (bins[0][aa] != bins[1][aa])
                {
                    bins[2][aa] = 1;
                }
                break;

            case 3:                    //NAND
                if (!(bins[0][aa] == 1 && bins[1][aa] == 1))
                {
                    bins[2][aa] = 1;
                }
                break;

            case 4:                    //NOR
                if (!(bins[0][aa] == 1 || bins[1][aa] == 1))
                {
                    bins[2][aa] = 1;
                }
                break;

            case 5:                    //XNOR
                if (bins[0][aa] == bins[1][aa])
                {
                    bins[2][aa] = 1;
                }
                break;

            case 6:                    //->
                if (bins[1][aa] == 1 || bins[0][aa] == 0)
                {
                    bins[2][aa] = 1;
                }
                break;

            default:                    //<-
                if (bins[0][aa] == 1 || bins[1][aa] == 0)
                {
                    bins[2][aa] = 1;
                }
                break;
            }
            for (int bb = 0; bb < 3; bb++)
            {
                if (bins[bb][aa] == 1)
                {
                    switch (aa)
                    {
                    case 0:
                        numbers[bb] += 32;
                        break;

                    case 1:
                        numbers[bb] += 16;
                        break;

                    case 2:
                        numbers[bb] += 8;
                        break;

                    case 3:
                        numbers[bb] += 4;
                        break;

                    case 4:
                        numbers[bb] += 2;
                        break;

                    default:
                        numbers[bb] += 1;
                        break;
                    }
                }
            }
        }
        string randomAlpha = "VOT6C8GU9NJRAX3Q5DM12FPEBZKYW7SLIH40";

        foreach (int i in buttonIndex)
        {
            int n;
            switch (bins[0][i] + "" + bins[1][i])
            {
            case "00":
                n = 0;
                break;

            case "01":
                n = 1;
                break;

            case "10":
                n = 2;
                break;

            default:
                n = 3;
                break;
            }
            buttonText[solution[i]].text = randomAlpha[n + (4 * UnityEngine.Random.Range(0, 9))] + "";
        }
        string numberDigits = "";

        for (int aa = 0; aa < 3; aa++)
        {
            if (numbers[aa] < 10)
            {
                numberDigits = numberDigits + "0" + numbers[aa];
            }
            else
            {
                numberDigits = numberDigits + "" + numbers[aa];
            }
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated text on buttons in reading order: {1}{2}{3}{4}{5}{6}", moduleId, buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated left binary: {1}{2}{3}{4}{5}{6}", moduleId, bins[0][0], bins[0][1], bins[0][2], bins[0][3], bins[0][4], bins[0][5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated right binary: {1}{2}{3}{4}{5}{6}", moduleId, bins[1][0], bins[1][1], bins[1][2], bins[1][3], bins[1][4], bins[1][5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Resulting binary: {1}{2}{3}{4}{5}{6}", moduleId, bins[2][0], bins[2][1], bins[2][2], bins[2][3], bins[2][4], bins[2][5]);
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated 6 digit number: {1}", moduleId, numberDigits);
        numButtonPresses = 0;
        for (int aa = 0; aa < 10; aa++)
        {
            for (int bb = 0; bb < 6; bb++)
            {
                if (aa == numberDigits[bb] - '0')
                {
                    solution[bb] = numButtonPresses + 0;
                    numButtonPresses++;
                    if (numButtonPresses == 6)
                    {
                        break;
                    }
                }
            }
            if (numButtonPresses == 6)
            {
                break;
            }
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Solution: {1} {2} {3} {4} {5} {6}", moduleId, positions[solution[0]], positions[solution[1]], positions[solution[2]], positions[solution[3]], positions[solution[4]], positions[solution[5]]);
        numButtonPresses = 0;
        foreach (int i in buttonIndex)
        {
            hexButtons[i].OnInteract = delegate { pressedPurple(i); return(false); }
        }
        ;
    }

    void pressedPurple(int n)
    {
        if (!(moduleSolved))
        {
            Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}.", moduleId, positions[n]);
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            if (solution[numButtonPresses] == n)
            {
                Vector3 pos = buttonMesh[n].transform.localPosition;
                pos.y = 0.0126f;
                buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                hexButtons[n].OnInteract = null;
                ledMesh[n].material      = ledColors[1];
                numButtonPresses++;
                if (numButtonPresses == 6)
                {
                    moduleSolved = true;
                    coloredHexabuttons.Solve();
                }
            }
            else
            {
                Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting the {1} button!", moduleId, positions[solution[numButtonPresses]]);
                coloredHexabuttons.Strike();
                foreach (int i in buttonIndex)
                {
                    Vector3 pos = buttonMesh[i].transform.localPosition;
                    pos.y = 0.0169f;
                    buttonMesh[i].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                    hexButtons[i].OnInteract = delegate { pressedPurple(i); return(false); };
                    ledMesh[i].material      = ledColors[0];
                }
                numButtonPresses = 0;
            }
        }
    }

    void pressedPurpleCenter()
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Vector3 pos = buttonMesh[6].transform.localPosition;
            pos.y = 0.0126f;
            buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            coloredHexabuttons.StartCoroutine(playAudio());
        }
    }

    IEnumerator playAudio()
    {
        hexButtons[6].OnInteract = null;
        yield return(new WaitForSeconds(0.5f));

        for (int aa = 0; aa < voiceMessage.Length; aa++)
        {
            Audio.PlaySoundAtTransform(voiceMessage[aa], transform);
            yield return(new WaitForSeconds(1.5f));
        }
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
        Vector3 pos = buttonMesh[6].transform.localPosition;

        pos.y = 0.0169f;
        buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
        hexButtons[6].OnInteract = delegate { pressedPurpleCenter(); return(false); };
    }
}
    void pressedYellow(int n, int d)
    {
        if (!(moduleSolved))
        {
            Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}, which is {2}.", moduleId, positions[n], dirNames[d]);
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Vector3 pos = buttonMesh[n].transform.localPosition;
            pos.y = 0.0126f;
            buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            switch (d)
            {
            case 0:                    //N
                if (yellowMaze[yellowRC[0] - 1][yellowRC[1]].Equals("W"))
                {
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! There is a wall to the N of {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                    coloredHexabuttons.Strike();
                }
                else
                {
                    yellowRC[0]    -= 4;
                    voiceMessage[0] = yellowMaze[yellowRC[0]][yellowRC[1]][0] + "";
                    voiceMessage[1] = yellowMaze[yellowRC[0]][yellowRC[1]][1] + "";
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Moving N, current space is now {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                }
                break;

            case 1:                    //NE
                if (yellowMaze[yellowRC[0] - 1][yellowRC[1] + 1].Equals("W"))
                {
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! There is a wall to the NE of {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                    coloredHexabuttons.Strike();
                }
                else
                {
                    yellowRC[0]    -= 2;
                    yellowRC[1]    += 2;
                    voiceMessage[0] = yellowMaze[yellowRC[0]][yellowRC[1]][0] + "";
                    voiceMessage[1] = yellowMaze[yellowRC[0]][yellowRC[1]][1] + "";
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Moving NE, current space is now {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                }
                break;

            case 2:                    //SE
                if (yellowMaze[yellowRC[0] + 1][yellowRC[1] + 1].Equals("W"))
                {
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! There is a wall to the SE of {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                    coloredHexabuttons.Strike();
                }
                else
                {
                    yellowRC[0]    += 2;
                    yellowRC[1]    += 2;
                    voiceMessage[0] = yellowMaze[yellowRC[0]][yellowRC[1]][0] + "";
                    voiceMessage[1] = yellowMaze[yellowRC[0]][yellowRC[1]][1] + "";
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Moving SE, current space is now {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                }
                break;

            case 3:                    //S
                if (yellowMaze[yellowRC[0] + 1][yellowRC[1]].Equals("W"))
                {
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! There is a wall to the S of {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                    coloredHexabuttons.Strike();
                }
                else
                {
                    yellowRC[0]    += 4;
                    voiceMessage[0] = yellowMaze[yellowRC[0]][yellowRC[1]][0] + "";
                    voiceMessage[1] = yellowMaze[yellowRC[0]][yellowRC[1]][1] + "";
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Moving S, current space is now {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                }
                break;

            case 4:                    //SW
                if (yellowMaze[yellowRC[0] + 1][yellowRC[1] - 1].Equals("W"))
                {
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! There is a wall to the SW of {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                    coloredHexabuttons.Strike();
                }
                else
                {
                    yellowRC[0]    += 2;
                    yellowRC[1]    -= 2;
                    voiceMessage[0] = yellowMaze[yellowRC[0]][yellowRC[1]][0] + "";
                    voiceMessage[1] = yellowMaze[yellowRC[0]][yellowRC[1]][1] + "";
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Moving SW, current space is now {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                }
                break;

            default:                    //NW
                if (yellowMaze[yellowRC[0] - 1][yellowRC[1] - 1].Equals("W"))
                {
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! There is a wall to the NW of {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                    coloredHexabuttons.Strike();
                }
                else
                {
                    yellowRC[0]    -= 2;
                    yellowRC[1]    -= 2;
                    voiceMessage[0] = yellowMaze[yellowRC[0]][yellowRC[1]][0] + "";
                    voiceMessage[1] = yellowMaze[yellowRC[0]][yellowRC[1]][1] + "";
                    Debug.LogFormat("[Colored Hexabuttons #{0}] Moving NW, current space is now {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
                }
                break;
            }
            if (voiceMessage[0] == voiceMessage[2] && voiceMessage[1] == voiceMessage[3])
            {
                moduleSolved = true;
                coloredHexabuttons.Solve();
            }
        }
    }
    public void run()
    {
        numButtonPresses = 0;
        moduleSolved     = false;
        Debug.LogFormat("[Colored Hexabuttons #{0}] Color Generated: Orange", moduleId);
        string[] wordList =
        {
            "ABACUS", "ACTION", "ADVICE", "AFFECT", "AGENCY", "ALMOND", "AMOUNT", "ANARCH", "APPEAR", "ARRIVE",
            "BALLAD", "BAKERY", "BEACON", "BINARY", "BLEACH", "BRONZE", "BOXING", "BREEZE", "BELIEF", "BITTER",
            "CACTUS", "CEREAL", "CHERRY", "CITRUS", "CLOSET", "COFFEE", "CRISIS", "CURSOR", "CONVEX", "CELLAR",
            "DANGER", "DEBRIS", "DINNER", "DOODLE", "DRIVER", "DUSTER", "DEFEAT", "DIRECT", "DOMINO", "DRAWER",
            "EASTER", "EDITOR", "EFFECT", "EGGNOG", "EMBLEM", "ENROLL", "EQUALS", "ERASER", "ESCAPE", "EXPERT",
            "FABRIC", "FELINE", "FILTER", "FLAVOR", "FOREST", "FREEZE", "FUTURE", "FACADE", "FOLLOW", "FINISH",
            "GALLON", "GEYSER", "GALAXY", "GLANCE", "GROWTH", "GUTTER", "GAMBLE", "GERBIL", "GINGER", "GIVING",
            "HAMMER", "HEIGHT", "HIDING", "HOLLOW", "HUNTER", "HYBRID", "HANDLE", "HELMET", "HAZARD", "HURDLE",
            "ICICLE", "IMPORT", "INSERT", "ITALIC", "IMPAIR", "INCOME", "IMPACT", "INSULT", "INSECT", "INTENT",
            "JESTER", "JINGLE", "JOGGER", "JUNGLE", "JERSEY", "JOCKEY", "JUGGLE", "JUMBLE", "JUNIOR", "JAILER",
            "KETTLE", "KIDNEY", "KNIGHT", "KENNEL", "KINGLY", "KITTEN", "KRAKEN", "KINDLY", "KERNEL", "KEEPER",
            "LAGOON", "LEADER", "LIMBER", "LOCKET", "LUXURY", "LYCHEE", "LADDER", "LEGACY", "LIQUID", "LOTION",
            "MAGNET", "MEADOW", "MIDDLE", "MOMENT", "MUSEUM", "MYSTIC", "MATRIX", "MELODY", "MIRROR", "MUFFIN",
            "NAPKIN", "NEEDLE", "NICKEL", "NOBODY", "NUTMEG", "NATION", "NECTAR", "NINETY", "NOTICE", "NARROW",
            "OBJECT", "OCELOT", "OFFICE", "OPTION", "ORANGE", "OUTPUT", "OXYGEN", "OYSTER", "OFFSET", "OUTFIT",
            "PALACE", "PEBBLE", "PICNIC", "PLAQUE", "POCKET", "PROFIT", "PUDDLE", "PENCIL", "PIGEON", "POETRY",
            "QUARTZ", "QUIVER", "QUARRY", "QUEASY", "RABBIT", "REFLEX", "RHYTHM", "RIBBON", "ROCKET", "RAFFLE",
            "RECIPE", "RUBBER", "RADIUS", "RECORD", "SAILOR", "SCHEME", "SEARCH", "SHADOW", "SIGNAL", "SLEIGH",
            "SMUDGE", "SNEEZE", "SOCIAL", "SQUEAK", "TAILOR", "TEACUP", "THIRST", "TICKET", "TOGGLE", "TRAVEL",
            "TUNNEL", "TWITCH", "TEMPLE", "THEORY", "UNISON", "UPWARD", "UTMOST", "UTOPIA", "UNIQUE", "UNREST",
            "UNSEEN", "UNWRAP", "UNVIEL", "UPHOLD", "VACUUM", "VECTOR", "VIEWER", "VORTEX", "VALLEY", "VERBAL",
            "VICTIM", "VOLUME", "VANISH", "VERMIN", "WAFFLE", "WEALTH", "WHEEZE", "WIDGET", "WOLVES", "WRENCH",
            "WALNUT", "WEIGHT", "WISDOM", "WONDER", "YEARLY", "YELLOW", "YONDER", "ZEALOT", "ZEBRAS", "ZODIAC"
        };
        string temp = wordList[UnityEngine.Random.Range(0, wordList.Length)].ToUpper();

        solution = temp.ToUpper();
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated Word: {1}", moduleId, solution);
        scramble = "";
        for (int aa = 0; aa < 6; aa++)
        {
            int pos = UnityEngine.Random.Range(0, temp.Length);
            scramble = scramble + "" + temp[pos];
            temp     = temp.Remove(pos, 1);
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Scrambled Word: {1}", moduleId, scramble);
        foreach (int i in buttonIndex)
        {
            hexButtons[i].OnInteract = delegate { pressedOrange(i); return(false); }
        }
        ;
        hexButtons[6].OnInteract = delegate { pressedOrangeCenter(); return(false); };
        string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        switch (UnityEngine.Random.Range(0, 7))
        {
        case 0:                //Atbash

            voiceMessage    = new string[1];
            voiceMessage[0] = "ATBASH";
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[25 - alpha.IndexOf(scramble[aa])] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using ATBASH: {1}{2}{3}{4}{5}{6}", moduleId, buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 1:                //Caesar
            voiceMessage    = new string[3];
            voiceMessage[0] = "CAESAR";
            int r1 = UnityEngine.Random.Range(1, 26);
            if (r1 < 10)
            {
                voiceMessage[1] = "0";
                voiceMessage[2] = r1 + "";
            }
            else
            {
                voiceMessage[1] = (r1 / 10) + "";
                voiceMessage[2] = (r1 % 10) + "";
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[mod(alpha.IndexOf(scramble[aa]) - r1, 26)] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using CAESAR {1}{2}: {3}{4}{5}{6}{7}{8}", moduleId, voiceMessage[1], voiceMessage[2], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 2:                //Condi
            voiceMessage    = new string[3];
            voiceMessage[0] = "CONDI";
            int r2 = UnityEngine.Random.Range(1, 26);
            if (r2 < 10)
            {
                voiceMessage[1] = "0";
                voiceMessage[2] = r2 + "";
            }
            else
            {
                voiceMessage[1] = (r2 / 10) + "";
                voiceMessage[2] = (r2 % 10) + "";
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[mod(alpha.IndexOf(scramble[aa]) + r2, 26)] + "";
                r2 = alpha.IndexOf(scramble[aa]) + 1;
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using CONDI {1}{2}: {3}{4}{5}{6}{7}{8}", moduleId, voiceMessage[1], voiceMessage[2], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 3:                //Monoalphabetic
            voiceMessage    = new string[7];
            voiceMessage[0] = "MONOALPHABETIC";
            temp            = alpha.ToUpper();
            for (int aa = 1; aa < 7; aa++)
            {
                voiceMessage[aa] = temp[UnityEngine.Random.Range(0, temp.Length)] + "";
                temp             = temp.Replace(voiceMessage[aa], "");
            }
            for (int aa = 6; aa >= 1; aa--)
            {
                temp = voiceMessage[aa] + "" + temp;
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = temp[alpha.IndexOf(scramble[aa])] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using MONOALPHABETIC {1}{2}{3}{4}{5}{6}: {7}{8}{9}{10}{11}{12}", moduleId, voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5], voiceMessage[6], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 4:                //Porta
            voiceMessage    = new string[7];
            voiceMessage[0] = "PORTA";
            temp            = alpha.ToUpper();
            for (int aa = 1; aa < 7; aa++)
            {
                voiceMessage[aa] = temp[UnityEngine.Random.Range(0, temp.Length)] + "";
                temp             = temp.Replace(voiceMessage[aa], "");
            }
            string[] portaChart =
            {
                "NOPQRSTUVWXYZ",
                "OPQRSTUVWXYZN",
                "PQRSTUVWXYZNO",
                "QRSTUVWXYZNOP",
                "RSTUVWXYZNOPQ",
                "STUVWXYZNOPQR",
                "TUVWXYZNOPQRS",
                "UVWXYZNOPQRST",
                "VWXYZNOPQRSTU",
                "WXYZNOPQRSTUV",
                "XYZNOPQRSTUVW",
                "YZNOPQRSTUVWX",
                "ZNOPQRSTUVWXY"
            };
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                if (alpha.IndexOf(scramble[aa]) < 13)
                {
                    buttonText[aa].text = portaChart[alpha.IndexOf(voiceMessage[aa + 1]) / 2][alpha.IndexOf(scramble[aa])] + "";
                }
                else
                {
                    buttonText[aa].text = alpha[portaChart[alpha.IndexOf(voiceMessage[aa + 1]) / 2].IndexOf(scramble[aa])] + "";
                }
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using PORTA {1}{2}{3}{4}{5}{6}: {7}{8}{9}{10}{11}{12}", moduleId, voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5], voiceMessage[6], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        case 5:                //Ragbaby
            voiceMessage    = new string[3];
            voiceMessage[0] = "RAGBABY";
            int r3 = UnityEngine.Random.Range(0, 26);
            if (r3 < 10)
            {
                voiceMessage[1] = "0";
                voiceMessage[2] = r3 + "";
            }
            else
            {
                voiceMessage[1] = (r3 / 10) + "";
                voiceMessage[2] = (r3 % 10) + "";
            }
            for (int aa = 0; aa < 6; aa++)
            {
                buttonText[aa].color = Color.black;
                buttonText[aa].text  = alpha[mod(alpha.IndexOf(scramble[aa]) + r3, 26)] + "";
                r3++;
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using RAGBABY {1}{2}: {3}{4}{5}{6}{7}{8}", moduleId, voiceMessage[1], voiceMessage[2], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;

        default:                //Vigenere
            voiceMessage    = new string[7];
            voiceMessage[0] = "VIGENERE";
            temp            = alpha.ToUpper();
            string alpha2 = "-ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            for (int aa = 1; aa < 7; aa++)
            {
                voiceMessage[aa] = temp[UnityEngine.Random.Range(0, temp.Length)] + "";
                temp             = temp.Replace(voiceMessage[aa], "");
                int r4 = alpha2.IndexOf(scramble[aa - 1]) + alpha2.IndexOf(voiceMessage[aa]);
                while (r4 > 26)
                {
                    r4 -= 26;
                }
                buttonText[aa - 1].color = Color.black;
                buttonText[aa - 1].text  = alpha2[r4] + "";
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] Encryption using VIGENERE {1}{2}{3}{4}{5}{6}: {7}{8}{9}{10}{11}{12}", moduleId, voiceMessage[1], voiceMessage[2], voiceMessage[3], voiceMessage[4], voiceMessage[5], voiceMessage[6], buttonText[0].text, buttonText[1].text, buttonText[2].text, buttonText[3].text, buttonText[4].text, buttonText[5].text);
            break;
        }
    }

    void pressedOrange(int n)
    {
        if (!(moduleSolved))
        {
            Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}. Which is the decrypted letter {2}.", moduleId, positions[n], scramble[n]);
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            if (solution[numButtonPresses] == scramble[n])
            {
                Vector3 pos = buttonMesh[n].transform.localPosition;
                pos.y = 0.0126f;
                buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                hexButtons[n].OnInteract = null;
                ledMesh[n].material      = ledColors[1];
                if (numButtonPresses == 5)
                {
                    moduleSolved = true;
                    coloredHexabuttons.Solve();
                }
                else
                {
                    numButtonPresses++;
                }
            }
            else
            {
                numButtonPresses = 0;
                Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting {1}!", moduleId, solution[numButtonPresses]);
                coloredHexabuttons.Strike();
                for (int aa = 0; aa < 6; aa++)
                {
                    Vector3 pos = buttonMesh[aa].transform.localPosition;
                    pos.y = 0.0169f;
                    buttonMesh[aa].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                    ledMesh[aa].material = ledColors[0];
                }
                foreach (int i in buttonIndex)
                {
                    hexButtons[i].OnInteract = delegate { pressedOrange(i); return(false); }
                }
                ;
            }
        }
    }

    void pressedOrangeCenter()
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Vector3 pos = buttonMesh[6].transform.localPosition;
            pos.y = 0.0126f;
            buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            coloredHexabuttons.StartCoroutine(playAudio());
        }
    }

    IEnumerator playAudio()
    {
        hexButtons[6].OnInteract = null;
        yield return(new WaitForSeconds(0.5f));

        for (int aa = 0; aa < voiceMessage.Length; aa++)
        {
            Audio.PlaySoundAtTransform(voiceMessage[aa], transform);
            yield return(new WaitForSeconds(1.5f));
        }
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
        Vector3 pos = buttonMesh[6].transform.localPosition;

        pos.y = 0.0169f;
        buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
        hexButtons[6].OnInteract = delegate { pressedOrangeCenter(); return(false); };
    }

    private int mod(int n, int m)
    {
        while (n < 0)
        {
            n += 26;
        }
        return(n % 26);
    }
}
    void pressedBrown(int n, int c)
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            string results;
            if (flip == -1)
            {
                string[] r = { getResult(chemicals[c], chemicals[absent[0]]), getResult(chemicals[c], chemicals[absent[1]]) };
                if (r[0].Equals(solution[numButtonPresses]) && r[1].Equals(solution[numButtonPresses]))
                {
                    flip    = -1;
                    results = getResult(chemicals[c], chemicals[absent[0]]);
                }
                else if (r[0].Equals(solution[numButtonPresses]))
                {
                    flip    = 0;
                    results = getResult(chemicals[c], chemicals[absent[0]]);
                }
                else
                {
                    flip    = 1;
                    results = getResult(chemicals[c], chemicals[absent[1]]);
                }
            }
            else
            {
                results = getResult(chemicals[c], chemicals[absent[flip]]);
            }
            Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}! This creates a {2}", moduleId, positions[n], results);
            if (results.Equals(solution[numButtonPresses]))
            {
                Vector3 pos = buttonMesh[n].transform.localPosition;
                pos.y = 0.0126f;
                buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                hexButtons[n].OnInteract = null;
                ledMesh[n].material      = ledColors[1];
                numButtonPresses++;
                flip = (flip + 1) % 2;
                if (numButtonPresses == 6)
                {
                    moduleSolved = true;
                    coloredHexabuttons.Solve();
                }
            }
            else
            {
                Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting {1}!", moduleId, solution[numButtonPresses]);
                coloredHexabuttons.Strike();
                numButtonPresses = 0;
                flip             = -1;
                for (int aa = 0; aa < 6; aa++)
                {
                    Vector3 pos = buttonMesh[aa].transform.localPosition;
                    pos.y = 0.0169f;
                    buttonMesh[aa].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                    ledMesh[aa].material = ledColors[0];
                }
                foreach (int i in buttonIndex)
                {
                    hexButtons[i].OnInteract = delegate { pressedBrown(i, present[i]); return(false); }
                }
                ;
            }
        }
    }

    string getResult(string c1, string c2)
    {
        for (int aa = 0; aa < 3; aa++)
        {
            if (c1[aa * 2] != c2[aa * 2] && c1[(aa * 2) + 1] == c2[(aa * 2) + 1])
            {
                return("RGB"[aa] + "" + c1[(aa * 2) + 1]);
            }
        }
        return("N");
    }

    void pressedBrownCenter()
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Vector3 pos = buttonMesh[6].transform.localPosition;
            pos.y = 0.0126f;
            buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            coloredHexabuttons.StartCoroutine(playAudio());
            numButtonPresses = 0;
            flip             = -1;
            for (int aa = 0; aa < 6; aa++)
            {
                pos   = buttonMesh[aa].transform.localPosition;
                pos.y = 0.0169f;
                buttonMesh[aa].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                ledMesh[aa].material = ledColors[0];
            }
            foreach (int i in buttonIndex)
            {
                hexButtons[i].OnInteract = delegate { pressedBrown(i, present[i]); return(false); }
            }
            ;
        }
    }

    IEnumerator playAudio()
    {
        hexButtons[6].OnInteract = null;
        yield return(new WaitForSeconds(0.5f));

        for (int aa = 0; aa < voiceMessage.Length; aa++)
        {
            Audio.PlaySoundAtTransform(voiceMessage[aa], transform);
            yield return(new WaitForSeconds(1.5f));
        }
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
        Vector3 pos = buttonMesh[6].transform.localPosition;

        pos.y = 0.0169f;
        buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
        hexButtons[6].OnInteract = delegate { pressedBrownCenter(); return(false); };
    }
}
Exemplo n.º 10
0
    public void run()
    {
        moduleSolved = false;
        Debug.LogFormat("[Colored Hexabuttons #{0}] Color Generated: Red", moduleId);
        foreach (int i in buttonIndex)
        {
            hexButtons[i].OnInteract = delegate { pressedRed(buttonIndex[i]); return(false); }
        }
        ;
        hexButtons[6].OnInteract = delegate { pressedRedCenter(); return(false); };
        int[][] chart =
        {
            new int[6] {
                2, 4, 5, 1, 0, 3
            },
            new int[6] {
                1, 5, 3, 0, 2, 4
            },
            new int[6] {
                5, 4, 3, 1, 2, 0
            },
            new int[6] {
                1, 0, 2, 3, 4, 5
            },
            new int[6] {
                3, 0, 1, 2, 5, 4
            },
            new int[6] {
                5, 0, 1, 2, 4, 3
            },
            new int[6] {
                4, 2, 3, 5, 0, 1
            },
            new int[6] {
                0, 4, 5, 1, 3, 2
            },
            new int[6] {
                0, 5, 3, 2, 1, 4
            },
            new int[6] {
                4, 3, 5, 1, 2, 0
            },
            new int[6] {
                2, 0, 3, 4, 5, 1
            },
            new int[6] {
                2, 5, 4, 3, 1, 0
            },
            new int[6] {
                3, 1, 0, 4, 2, 5
            },
            new int[6] {
                1, 4, 5, 2, 3, 0
            },
            new int[6] {
                3, 2, 4, 5, 0, 1
            },
            new int[6] {
                5, 2, 4, 3, 0, 1
            },
            new int[6] {
                5, 3, 2, 0, 1, 4
            },
            new int[6] {
                5, 1, 0, 4, 3, 2
            },
            new int[6] {
                4, 0, 1, 2, 3, 5
            },
            new int[6] {
                1, 3, 4, 5, 0, 2
            },
            new int[6] {
                3, 5, 2, 1, 4, 0
            },
            new int[6] {
                0, 1, 2, 3, 4, 5
            },
            new int[6] {
                0, 2, 1, 4, 5, 3
            },
            new int[6] {
                2, 1, 0, 5, 3, 4
            },
            new int[6] {
                4, 1, 0, 3, 5, 2
            },
            new int[6] {
                0, 3, 4, 5, 2, 1
            }
        };
        int pos1 = UnityEngine.Random.Range(0, chart.Length);
        int pos2 = UnityEngine.Random.Range(0, 6);

        voiceMessage = new string[2] {
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[pos1] + "", (pos2 + 1) + ""
        };
        Debug.LogFormat("[Colored Hexabuttons #{0}] Generated Message: {1}{2}", moduleId, voiceMessage[0], voiceMessage[1]);
        solution = new int[6];
        string output = "";

        for (int aa = 0; aa < 6; aa++)
        {
            solution[aa] = chart[pos1][(pos2 + aa) % 6];
            output       = output + "" + positions[solution[aa]] + " ";
        }
        Debug.LogFormat("[Colored Hexabuttons #{0}] Solution: {1}", moduleId, output);
        numButtonPresses = 0;
    }

    void pressedRed(int n)
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Debug.LogFormat("[Colored Hexabuttons #{0}] User pressed {1}", moduleId, positions[n]);
            if (solution[numButtonPresses] == n)
            {
                Vector3 pos = buttonMesh[n].transform.localPosition;
                pos.y = 0.0126f;
                buttonMesh[n].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                hexButtons[n].OnInteract = null;
                ledMesh[n].material      = ledColors[1];
                if (numButtonPresses == 5)
                {
                    moduleSolved = true;
                    coloredHexabuttons.Solve();
                }
                else
                {
                    numButtonPresses++;
                }
            }
            else
            {
                numButtonPresses = 0;
                Debug.LogFormat("[Colored Hexabuttons #{0}] Strike! I was expecting {1}!", moduleId, positions[solution[numButtonPresses]]);
                coloredHexabuttons.Strike();
                for (int aa = 0; aa < 6; aa++)
                {
                    Vector3 pos = buttonMesh[aa].transform.localPosition;
                    pos.y = 0.0169f;
                    buttonMesh[aa].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
                    ledMesh[aa].material = ledColors[0];
                }
                foreach (int i in buttonIndex)
                {
                    hexButtons[i].OnInteract = delegate { pressedRed(buttonIndex[i]); return(false); }
                }
                ;
            }
        }
    }

    void pressedRedCenter()
    {
        if (!(moduleSolved))
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            Vector3 pos = buttonMesh[6].transform.localPosition;
            pos.y = 0.0126f;
            buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
            coloredHexabuttons.StartCoroutine(playAudio());
        }
    }

    IEnumerator playAudio()
    {
        hexButtons[6].OnInteract = null;
        yield return(new WaitForSeconds(0.5f));

        for (int aa = 0; aa < voiceMessage.Length; aa++)
        {
            Audio.PlaySoundAtTransform(voiceMessage[aa], transform);
            yield return(new WaitForSeconds(1.5f));
        }
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
        Vector3 pos = buttonMesh[6].transform.localPosition;

        pos.y = 0.0169f;
        buttonMesh[6].transform.localPosition = new Vector3(pos.x, pos.y, pos.z);
        hexButtons[6].OnInteract = delegate { pressedRedCenter(); return(false); };
    }
}