void ZonePress(KMSelectable zone)
 {
     if (moduleSolved)
     {
         return;
     }
     if (zone.name == "AztecSelectable" && !aztecSolved)
     {
         zone.AddInteractionPunch();
         Audio.PlaySoundAtTransform("sting", transform);
         aztecTimer.text     = "0:" + aztecTime.ToString("00");
         aztecGuessText.text = "?";
         surface.material    = surfaceOptions[1];
         zones[0].SetActive(false);
         zones[1].SetActive(true);
         StartCoroutine(AztecTimer());
         Debug.LogFormat("[The Crystal Maze #{0}] Welcome to Aztec world! Your target weight is {1}kg. Your buttons will switch every {2} presses.", moduleId, aztecTargetWeight, aztecReset);
     }
     else if (zone.name == "IndustrialSelectable" && !industrialSolved)
     {
         zone.AddInteractionPunch();
         Audio.PlaySoundAtTransform("sting", transform);
         industrialTimer.text    = "0:" + industrialTime.ToString("00");
         displayedDigit          = UnityEngine.Random.Range(0, 10);
         displayedDigitText.text = displayedDigit.ToString();
         surface.material        = surfaceOptions[2];
         zones[0].SetActive(false);
         zones[2].SetActive(true);
         StartCoroutine(IndustrialTimer());
         Debug.LogFormat("[The Crystal Maze #{0}] Welcome to Industrial world! Your serial number is {1}. The reverse digit is {2}.", moduleId, serialNumber, industrialZ);
     }
     else if (zone.name == "FuturisticSelectable" && !futuristicSolved)
     {
         zone.AddInteractionPunch();
         Audio.PlaySoundAtTransform("sting", transform);
         futuristicTimer.text = "0:" + futuristicTime.ToString("00");
         for (int i = 0; i <= 2; i++)
         {
             indicatorLightLeft[i].material  = indicatorOptions[0];
             indicatorLightRight[i].material = indicatorOptions[0];
         }
         surface.material = surfaceOptions[3];
         zones[0].SetActive(false);
         zones[3].SetActive(true);
         StartCoroutine(FutureScreen1());
         StartCoroutine(FutureScreen2());
         StartCoroutine(FutureScreen3());
         StartCoroutine(FuturisticTimer());
         Debug.LogFormat("[The Crystal Maze #{0}] Welcome to Futuristic world!", moduleId);
         Debug.LogFormat("[The Crystal Maze #{0}] The screen 1 words are {1}, {2} & {3}. The screen 1 colours are {4}, {5} & {6}.", moduleId, screen1Words[0], screen1Words[1], screen1Words[2], screen1ColorNames[0], screen1ColorNames[1], screen1ColorNames[2]);
         Debug.LogFormat("[The Crystal Maze #{0}] The screen 2 words are {1}, {2} & {3}. The screen 2 colours are {4}, {5} & {6}.", moduleId, screen2Words[0], screen2Words[1], screen2Words[2], screen2ColorNames[0], screen2ColorNames[1], screen2ColorNames[2]);
         Debug.LogFormat("[The Crystal Maze #{0}] The screen 3 words are {1}, {2} & {3}. The screen 3 colours are {4}, {5} & {6}.", moduleId, screen3Words[0], screen3Words[1], screen3Words[2], screen3ColorNames[0], screen3ColorNames[1], screen3ColorNames[2]);
         Debug.LogFormat("[The Crystal Maze #{0}] The screen 1 anomaly is {1} colour, {2} word.", moduleId, correctColorsLog[0], correctWords[0]);
         Debug.LogFormat("[The Crystal Maze #{0}] The screen 2 anomaly is {1} colour, {2} word.", moduleId, correctColorsLog[1], correctWords[1]);
         Debug.LogFormat("[The Crystal Maze #{0}] The screen 3 anomaly is {1} colour, {2} word.", moduleId, correctColorsLog[2], correctWords[2]);
     }
     else if (zone.name == "MedievalSelectable" && !medievalSolved)
     {
         zone.AddInteractionPunch();
         Audio.PlaySoundAtTransform("sting", transform);
         arrow[0].enabled   = false;
         arrow[1].enabled   = false;
         medievalTimer.text = "0:" + medievalTime.ToString("00");
         surface.material   = surfaceOptions[4];
         zones[0].SetActive(false);
         zones[4].SetActive(true);
         StartCoroutine(MedievalTimer());
         Debug.LogFormat("[The Crystal Maze #{0}] Welcome to Medieval world! Your chosen circles are {1} {2}; {3} {4}; {5} {6} & {7} {8}.", moduleId, circleColourName[0], clockwiseLog[0], circleColourName[1], clockwiseLog[1], circleColourName[2], clockwiseLog[2], circleColourName[3], clockwiseLog[3]);
         Debug.LogFormat("[The Crystal Maze #{0}] Press the target when the last digit of the game timer is {1}.", moduleId, pressTime);
     }
     else if (zone.name == "DomeSelectable" && collectedCrystals > 0)
     {
         zone.AddInteractionPunch();
         for (int i = 0; i <= 3; i++)
         {
             endOfZone[i] = false;
         }
         domeTime = collectedCrystals * 5;
         Debug.LogFormat("[The Crystal Maze #{0}] You have {1} seconds of time inside the Crystal Dome. Good luck.", moduleId, domeTime);
         surface.material = surfaceOptions[5];
         zones[0].SetActive(false);
         zones[5].SetActive(true);
         StartCoroutine(DomeTimer());
     }
 }
    void PressButton()
    {
        if (moduleSolved || !moduleReady)
            return;
        Button.AddInteractionPunch();
        GetComponent<KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
        if (zenMode == false)
        {
            if (stages == 0 && Mathf.Floor(Bomb.GetTime()) == timeA)
            {
                stages = 1;
                Text.text = strB;
                Lights[0].GetComponent<MeshRenderer>().material = GreenMat;
                Debug.LogFormat("[Timing is Everything #{0}] Stage 1 complete.", moduleId);
                tpCorrect = true;
            }
            else if (stages == 1 && Mathf.Floor(Bomb.GetTime()) == timeB)
            {
                stages = 2;
                Text.text = strC;
                Lights[1].GetComponent<MeshRenderer>().material = GreenMat;
                Debug.LogFormat("[Timing is Everything #{0}] Stage 2 complete.", moduleId);
                tpCorrect = true;
            }
            else if (stages == 2 && Mathf.Floor(Bomb.GetTime()) == timeC)
            {
                GetComponent<KMBombModule>().HandlePass();
                moduleSolved = true;
                stages = 3;
                Text.text = "!!!";
                Lights[2].GetComponent<MeshRenderer>().material = GreenMat;
                Debug.LogFormat("[Timing is Everything #{0}] Stage 3 complete, module solved.", moduleId);
                tpCorrect = true;
            }
            else if (stages != 3)
            {
                GetComponent<KMBombModule>().HandleStrike();
                if (timeMode == true)
                {
                    Debug.LogFormat("[Timing is Everything #{0}] Submit pressed at the wrong time of '{1}' on Stage {2}. Strike!", moduleId, Bomb.GetFormattedTime(), stages + 1);
                }
                else
                {
                    Debug.LogFormat("[Timing is Everything #{0}] Too early on Stage {1}. Strike!", moduleId, stages + 1);
                }
            }
        } else
        {
            if (stages == 0 && Mathf.Floor(Bomb.GetTime()) == timeC)
            {
                stages = 1;
                Text.text = strB;
                Lights[0].GetComponent<MeshRenderer>().material = GreenMat;
                Debug.LogFormat("[Timing is Everything #{0}] Stage 1 complete.", moduleId);
                tpCorrect = true;
            }
            else if (stages == 1 && Mathf.Floor(Bomb.GetTime()) == timeB)
            {
                stages = 2;
                GenerateStrings(timeA, strA, 1);
                Text.text = strA;
                Lights[1].GetComponent<MeshRenderer>().material = GreenMat;
                Debug.LogFormat("[Timing is Everything #{0}] Stage 2 complete.", moduleId);
                tpCorrect = true;
                Debug.Log(timeA);
            }
            else if (stages == 2 && Mathf.Floor(Bomb.GetTime()) == timeA)
            {
                GetComponent<KMBombModule>().HandlePass();
                moduleSolved = true;
                stages = 3;
                Text.text = "!!!";
                Lights[2].GetComponent<MeshRenderer>().material = GreenMat;
                Debug.LogFormat("[Timing is Everything #{0}] Stage 3 complete, module solved.", moduleId);
                tpCorrect = true;

            }
            else if (stages != 3)
            {
                GetComponent<KMBombModule>().HandleStrike();
                if (timeMode == true)
                {
                    Debug.LogFormat("[Timing is Everything #{0}] Submit pressed at the wrong time of '{1}' on Stage {2}. Strike!", moduleId, Bomb.GetFormattedTime(), stages + 1);
                }
                else
                {
                    Debug.LogFormat("[Timing is Everything #{0}] Too early on Stage {1}. Strike!", moduleId, stages + 1);
                }
            }
        }
    }
 private void KeyPress(KMSelectable key)
 {
     if (alreadypressed[keys.IndexOf(key)] == false && moduleSolved == false && pressable == true)
     {
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, key.transform);
         alreadypressed[keys.IndexOf(key)] = true;
         key.transform.localPosition       = new Vector3(0, 0, -1f);
         key.AddInteractionPunch();
         if (!recovery)
         {
             presses.Add((keys.IndexOf(key) + 1).ToString());
             if (pressCount < 5)
             {
                 pressCount++;
             }
             else
             {
                 pressCount = 0;
                 string[] answ = new string[6];
                 for (int i = 0; i < 6; i++)
                 {
                     answ[i] = (answer.IndexOf(i + 1) + 1).ToString();
                 }
                 string   ans   = string.Join(string.Empty, answ);
                 string[] press = presses.ToArray();
                 string   pr    = string.Join(string.Empty, press);
                 Debug.LogFormat("[Tallordered Keys #{0}] After {1} reset(s), the buttons were pressed in the order: {2}", moduleID, resetCount, pr);
                 if (ans == pr)
                 {
                     Audio.PlaySoundAtTransform("InputCorrect", transform);
                     moduleSolved = true;
                 }
                 else
                 {
                     GetComponent <KMBombModule>().HandleStrike();
                     recovery      = true;
                     pressable     = false;
                     recoveryIndex = 0;
                 }
                 presses.Clear();
                 labelList.Clear();
                 resetCount++;
                 Reset();
             }
         }
         else
         {
             int[] offsets = { -100, -10, -1, 1, 10, 100 };
             recoveryIndex += offsets[keys.IndexOf(key)];
             if (recoveryIndex < 0)
             {
                 recoveryIndex = 0;
             }
             else if (recoveryIndex > recoveryList.Count - 1)
             {
                 recovery      = false;
                 recoveryIndex = recoveryList.Count - 1;
                 disp.text     = stage.ToString();
             }
             pressable = false;
             Reset();
         }
     }
 }
    /// <summary>
    /// Helper method that will change the numbers based on which arrow button is pressed
    /// </summary>
    /// <param name="index">Index of the button pushed (0 is top-left, then goes along the rows; 5 is bottom-right)</param>
    private void ChangeNumber(int index)
    {
        switch (index)
        {
        //Add to left digit
        case 0:
            digits[0]     = (digits[0] + 1) % 10;
            leftText.text = digits[0].ToString();
            upButtonLeft.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 1's up button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Add to middle digit
        case 1:
            digits[1]       = (digits[1] + 1) % 10;
            middleText.text = digits[1].ToString();
            upButtonMiddle.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 2's up button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Add to right digit
        case 2:
            digits[2]      = (digits[2] + 1) % 10;
            rightText.text = digits[2].ToString();
            upButtonRight.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 3's up button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Subtract from left digit
        case 3:
            digits[0]     = (digits[0] + 9) % 10;
            leftText.text = digits[0].ToString();
            downButtonLeft.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 1's down button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Subtract from middle digit
        case 4:
            digits[1]       = (digits[1] + 9) % 10;
            middleText.text = digits[1].ToString();
            downButtonMiddle.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 2's down button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        //Subtract from right digit
        case 5:
            digits[2]      = (digits[2] + 9) % 10;
            rightText.text = digits[2].ToString();
            downButtonRight.AddInteractionPunch(.2f);
            bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Display 3's down button was pressed. Number is now {1}{2}{3}.", moduleId, digits[0], digits[1], digits[2]);
            break;

        default:
            break;
        }
    }
예제 #5
0
    void ButtonPress(KMSelectable Button)
    {
        Button.AddInteractionPunch();
        GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Button.transform);
        if (EDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJDEDFGHJKUFHALDFHKAJFNLKWFNLKAJD == true)
        {
            if (Button == Buttons[0]) //right
            {
                Youisdumb += 1;
                if (Maze[Youisdumb] == 'O')
                {
                    Youisdumb += 1;
                }
                else
                {
                    GetComponent <KMBombModule>().HandleStrike();
                    Youisdumb -= 1;
                }
            }
            else if (Button == Buttons[1]) //Left
            {
                Youisdumb -= 1;
                if (Maze[Youisdumb] == 'O')
                {
                    Youisdumb -= 1;
                }
                else
                {
                    Youisdumb += 1;
                    GetComponent <KMBombModule>().HandleStrike();
                }
            }
            else if (Button == Buttons[2]) //Up
            {
                Youisdumb -= 15;
                if (Youisdumb < 0 || Maze[Youisdumb] == 'O')
                {
                    Youisdumb -= 15;
                }
                else
                {
                    Youisdumb += 15;
                    GetComponent <KMBombModule>().HandleStrike();
                }
            }
            else if (Button == Buttons[3]) //Down
            {
                Youisdumb += 15;
                if (Youisdumb > 374 || Maze[Youisdumb] == 'O')
                {
                    Youisdumb += 15;
                }
                else
                {
                    Youisdumb -= 15;
                    GetComponent <KMBombModule>().HandleStrike();
                }
            }
            else
            {
                Debug.Log("F**k");
            }
            Debug.Log(Youisdumb);

            for (int i = 0; i < 84; i++)
            {
                if (Youisdumb == WeedKhungus[i])
                {
                    Display.text = KMazeyTalk1.phrases[i];
                }
            }
        }
    }
    IEnumerator PrintManifest()
    {
        int sectorVal = goalDestination / 100;

        string[] message = new string[] { "--==Shipping Manifest==--\n",
                                          "\n",
                                          string.Format("Delivery Nº: {0}\n", deliveryNo.Join("")),
                                          "\n",
                                          "From: Steel Crate Games,\n",
                                          "Ottawa, Ontario, Canada\n",
                                          "\n",
                                          string.Format("To: {0},\n", GetAreaName(goalDestination)),
                                          string.Format("{0}\n", GetSectorName(sectorVal)),
                                          string.Format("Area Code: {0}\n", goalDestination),
                                          "\n",
                                          "Content Details: \n",
                                          "   - Bomb;\n",
                                          "\n",
                                          "\n",
                                          "\n",
                                          "\n",
                                          "" };

        Audio.PlaySoundAtTransform("print", transform);

        for (int i = 0; i < 20; i++)
        {
            manifestText.gameObject.transform.localPosition += new Vector3(0, 0, 0.01f);
            manifest.gameObject.transform.localPosition     += new Vector3(0, 0, 0.005f);
            manifest.gameObject.transform.localScale        += new Vector3(0, 0, 0.01f);
            yield return(new WaitForSeconds(0.01f));
        }

        for (int i = 0; i < message.Length; i++)
        {
            manifestText.text = message[message.Length - 1 - i] + manifestText.text;
            for (int j = 0; j < 22; j++)
            {
                manifestText.gameObject.transform.localPosition += new Vector3(0, 0, 0.01f);
                manifest.gameObject.transform.localPosition     += new Vector3(0, 0, 0.005f);
                manifest.gameObject.transform.localScale        += new Vector3(0, 0, 0.01f);
                yield return(new WaitForSeconds(0.01f));
            }
        }

        yield return(new WaitForSeconds(0.3f));

        int[] vertical = new int[] { 110, 122, 124, 134, 141, 142, 144,
                                     203, 223, 224, 230, 231, 233, 240, 241,
                                     311, 312, 313, 321, 330, 332, 333, 342,
                                     400, 432, 434, 441, 444,
                                     511, 520, 523, 540, 541 };

        Audio.PlaySoundAtTransform("paper", transform);
        postStamp.GetComponentInChildren <Renderer>().material = GetStamp(goalDestination);
        if (vertical.ToList().Contains(goalDestination))
        {
            postStamp.transform.Rotate(0, 90f, 0);
        }
        postStamp.SetActive(true);
        selectableSelf.AddInteractionPunch(2f);

        yield return(new WaitForSeconds(0.3f));

        stamp.SetActive(true);
        Audio.PlaySoundAtTransform("stamp", transform);
        modSelf.HandlePass();
    }
예제 #7
0
    void Init()
    {
        for (int i = 0; i < 5; i++)
        {
            stageDisplay[i].GetComponentInChildren <TextMesh>().text = "";
        }
        inputDisplay.GetComponentInChildren <TextMesh>().text = "";
        curSolved    = 0;
        numSolvables = Bomb.GetSolvableModuleNames().Where(x => !listF.Contains(x)).Count() + extraz;
        //Debug.Log(Bomb.GetSolvableModuleNames().Where(x => !listF.Contains(x)).ToString());
        //Debug.Log(Bomb.GetSolvableModuleNames());
        //var xxxxx = String.Join(", ", Bomb.GetSolvableModuleNames());
        //Debug.Log("Solviez " + String.Join(", ", Bomb.GetSolvableModuleNames().ToArray()));


        //numSolvables = 57; //debug
        if (numSolvables < 2)
        {
            Debug.LogFormat("[Forget This #{0}] Auto-solving, not enough non-List F modules exist (need 2 or more)", _moduleId);
            autoSolved = true;
            isSolved   = true;
        }
        else
        {
            Debug.LogFormat("[Forget This #{0}] {1} (Row C is the first letter of the stage's color, V is the stage's value)", _moduleId, coolString);
            for (int i = 1; i <= numSolvables; i++)
            {
                //var iZero = i - 1;
                stageNumbers.Add(UnityEngine.Random.Range(0, 36));
                stageColors.Add(UnityEngine.Random.Range(0, 5));
                if (numSolvables == i)
                {
                    //coolString = coolString + "and " + i + " is " + lightColors[(int)stageColors[iZero]] + " " + theValues[(int)stageNumbers[iZero]] + " (worth " + stageNumbers[iZero] + ").";
                }
                else
                {
                    //coolString = coolString + i + " is " + lightColors[(int)stageColors[iZero]] + " " + theValues[(int)stageNumbers[iZero]] + " (worth " + stageNumbers[iZero] + "), ";
                }
            }
            //numSolvables = 7;
            if (numSolvables > 5)
            {
                finalStage[0] = UnityEngine.Random.Range(2, numSolvables);
                finalStage[1] = finalStage[0];
                finalStage[2] = finalStage[0];
                finalStage[3] = finalStage[0];
                finalStage[4] = finalStage[0];
                while (finalStage[1] == finalStage[0])
                {
                    finalStage[1] = UnityEngine.Random.Range(2, numSolvables + 1);
                }
                while (finalStage[2] == finalStage[0] || finalStage[2] == finalStage[1])
                {
                    finalStage[2] = UnityEngine.Random.Range(2, numSolvables + 1);
                }
                while (finalStage[3] == finalStage[0] || finalStage[3] == finalStage[1] || finalStage[3] == finalStage[2])
                {
                    finalStage[3] = UnityEngine.Random.Range(2, numSolvables + 1);
                }
                while (finalStage[4] == finalStage[0] || finalStage[4] == finalStage[1] || finalStage[4] == finalStage[2] || finalStage[4] == finalStage[3])
                {
                    finalStage[4] = UnityEngine.Random.Range(2, numSolvables + 1);
                }
            }
            else
            {
                finalStage[0] = UnityEngine.Random.Range(2, 1 + numSolvables);
                finalStage[1] = UnityEngine.Random.Range(2, 1 + numSolvables);
                finalStage[2] = UnityEngine.Random.Range(2, 1 + numSolvables);
                finalStage[3] = UnityEngine.Random.Range(2, 1 + numSolvables);
                finalStage[4] = UnityEngine.Random.Range(2, 1 + numSolvables);
            }
            var twenties    = (int)(numSolvables / 20);
            var numberGroup = "";
            var colorGroup  = "";
            var tN          = 0;
            var unitNum     = 0;

            for (tN = 0; tN < twenties; tN++)
            {
                for (unitNum = 0; unitNum < 20; unitNum++)
                {
                    numberGroup = numberGroup + theValues[stageNumbers[(tN * 20) + unitNum]];
                    colorGroup  = colorGroup + lightColors[stageColors[(tN * 20) + unitNum]].Substring(0, 1);
                    if (unitNum > 0 && unitNum % 5 == 4)
                    {
                        numberGroup = numberGroup + " ";
                        colorGroup  = colorGroup + " ";
                    }
                }

                //Debug.LogFormat("{1}", _moduleId, colorGroup);

                Debug.LogFormat("[Forget This #{0}] Stages {1} to {2}", _moduleId, 1 + (20 * tN), 20 + (20 * tN));
                Debug.LogFormat("[Forget This #{0}] C: {1}", _moduleId, colorGroup);
                Debug.LogFormat("[Forget This #{0}] V: {1}", _moduleId, numberGroup);
                Debug.LogFormat("[Forget This #{0}]", _moduleId);
                numberGroup = "";
                colorGroup  = "";
            }
            for (unitNum = 0; unitNum < (numSolvables - (20 * (int)(numSolvables / 20))); unitNum++)
            {
                numberGroup = numberGroup + theValues[stageNumbers[(tN * 20) + unitNum]];
                colorGroup  = colorGroup + lightColors[stageColors[(tN * 20) + unitNum]].Substring(0, 1);
                if (unitNum > 0 && unitNum % 5 == 4)
                {
                    numberGroup = numberGroup + " ";
                    colorGroup  = colorGroup + " ";
                }
            }

            Debug.LogFormat("[Forget This #{0}] Stages {1} to {2}", _moduleId, 1 + (20 * tN), unitNum + (20 * tN));
            Debug.LogFormat("[Forget This #{0}] C: {1}", _moduleId, colorGroup);
            Debug.LogFormat("[Forget This #{0}] V: {1}", _moduleId, numberGroup);
            Debug.LogFormat("[Forget This #{0}]", _moduleId);
            numberGroup = "";
            colorGroup  = "";
            Debug.LogFormat("[Forget This #{0}] Stages to implement, in the order in which they should be implemented: {1}, {2}, {3}, {4}, and {5}.", _moduleId, finalStage[0], finalStage[1],
                            finalStage[2], finalStage[3], finalStage[4]);
            doSolution();
        }


        upButton.OnInteract     += delegate() { OnPress(); doUp(); upButton.AddInteractionPunch(0.2f); return(false); };
        downButton.OnInteract   += delegate() { OnPress(); doDown();  downButton.AddInteractionPunch(0.2f); return(false); };
        centerButton.OnInteract += delegate() { OnPress(); doSubmit();  downButton.AddInteractionPunch(0.2f); return(false); };

        upButton.OnInteractEnded     += delegate() { OnRelease(); };
        downButton.OnInteractEnded   += delegate() { OnRelease(); };
        centerButton.OnInteractEnded += delegate() { OnRelease(); };
        Module.OnActivate            += delegate { doActivationStuff(); };
    }
예제 #8
0
    void handleQuery()
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Query.transform);
        Query.AddInteractionPunch();

        if (!isActive || isSolved)
        {
            return;
        }
        else
        {
            // substituting variables
            int[] PHSlotNR = { SlotNR[0], SlotNR[1], SlotNR[2], SlotNR[3], SlotNR[4] };
            Debug.Log("[Mastermind Simple #" + moduleId + "] Query: " + SlotColors[PHSlotNR [0]] + " " + SlotColors[PHSlotNR [1]] + " " + SlotColors[PHSlotNR [2]] + " " + SlotColors[PHSlotNR [3]] + " " + SlotColors[PHSlotNR [4]]);
            int[] PHcorrSlot = { corrSlot[0], corrSlot[1], corrSlot[2], corrSlot[3], corrSlot[4] };


            // assigning black pegs
            for (int i = 0; i < 5; i++)
            {
                int j = i;
                if (PHSlotNR [j] < 6)
                {
                    if (PHSlotNR [j] == PHcorrSlot [j])
                    {
                        PegBlack++;
                        PHSlotNR [j]   = 6;
                        PHcorrSlot [j] = 7;
                    }
                }
            }


            // assigning white pegs
            for (int i = 0; i < 5; i++)
            {
                int j = i;
                if (PHSlotNR [j] < 6)
                {
                    for (int k = 0; k < 5; k++)
                    {
                        int l = k;
                        if (PHSlotNR [j] == PHcorrSlot [l])
                        {
                            PegWhite++;
                            PHSlotNR [j]   = 6;
                            PHcorrSlot [l] = 7;
                        }
                    }
                }
            }


            // assigning gray pegs
            PegGray = (5 - PegBlack - PegWhite);

            Debug.Log("[Mastermind Simple #" + moduleId + "] Query result: " + PegBlack + " correct, " + PegWhite + " correct, but in wrong positions");

            // update display
            DisplaytextLeft.text  = PegBlack.ToString();
            DisplaytextRight.text = PegWhite.ToString();

            // reset
            PegBlack = 0;
            PegWhite = 0;
            PegGray  = 0;
        }
    }
예제 #9
0
파일: boxing.cs 프로젝트: eXish/Boxing
    void Awake()
    {
        moduleId = moduleIdCounter++;
        boxingGlove.OnInteract   += delegate() { PressBoxingGlove(); return(false); };
        hireButton.OnInteract    += delegate() { Hire(); return(false); };
        abstainButton.OnInteract += delegate() { Abstain(); return(false); };
        foreach (KMSelectable arrowButton in arrowButtons)
        {
            arrowButton.OnInteract += delegate() { PressArrowButton(arrowButton); return(false); }
        }
        ;
        GetComponent <KMBombModule>().OnActivate += OnActivate;
    }

    void Start()
    {
        var dupliates = possibleSubstituteNames.Where(s => !possibleSubstituteNames.Distinct().Contains(s)).ToArray();

        foreach (string duplicate in dupliates)
        {
            Debug.LogFormat("[Boxing #{0}] {1} is a duplicate.", moduleId, duplicate);
        }
        contestantStrengths = Enumerable.Range(0, 5).ToList().Shuffle().ToArray();
        contestantIndices   = Enumerable.Range(0, 25).ToList().Shuffle().Take(5).ToArray();
        blueContestant      = rnd.Range(0, 5);
        string[] ordinals = new string[5] {
            "1st", "2nd", "3rd", "4th", "5th"
        };
        int         count         = 0;
        List <Char> allCharacters = new List <Char>();
        var         tempString    = "";

        for (int i = 0; i < 5; i++)
        {
            lastNameIndices[i]           = Array.IndexOf(possibleLastNames, possibleLastNames.PickRandom());
            substituteIndices[i]         = Array.IndexOf(possibleSubstituteNames, possibleSubstituteNames.PickRandom());
            substituteLastNameIndices[i] = Array.IndexOf(possibleLastNames, possibleLastNames.PickRandom());
            tempString += possibleNames[contestantIndices[i]];
            tempString += possibleLastNames[lastNameIndices[i]];
            tempString += possibleSubstituteNames[substituteIndices[i]];
            tempString += possibleLastNames[substituteLastNameIndices[i]];
        }
        tempString = tempString.ToUpperInvariant();
        for (int i = 0; i < 5; i++)
        {
            var value1         = contestantStrengths[contestantIndices[i] / 5];
            var value2         = contestantStrengths[contestantIndices[i] % 5];
            var contestantChar = alphabet[5 * value1 + value2];
            allCharacters.Add(contestantChar);
            var addCount = tempString.Count(c => c == contestantChar);
            count += addCount;
            Debug.LogFormat("[Boxing #{0}] The {1} contestant is {2} {3}, with punch strength {4}, and his substitute is {5} {6}. His base 5 pair forms the letter {7}, so {8} is added to the total.", moduleId, ordinals[i], possibleNames[contestantIndices[i]], possibleLastNames[lastNameIndices[i]], contestantStrengths[i], possibleSubstituteNames[substituteIndices[i]], possibleLastNames[substituteLastNameIndices[i]], contestantChar, addCount);
        }
        count += Array.IndexOf(alphabet, allCharacters[blueContestant]);
        Debug.LogFormat("[Boxing #{0}] {1} has the blue name, so {2} is added.", moduleId, possibleNames[contestantIndices[blueContestant]], Array.IndexOf(alphabet, allCharacters[blueContestant]));
        int unmodifiedCount = count;

        count %= 6;
        Debug.LogFormat("[Boxing #{0}] The count is {1}, modulo 6 is {2}.", moduleId, unmodifiedCount, count % 6);
        if (count == 5)
        {
            solution = 10;
            Debug.LogFormat("[Boxing #{0}] Every contestant is on steroids. Abstain from participating.", moduleId);
        }
        else
        {
            if (count == 0)
            {
                solution = Array.IndexOf(contestantStrengths, 4);
            }
            else
            {
                int subtracted = 5 - count;
                solution = Array.IndexOf(contestantStrengths, subtracted);
            }
            Debug.LogFormat("[Boxing #{0}] The strongest contestant not on steroids is {1}.", moduleId, possibleNames[contestantIndices[solution]]);
        }
        screenTexts[0].text = "";
        screenTexts[1].text = "";
        screenTexts[2].text = "";
        screenTexts[3].text = "";

        /**screenTexts[0].text = possibleNames[contestantIndices[0]];
         *      screenTexts[1].text = possibleLastNames[lastNameIndices[0]];
         *      screenTexts[2].text = possibleSubstituteNames[substituteIndices[0]];
         *      screenTexts[3].text = possibleLastNames[substituteLastNameIndices[0]];
         *      foreach (TextMesh screenText in screenTexts)
         *              screenText.color = blueContestant == 0 ? textColors[1] : textColors[0];*/
    }

    void OnActivate()
    {
        string[] oldMessages = new string[4] {
            screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
        };
        string[] newMessages = new string[4] {
            possibleNames[contestantIndices[chosenContestant]], possibleLastNames[lastNameIndices[chosenContestant]], possibleSubstituteNames[substituteIndices[chosenContestant]], possibleLastNames[substituteLastNameIndices[chosenContestant]]
        };
        for (int i = 0; i < 4; i++)
        {
            StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
        }
    }

    void PressBoxingGlove()
    {
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        boxingGlove.AddInteractionPunch(strengths[contestantStrengths[chosenContestant]]);
        audio.PlaySoundAtTransform("punch" + rnd.Range(0, 6).ToString(), boxingGlove.transform);
    }

    void PressArrowButton(KMSelectable button)
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        button.AddInteractionPunch(.5f);
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        int[] offsets = new int[2] {
            -1, 1
        };
        int ix = Array.IndexOf(arrowButtons, button);

        if (!(chosenContestant == 0 && ix == 0) && !(chosenContestant == 4 && ix == 1))
        {
            chosenContestant += offsets[ix];
            string[] oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            string[] newMessages = new string[4] {
                possibleNames[contestantIndices[chosenContestant]], possibleLastNames[lastNameIndices[chosenContestant]], possibleSubstituteNames[substituteIndices[chosenContestant]], possibleLastNames[substituteLastNameIndices[chosenContestant]]
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
        }
        else
        {
            audio.PlaySoundAtTransform("error", button.transform);
        }
    }

    void Hire()
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, hireButton.transform);
        hireButton.AddInteractionPunch(.75f);
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        if (chosenContestant == solution)
        {
            module.HandlePass();
            Debug.LogFormat("[Boxing #{0}] You submitted {1}. That is correct. Module solved!", moduleId, possibleNames[contestantIndices[chosenContestant]]);
            moduleSolved = true;
            string[] oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            string[] newMessages = new string[4] {
                "Ready", "for", "the", "match!"
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
            audio.PlaySoundAtTransform("bell", hireButton.transform);
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Boxing #{0}] You submitted {1}. That is incorrect. Strike!", moduleId, possibleNames[contestantIndices[chosenContestant]]);
            audio.PlaySoundAtTransform("strike", hireButton.transform);
        }
    }

    void Abstain()
    {
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, abstainButton.transform);
        abstainButton.AddInteractionPunch(.75f);
        if (moduleSolved || animating.Contains(true))
        {
            return;
        }
        if (solution == 10)
        {
            module.HandlePass();
            Debug.LogFormat("[Boxing #{0}] You abstained from participating. That is correct. Module solved!", moduleId);
            audio.PlaySoundAtTransform("abstain", abstainButton.transform);
            moduleSolved = true;
            string[] oldMessages = new string[4] {
                screenTexts[0].text, screenTexts[1].text, screenTexts[2].text, screenTexts[3].text
            };
            string[] newMessages = new string[4] {
                "No", "contest", "this", "time..."
            };
            for (int i = 0; i < 4; i++)
            {
                StartCoroutine(CycleText(screenTexts[i], oldMessages[i], newMessages[i]));
            }
        }
        else
        {
            module.HandleStrike();
            Debug.LogFormat("[Boxing #{0}] You abstained from participating. That is incorrect. Strike!", moduleId);
            audio.PlaySoundAtTransform("strike", abstainButton.transform);
        }
    }

    IEnumerator CycleText(TextMesh display, string oldMessage, string newMessage)
    {
        animating[Array.IndexOf(screenTexts, display)] = true;
        string currentMessage = oldMessage;
        int    messageLength  = currentMessage.Length;

        for (int i = 0; i < messageLength; i++)
        {
            currentMessage = currentMessage.Remove(currentMessage.Length - 1);
            display.text   = currentMessage;
            audio.PlaySoundAtTransform("beep", display.transform);
            yield return(new WaitForSeconds(.05f));
        }
        currentMessage = "";
        if (!moduleSolved)
        {
            display.color = chosenContestant == blueContestant ? textColors[1] : textColors[0];
        }
        else
        {
            display.color = solveColor;
        }
        for (int i = 0; i < newMessage.Length; i++)
        {
            currentMessage = currentMessage + newMessage[i];
            display.text   = currentMessage;
            audio.PlaySoundAtTransform("beep", display.transform);
            yield return(new WaitForSeconds(.05f));
        }
        animating[Array.IndexOf(screenTexts, display)] = false;
    }
예제 #10
0
 void PressButton(KMSelectable pressed)
 {
     if (moduleSolved != true && nointeract == false)
     {
         pressed.AddInteractionPunch(0.25f);
         if (firstpress == false)
         {
             firstpress = true;
         }
         if (isrunning == true)
         {
             StopCoroutine(flash);
             clearLights();
             isrunning = false;
         }
         if (pressed == buttons[0])
         {
             if (lights[0].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep1", transform);
                 inputs++;
                 total += buttonvals[0];
                 lights[0].enabled = true;
             }
             else
             {
                 lights[0].enabled = false;
                 inputs--;
                 total -= buttonvals[0];
             }
         }
         else if (pressed == buttons[1])
         {
             if (lights[1].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep2", transform);
                 inputs++;
                 total += buttonvals[1];
                 lights[1].enabled = true;
             }
             else
             {
                 lights[1].enabled = false;
                 inputs--;
                 total -= buttonvals[1];
             }
         }
         else if (pressed == buttons[2])
         {
             if (lights[2].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep3", transform);
                 inputs++;
                 total += buttonvals[2];
                 lights[2].enabled = true;
             }
             else
             {
                 lights[2].enabled = false;
                 inputs--;
                 total -= buttonvals[2];
             }
         }
         else if (pressed == buttons[3])
         {
             if (lights[3].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep4", transform);
                 inputs++;
                 total += buttonvals[3];
                 lights[3].enabled = true;
             }
             else
             {
                 lights[3].enabled = false;
                 inputs--;
                 total -= buttonvals[3];
             }
         }
         else if (pressed == buttons[4])
         {
             if (lights[4].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep5", transform);
                 inputs++;
                 total += buttonvals[4];
                 lights[4].enabled = true;
             }
             else
             {
                 lights[4].enabled = false;
                 inputs--;
                 total -= buttonvals[4];
             }
         }
         else if (pressed == buttons[5])
         {
             if (lights[5].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep6", transform);
                 inputs++;
                 total += buttonvals[5];
                 lights[5].enabled = true;
             }
             else
             {
                 lights[5].enabled = false;
                 inputs--;
                 total -= buttonvals[5];
             }
         }
         else if (pressed == buttons[6])
         {
             if (lights[6].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep7", transform);
                 inputs++;
                 total += buttonvals[6];
                 lights[6].enabled = true;
             }
             else
             {
                 lights[6].enabled = false;
                 inputs--;
                 total -= buttonvals[6];
             }
         }
         else if (pressed == buttons[7])
         {
             if (lights[7].enabled == false)
             {
                 audio.PlaySoundAtTransform("beep8", transform);
                 inputs++;
                 total += buttonvals[7];
                 lights[7].enabled = true;
             }
             else
             {
                 lights[7].enabled = false;
                 inputs--;
                 total -= buttonvals[7];
             }
         }
         else if (pressed == buttons[8])
         {
             if (inputs > 0)
             {
                 if (answer == total)
                 {
                     if (stage == 3)
                     {
                         Debug.LogFormat("[Simon Selects #{0}] Inputted Number Total is: {1}, which is correct! Module Disarmed!", moduleId, total);
                         clearLights();
                         stage++;
                         if (!Settings.noCopyrightMusic)
                             audio.HandlePlaySoundAtTransform("victory", transform);
                         else
                             audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
                         StartCoroutine(victory());
                     }
                     else
                     {
                         Debug.LogFormat("[Simon Selects #{0}] Inputted Number Total is: {1}, which is correct!", moduleId, total);
                         clearLights();
                         if (!Settings.noCopyrightMusic)
                             audio.HandlePlaySoundAtTransform("correctans", transform);
                         else
                             audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
                         StartCoroutine(correctFlash());
                     }
                 }
                 else
                 {
                     Debug.LogFormat("[Simon Selects #{0}] Inputted Number Total is: {1}, which is incorrect!", moduleId, total);
                     GetComponent<KMBombModule>().HandleStrike();
                     clearLights();
                     StartCoroutine(wrongFlash());
                 }
             }
         }
         else if (pressed == buttons[9])
         {
             audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, pressed.transform);
             firstpress = false;
         }
         if (isrunning == false && inputs == 0)
         {
             flash = StartCoroutine(flashSequence());
         }
     }
 }
 void Start()
 {
     moduleId     = moduleIdCounter++;
     numberToMake = rdn.Range(0, 10000);
     state        = rdn.Range(0, 2);
     if (state == 1)
     {
         needBalance = true;
     }
     else
     {
         needBalance = false;
     }
     convert(numberToMake);
     Debug.LogFormat("[Ternary Converter #{0}] Decimal number: {1}", moduleId, numberToMake.ToString());
     Debug.LogFormat("[Ternary Converter #{0}] In standard ternary: {1}", moduleId, base3);
     Debug.LogFormat("[Ternary Converter #{0}] In balanced ternary: {1}", moduleId, balancedTernary);
     if (needBalance)
     {
         Debug.LogFormat("[Ternary Converter #{0}] The display is in standard ternary so you need to input balanced ternary", moduleId);
         Display.GetComponent <TextMesh>().text = base3;
         finalAnswer = balancedTernary;
     }
     else
     {
         Debug.LogFormat("[Ternary Converter #{0}] The display is in balanced ternary so you need to input standard ternary", moduleId);
         Display.GetComponent <TextMesh>().text = balancedTernary;
         finalAnswer = base3;
     }
     resizeText(Display);
     numberedButtons[0].OnInteract += delegate(){
         pressButton("0");
         return(false);
     };
     numberedButtons[1].OnInteract += delegate(){
         pressButton("1");
         return(false);
     };
     numberedButtons[2].OnInteract += delegate(){
         pressButton("2");
         return(false);
     };
     symbolButtons[0].OnInteract += delegate(){
         pressButton("-");
         return(false);
     };
     symbolButtons[1].OnInteract += delegate(){
         pressButton("+");
         return(false);
     };
     clearButton.OnInteract += delegate(){
         clearButton.AddInteractionPunch(.5f);
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, clearButton.transform);
         if (!solved)
         {
             inputstring = "";
             inputDisplay.GetComponent <TextMesh>().text     = "";
             inputDisplay.GetComponent <TextMesh>().fontSize = 120;
         }
         return(false);
     };
     submitButton.OnInteract += delegate(){
         submitButton.AddInteractionPunch(.5f);
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, submitButton.transform);
         if (!solved)
         {
             if (inputstring == finalAnswer)
             {
                 Debug.LogFormat("[Ternary Converter #{0}] Correct answer entered! Module solved!", moduleId);
                 solved = true;
                 decimalDisplay.GetComponent <TextMesh>().text = numberToMake.ToString();
                 resizeText(decimalDisplay);
                 GetComponent <KMBombModule>().HandlePass();
             }
             else
             {
                 if (inputstring == "")
                 {
                     Debug.LogFormat("[Ternary Converter #{0}] Incorrect answer entered: *Literally nothing*! Strike!", moduleId);
                 }
                 else
                 {
                     Debug.LogFormat("[Ternary Converter #{0}] Incorrect answer entered: {1}! Strike!", moduleId, inputstring);
                 }
                 inputstring = "";
                 inputDisplay.GetComponent <TextMesh>().text     = "";
                 inputDisplay.GetComponent <TextMesh>().fontSize = 120;
                 GetComponent <KMBombModule>().HandleStrike();
             }
         }
         return(false);
     };
 }
예제 #12
0
    void Start()
    {
        _moduleId      = _moduleIdCounter++;
        _keptDiceSlot  = new int?[Dice.Length];
        _wasKept       = new bool[Dice.Length];
        _diceValues    = new int[Dice.Length];
        _diceLocations = new Vector3[Dice.Length];
        _coroutines    = new Coroutine[Dice.Length];

        foreach (var dice in DiceParent)
        {
            dice.gameObject.SetActive(false);
        }

        RollButton.OnInteract = delegate
        {
            RollButton.AddInteractionPunch();
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, RollButton.transform);

            if (_isSolved)
            {
                return(false);
            }

            // First roll ever?
            if (_lastRolled > 0)
            {
                Debug.LogFormat("[Yahtzee #{0}] Attempting to keep {1} and rerolling {2}.",
                                _moduleId,
                                Enumerable.Range(0, Dice.Length).Where(ix => _keptDiceSlot[ix] != null).Select(ix => string.Format("{0}={1}", (DiceColor)ix, _diceValues[ix])).DefaultIfEmpty("nothing").JoinString(", "),
                                Enumerable.Range(0, Dice.Length).Count(ix => _keptDiceSlot[ix] == null));

                if (!IsLegal(kept: Enumerable.Range(0, Dice.Length).Where(ix => _keptDiceSlot[ix] != null).ToArray(), logging: true))
                {
                    Module.HandleStrike();
                    return(false);
                }
            }
            else
            {
                Debug.LogFormat("[Yahtzee #{0}] Rolling all 5 dice.", _moduleId);
            }

            for (int i = 0; i < Dice.Length; i++)
            {
                if (_keptDiceSlot[i] == null)
                {
                    _diceValues[i] = Rnd.Range(1, 7);
                }

                var iterations = 0;
                do
                {
                    _diceLocations[i] = new Vector3(Rnd.Range(-.063f, .019f), .025f, Rnd.Range(-.069f, .028f));
                }while (_diceLocations.Where((loc, ix) => ix < i && (loc - _diceLocations[i]).magnitude < .03f).Any() && ++iterations < 1000);
                _wasKept[i] = _keptDiceSlot[i] != null;
            }

            Debug.LogFormat("[Yahtzee #{0}] New dice: {1}", _moduleId, Enumerable.Range(0, Dice.Length).Where(i => _keptDiceSlot[i] == null).Select(i => string.Format("{0}={1}", (DiceColor)i, _diceValues[i])).JoinString(", "));

            var sorted = Enumerable.Range(0, Dice.Length).Where(ix => _keptDiceSlot[ix] == null).OrderBy(ix => _diceLocations[ix].z).ToArray();
            for (int i = 0; i < sorted.Length; i++)
            {
                if (_coroutines[sorted[i]] != null)
                {
                    StopCoroutine(_coroutines[sorted[i]]);
                }
                _coroutines[sorted[i]] = StartCoroutine(rollDice(new Vector3(-.1f, .1f, -.069f + .1f * i / sorted.Length), sorted[i]));
            }
            StartCoroutine(playDicerollSound());

            _lastRolled = _keptDiceSlot.Count(kept => kept == null);
            if (_diceValues.Distinct().Count() == 1)
            {
                _isSolved = true;
                Debug.LogFormat("[Yahtzee #{0}] Yahtzee. Module solved.", _moduleId);
                StartCoroutine(victory());
            }
            return(false);
        };

        for (int i = 0; i < DiceParent.Length; i++)
        {
            DiceParent[i].OnInteract = getDiceHandler(i);
        }
    }
예제 #13
0
    void keyPress(int num)
    {
        if (num == 1)
        {
            button1.AddInteractionPunch();
        }
        else if (num == 2)
        {
            button2.AddInteractionPunch();
        }
        else if (num == 3)
        {
            button3.AddInteractionPunch();
        }
        else if (num == 4)
        {
            button4.AddInteractionPunch();
        }
        else if (num == 5)
        {
            button5.AddInteractionPunch();
        }
        else if (num == 6)
        {
            button6.AddInteractionPunch();
        }
        else if (num == 7)
        {
            button7.AddInteractionPunch();
        }
        else if (num == 8)
        {
            button8.AddInteractionPunch();
        }
        else if (num == 9)
        {
            button9.AddInteractionPunch();
        }
        else if (num == 0)
        {
            button0.AddInteractionPunch();
        }

        //Debug.Log(num + " " + code.Substring(currDig, 1));
        if (num == int.Parse(code.Substring(currDig, 1)) && !solved && enable)
        {
            if (currDig == 3)
            {
                BombModule.HandlePass();
                solved = true;
                for (int i = 0; i < squares.Length; i++)
                {
                    if (int.Parse(succsessPattern.Substring(i, 1)) == 1)
                    {
                        squares[i].SetActive(true);
                    }
                    else
                    {
                        squares[i].SetActive(false);
                    }
                }
            }
            else
            {
                currDig++;
            }
        }
        else if (!solved && enable)
        {
            BombModule.HandleStrike();
            currDig = 0;
            TL      = Random.Range(0, 7);
            TR      = Random.Range(0, 7);
            BL      = Random.Range(0, 7);
            BR      = Random.Range(0, 7);
            code    = digitTL.Substring(TL, 1) + digitTR.Substring(TR, 1) + digitBL.Substring(BL, 1) + digitBR.Substring(BR, 1);
            OnActivate();
            return;
        }
        KMAudio.PlaySoundAtTransform("tick", this.transform);
    }
예제 #14
0
 void buttonPress(KMSelectable button)
 {
     button.AddInteractionPunch();
     GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
     if (moduleSolved == false)
     {
         if (button == buttons[0])
         {
             if (puzzleType == 5)
             {
                 if (answer == 2)
                 {
                     needyModule.HandlePass();
                     Debug.LogFormat("[Common Sense #{0}] You selected the correct answer. Pass.", moduleId);
                     moduleSolved = true;
                 }
                 else
                 {
                     needyModule.HandleStrike();
                     needyModule.HandlePass();
                     Debug.LogFormat("[Common Sense #{0}] You selected the wrong answer. Strike!", moduleId);
                     moduleSolved = true;
                 }
             }
             else if (puzzleType == 6)
             {
                 if (answer == 5)
                 {
                     needyModule.HandlePass();
                     Debug.LogFormat("[Common Sense #{0}] You selected the correct answer. Pass.", moduleId);
                     moduleSolved = true;
                 }
                 else
                 {
                     needyModule.HandleStrike();
                     needyModule.HandlePass();
                     Debug.LogFormat("[Common Sense #{0}] You selected the wrong answer. Strike!", moduleId);
                     moduleSolved = true;
                 }
             }
             else if (puzzleType == 7)
             {
                 Audio.PlaySoundAtTransform(animalNames[animal], needyModule.transform);
             }
         }
         else if (button == buttons[1])
         {
             if (answer == 0 || answer == 3 || answer == 5)
             {
                 needyModule.HandlePass();
                 Debug.LogFormat("[Common Sense #{0}] You selected the correct answer. Pass.", moduleId);
                 moduleSolved = true;
             }
             else
             {
                 needyModule.HandleStrike();
                 needyModule.HandlePass();
                 Debug.LogFormat("[Common Sense #{0}] You selected the wrong answer. Strike!", moduleId);
                 moduleSolved = true;
             }
         }
         else if (button == buttons[2])
         {
             if (answer == 1 || answer == 3 || answer == 5)
             {
                 needyModule.HandlePass();
                 Debug.LogFormat("[Common Sense #{0}] You selected the correct answer. Pass.", moduleId);
                 moduleSolved = true;
             }
             else
             {
                 needyModule.HandleStrike();
                 needyModule.HandlePass();
                 Debug.LogFormat("[Common Sense #{0}] You selected the wrong answer. Strike!", moduleId);
                 moduleSolved = true;
             }
         }
         else
         {
             Debug.Log("Houston, we f****d up!");
         }
     }
 }
예제 #15
0
 void WeedEaterPress(KMSelectable WeedEater)
 {
     WeedEater.AddInteractionPunch();
     GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, WeedEater.transform);
     for (int i = 0; i < 8; i++)
     {
         if (WeedEater == WeedEaters[i])
         {
             if (i == 0)
             {
                 silvena      += 1000;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 1)
             {
                 if (silvena < 1000)
                 {
                     return;
                 }
                 silvena      -= 1000;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 2)
             {
                 silvena      += 100;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 3)
             {
                 if (silvena < 100)
                 {
                     return;
                 }
                 silvena      -= 100;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 4)
             {
                 silvena      += 10;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 5)
             {
                 if (silvena < 10)
                 {
                     return;
                 }
                 silvena      -= 10;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 6)
             {
                 silvena      += 1;
                 Weeds[2].text = silvena.ToString();
             }
             else if (i == 7)
             {
                 if (silvena < 1)
                 {
                     return;
                 }
                 silvena      -= 1;
                 Weeds[2].text = silvena.ToString();
             }
         }
     }
 }
 void onSubmitPress(KMSelectable button)
 {
     button.AddInteractionPunch();
     button.AddInteractionPunch(0.5f);
     if (stage == 1)
     {
         Debug.LogFormat("[Partial Derivatives #{0}] Inputted " + userInput.text.Substring(2, userInput.text.Length - 2) + ", expected " + stageAnswers[0], moduleId);
         if (userInput.text.Substring(2, userInput.text.Length - 2).Equals(stageAnswers[0].ToString()))
         {
             audio.PlaySoundAtTransform(sounds[2].name, transform);
             Debug.LogFormat("[Partial Derivatives #{0}] Stage 1 passed!", moduleId);
             userInput.text     = "> ";
             stage2Led.material = ledOptions[6];
             mainLed.material   = ledOptions[ledIndex[1]];
             stage++;
         }
         else
         {
             Debug.LogFormat("[Partial Derivatives #{0}] Strike given!", moduleId);
             GetComponent <KMBombModule>().HandleStrike();
             userInput.text = "> ";
         }
     }
     else if (stage == 2)
     {
         Debug.LogFormat("[Partial Derivatives #{0}] Inputted " + userInput.text.Substring(2, userInput.text.Length - 2) + ", expected " + stageAnswers[1], moduleId);
         if (userInput.text.Substring(2, userInput.text.Length - 2).Equals(stageAnswers[1].ToString()))
         {
             audio.PlaySoundAtTransform(sounds[2].name, transform);
             Debug.LogFormat("[Partial Derivatives #{0}] Stage 2 passed!", moduleId);
             userInput.text     = "> ";
             stage3Led.material = ledOptions[6];
             mainLed.material   = ledOptions[ledIndex[2]];
             stage++;
         }
         else
         {
             Debug.LogFormat("[Partial Derivatives #{0}] Strike given!", moduleId);
             GetComponent <KMBombModule>().HandleStrike();
             userInput.text = "> ";
         }
     }
     else if (stage == 3)
     {
         Debug.LogFormat("[Partial Derivatives #{0}] Inputted " + userInput.text.Substring(2, userInput.text.Length - 2) + ", expected " + stageAnswers[2], moduleId);
         if (userInput.text.Substring(2, userInput.text.Length - 2).Equals(stageAnswers[2].ToString()))
         {
             audio.PlaySoundAtTransform(sounds[3].name, transform);
             Debug.LogFormat("[Partial Derivatives #{0}] Stage 3 passed!", moduleId);
             display.text     = "Well done!\nThis module\nis solved!";
             mainLed.material = ledOptions[6];
             Debug.LogFormat("[Partial Derivatives #{0}] Module solved!", moduleId);
             GetComponent <KMBombModule>().HandlePass();
         }
         else
         {
             Debug.LogFormat("[Partial Derivatives #{0}] Strike given!", moduleId);
             GetComponent <KMBombModule>().HandleStrike();
             userInput.text = "> ";
         }
     }
 }
예제 #17
0
    void Activate()
    {
        SyncButton.OnInteract += () =>
        {
            if (Lights.Where(l => l.speed != 0).Select(l => l.speed).Distinct().Count() == 1 && !Solved)
            {
                SyncButton.AddInteractionPunch(0.5f);
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);

                if (((int)BombInfo.GetTime() % 60).ToString().Contains(DisplayNumber.ToString()))
                {
                    Module.HandlePass();
                    Solved = true;

                    foreach (Light light in Lights)
                    {
                        light.StopFlashing();
                        light.State = true;
                    }

                    Audio.PlaySoundAtTransform("Solve", transform);
                    StartCoroutine(PlayWinAnimation());
                }
                else
                {
                    Module.HandleStrike();
                }
            }
            else
            {
                resetCoroutine = StartCoroutine(HoldToReset());
            }

            return(false);
        };

        SyncButton.OnInteractEnded += () =>
        {
            if (resetCoroutine != null && !syncPause)
            {
                StopCoroutine(resetCoroutine);
                resetCoroutine = null;
            }
        };

        foreach (Light l in Lights)
        {
            l.gObject.GetComponent <KMSelectable>().OnInteract += SetupInteraction(l);
        }

        List <int> speeds = new List <int>()
        {
            1, 2, 3, 4, 5
        };
        List <int> lightIndexes = new List <int>()
        {
            0, 1, 2, 3, 4, 5, 6, 7, 8
        };

        for (int i = 0; i < 5; i++)
        {
            Lights[ExtractRandom(lightIndexes)].speed = ExtractRandom(speeds);
        }

        foreach (int lightIndex in lightIndexes)
        {
            Lights[lightIndex].State = true;
        }

        for (int i = 0; i < 9; i++)
        {
            InitialSpeeds[i] = Lights[i].speed;
        }

        foreach (Light light in Lights)
        {
            light.StartFlashing();
        }

        Log("Light speeds:\n{0} {1} {2}\n{3} {4} {5}\n{6} {7} {8}", Lights.Select(l => (object)l.speed).ToArray());

        // Find which way the user needs to sync

        int        fastestLight = Array.IndexOf(Lights, Lights.Where(l => l.speed != 0).Aggregate((l1, l2) => l1.speed > l2.speed ? l1 : l2));
        int        slowestLight = Array.IndexOf(Lights, Lights.Where(l => l.speed != 0).Aggregate((l1, l2) => l1.speed < l2.speed ? l1 : l2));
        Vector2Int chartPos     = new Vector2Int(
            lightToCol[fastestLight],
            Mathf.FloorToInt((DisplayNumber - 1) / 3)
            );

        var startingCell = chart[(int)chartPos.y][(int)chartPos.x];

        Log("Started at column {0}, row {1} ({2} {3})", chartPos.x + 1, chartPos.y + 1, orders[startingCell[0]], states[startingCell[1]]);

        for (int i = 0; i < Lights[4].speed; i++)
        {
            chartPos  += lightToDir[slowestLight];
            chartPos.x = (chartPos.x % 9 + 9) % 9;
            chartPos.y = (chartPos.y % 3 + 3) % 3;
        }
        Log("Ended at column {0}, row {1}", chartPos.x + 1, chartPos.y + 1);

        SyncMethod = chart[(int)chartPos.y][(int)chartPos.x];
        Log("Lights need to be synced in {0} {1} order", orders[SyncMethod[0]], states[SyncMethod[1]]);
    }
예제 #18
0
    void PressBall()
    {
        Ball.AddInteractionPunch();
        GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
        if (moduleSolved)
        {
            return;
        }
        switch (Callitsomethingyoucanremember)
        {
        case 0:
            if (You % 10 == 0)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 1:
            if (You % 10 == 1)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 2:
            if (You % 10 == 2)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 3:
            if (You % 10 == 3)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 4:
            if (You % 10 == 4)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 5:
            if (You % 10 == 5)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 6:
            if (You % 10 == 6)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 7:
            if (You % 10 == 7)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 8:
            if (You % 10 == 8)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        case 9:
            if (You % 10 == 9)
            {
                GetComponent <KMBombModule>().HandlePass();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Module disarmed.", moduleId, (You));
                Audio.PlaySoundAtTransform("Farfare", transform);
                moduleSolved = true;
                Ball.GetComponent <MeshRenderer>().material = color[2];
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                Debug.LogFormat("[1D Maze #{0}] You submitted at {1}. Strike, poopyhead.", moduleId, (You));
                Ball.GetComponent <MeshRenderer>().material = color[3];
            }
            break;

        default:
            Debug.LogFormat("You f****d up.");
            break;
        }
    }
예제 #19
0
    void Check()
    {
        if (!_lightsOn || _isSolved)
        {
            return;
        }

        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, submit.transform);
        submit.AddInteractionPunch();

        if (correctLine == currentLine)
        {
            Debug.LogFormat("[The Witness #{0}] Expected line: {1} or {2}, input line: {3}.", _moduleId, correctLine, alternativeLine, currentLine);
            Debug.LogFormat("[The Witness #{0}] Module defused. Well done :)", _moduleId);

            Audio.PlaySoundAtTransform("disarmed", Module.transform);
            wireGray.SetActive(false);
            wireGreen.SetActive(true);
            Module.HandlePass();
            _isSolved = true;
        }
        else if (alternativeLine == currentLine)
        {
            Debug.LogFormat("[The Witness #{0}] Expected line: {1} or {2}, input line: {3}.", _moduleId, correctLine, alternativeLine, currentLine);
            Debug.LogFormat("[The Witness #{0}] Module defused. Well done :)", _moduleId);

            Audio.PlaySoundAtTransform("disarmed", Module.transform);
            wireGray.SetActive(false);
            wireGreen.SetActive(true);
            Module.HandlePass();
            _isSolved = true;
        }
        else
        {
            Debug.LogFormat("[The Witness #{0}] Expected line: {1} or {2}, input line: {3}. Strike!", _moduleId, correctLine, alternativeLine, currentLine);

            Module.HandleStrike();

            StartCoroutine(RedWireHandle());

            tl.SetActive(false);
            tr.SetActive(false);
            tsl.SetActive(false);
            tsm.SetActive(false);
            tsr.SetActive(false);
            ml.SetActive(false);
            mr.SetActive(false);
            bsl.SetActive(false);
            bsm.SetActive(false);
            bsr.SetActive(false);
            bl.SetActive(false);
            br.SetActive(false);

            tmOn = false;
            trOn = false;
            mlOn = false;
            mmOn = false;
            mrOn = false;
            blOn = false;
            bmOn = false;
            brOn = false;

            currentLine = "";
            lastPress   = 0;
            isFirst     = true;
        }
    }
예제 #20
0
    void Activate()
    {
        InitGrid();
        ReinitializeGrid();

        for (int i = 0; i < 4; i++)
        {
            int j = i;
            ArrowButtons[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                ArrowButtons[j].AddInteractionPunch(0.4f);
                if (isSolved || !interactable)
                {
                    return(false);
                }
                OnArrowPress(j);
                return(false);
            };
        }

        for (int i = 0; i < 10; i++)
        {
            int j = i;
            NumberedButtons[i].OnInteract += delegate
            {
                Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
                NumberedButtons[j].AddInteractionPunch(0.4f);
                if (isSolved || !interactable)
                {
                    return(false);
                }
                OnNumberButtonPress(j);
                return(false);
            };
        }

        CheckButton.OnInteract += delegate
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
            CheckButton.AddInteractionPunch();
            if (isSolved || !interactable)
            {
                return(false);
            }
            var solved = CrackboxLogic.IsSolved(gridItems);
            Debug.LogFormat("[Crackbox #{0}] Submitted:", _moduleId);
            GridDebugLog(gridItems, x => string.Format("{0}", (x.IsBlack ? "B" : (x.Value == 0 ? "*" : x.Value.ToString()))));
            if (solved)
            {
                isSolved = true;
                Debug.LogFormat("[Crackbox #{0}] That is correct, module solved!", _moduleId);
                StartCoroutine("SolveAnimation", GridBoxSelected);
            }
            else
            {
                Debug.LogFormat("[Crackbox #{0}] That is incorrect, strike!", _moduleId);
                StartCoroutine("SolveAnimation", GridBoxWrong);
            }
            return(false);
        };
    }
예제 #21
0
    void Submit()
    {
        SubmitButton.AddInteractionPunch();
        if (!bossMode)
        {
            Debug.Log("[Forget Infinity #{0}] boss mode not active. Strike! (submit button)");
            Module.HandleStrike();
            return;
        }
        if (solveMode)
        {
            Debug.Log("[Forget Infinity #{0}] Solve mode detected! not submitting!");
            solveMode = false;
            StringBuilder sb = new StringBuilder(); // base 5
            for (int i = 0; i < 5; i++)
            {
                var j = code[i];
                if (j > 0)
                {
                    j--;
                }
                sb.Append(j.ToString());
            }
            var dec = ConvertFromBase5(sb.ToString());
            Debug.Log("[Forget Infinity #{0}] input is " + sb.ToString() + ", in base 10 that's " + dec);
            if (stages.Count() > dec && dec >= 0)
            {
                updateScreen(stages[dec].ToArray());
            }
            Module.HandleStrike();
            Screen.color = new UnityEngine.Color(1, 1, 1);
            return;
        }
        var stg = stages[solveStagePtr];

        Debug.Log("not calculated: " + ListString(stg));
        var batteries = KMBombInfoExtensions.KMBI.GetBatteryCount(Info);

        if (batteries != 0)
        {
            Debug.Log("batteries " + batteries);
            for (int i = 0; i < 5; i++)
            {
                var t = stg[i];
                t = (t + batteries) % 5;
                if (t == 0)
                {
                    t = 5;
                }
                stg[i] = t;
            }
        }
        var serial = KMBombInfoExtensions.KMBI.GetSerialNumber(Info);

        if (serial.Contains("F") || serial.Contains("I"))
        {
            Debug.Log("FI");
            for (int i = 0; i < 5; i++)
            {
                var t = stg[i];
                t = t - 1;
                if (t == 0)
                {
                    t = 5;
                }
                stg[i] = t;
            }
        }
        Debug.Log("calculated: " + ListString(stg));
        Debug.Log("solve stage ptr = " + solveStagePtr.ToString());
        Debug.Log("stage count = " + stages.Count());
        for (int i = 0; i < 5; i++)
        {
            if (code [i] != stg[i])
            {
                Debug.Log("[Forget Infinity #{0}] Code is different from the expected input of " + ListString(stg) + ". Strike!");
                Module.HandleStrike();
                Reset(true);
                solveStagePtr = 0;
                return;
            }
        }
        if (stages.Count() - 1 <= solveStagePtr)
        {
            Debug.Log("[Forget Infinity #{0}] All codes are correct! Solve!");
            solved = true;
            Module.HandlePass();
            Screen.text = "XXXXX";
            return;
        }
        solveStagePtr++;
        for (int i = 0; i < 5; i++)
        {
            this.code[i] = 0;
        }
        this.codeIndex = 0;
        updateScreen();
    }
예제 #22
0
    void buttonPressed(KMSelectable pressedButton)
    {
        StopAllCoroutines();

        soundEnabled     = true;
        otherPlaceholder = pressedButton;
        sound();

        selLights[0].enabled = false;
        selLights[1].enabled = false;
        selLights[2].enabled = false;
        selLights[3].enabled = false;
        selLights[4].enabled = false;

        pressedButton.AddInteractionPunch();

        for (int i = 0; i < 16; i++)
        {
            if (buttons[i] == pressedButton)
            {
                lights[i].enabled = true;
                StartCoroutine(PressedFlash(i));
            }
        }

        if (moduleSolved == true)
        {
            return;
        }

        if (stageNumber == 0)
        {
            if (pressedButton != corButtons[0])
            {
                incorrect = true;
            }

            if (incorrect != true)
            {
                DebugMsg("Correct sequence. Moving to the next stage.");
                stageNumber    = stageNumber + 1;
                pressedButton  = null;
                FlickerRoutine = StartCoroutine(FlickerCoRoutine2());
            }
            else
            {
                GetComponent <KMBombModule>().HandleStrike();
                incorrect = false;
                DebugMsg("Incorrect sequence. You pressed " + pressedButton.name + ", when the correct button was " + corButtons[0].name);
                FlickerRoutine = StartCoroutine(FlickerCoRoutine1());
                pressedButton  = null;
            }
        }
        else if (stageNumber == 1)
        {
            if (placeholders.Count != 1)
            {
                placeholders.Add(pressedButton);
            }
            else
            {
                if (pressedButton != corButtons[1] || placeholders[0] != corButtons[0])
                {
                    incorrect = true;
                }

                if (incorrect != true)
                {
                    DebugMsg("Correct sequence. Moving to the next stage.");
                    stageNumber     = stageNumber + 1;
                    pressedButton   = null;
                    placeholders[0] = null;
                    stopLights      = false;
                    placeholders.Clear();
                    FlickerRoutine = StartCoroutine(FlickerCoRoutine3());
                }
                else
                {
                    GetComponent <KMBombModule>().HandleStrike();
                    incorrect = false;
                    DebugMsg("Incorrect sequence. You pressed " + placeholders[0].name + " " + pressedButton.name + ", when the correct sequence was " + corButtons[0].name + " " + corButtons[1].name);
                    pressedButton  = null;
                    FlickerRoutine = StartCoroutine(FlickerCoRoutine2());
                    placeholders.Clear();
                }
            }
        }
        else if (stageNumber == 2)
        {
            {
                if (placeholders.Count < 2)
                {
                    placeholders.Add(pressedButton);
                }
                else
                {
                    if (pressedButton != corButtons[2] || placeholders[0] != corButtons[0] || placeholders[1] != corButtons[1])
                    {
                        incorrect = true;
                    }

                    if (incorrect != true)
                    {
                        DebugMsg("Correct sequence. Moving to the next stage.");
                        stageNumber   = stageNumber + 1;
                        pressedButton = null;
                        stopLights    = false;
                        placeholders.Clear();
                        FlickerRoutine = StartCoroutine(FlickerCoRoutine4());
                    }
                    else
                    {
                        GetComponent <KMBombModule>().HandleStrike();
                        incorrect = false;
                        DebugMsg("Incorrect sequence. You pressed " + placeholders[0].name + " " + placeholders[1].name + " " + pressedButton.name + ", when the correct sequence was " + corButtons[0].name + " " + corButtons[1].name + " " + corButtons[2].name);
                        pressedButton  = null;
                        FlickerRoutine = StartCoroutine(FlickerCoRoutine3());
                        placeholders.Clear();
                    }
                }
            }
        }
        else if (stageNumber == 3)
        {
            if (placeholders.Count < 3)
            {
                placeholders.Add(pressedButton);
            }
            else
            {
                if (pressedButton != corButtons[3] || placeholders[0] != corButtons[0] || placeholders[1] != corButtons[1] || placeholders[2] != corButtons[2])
                {
                    incorrect = true;
                }

                if (incorrect != true)
                {
                    DebugMsg("Correct sequence. Moving to the next stage.");
                    stageNumber   = stageNumber + 1;
                    pressedButton = null;
                    stopLights    = false;
                    placeholders.Clear();
                    FlickerRoutine = StartCoroutine(FlickerCoRoutine5());
                }
                else
                {
                    GetComponent <KMBombModule>().HandleStrike();
                    incorrect = false;
                    DebugMsg("Incorrect sequence. You pressed " + placeholders[0].name + " " + placeholders[1].name + " " + placeholders[2].name + " " + pressedButton.name + ", when the correct sequence was " + corButtons[0].name + " " + corButtons[1].name + " " + corButtons[2].name + " " + corButtons[3].name);
                    pressedButton  = null;
                    FlickerRoutine = StartCoroutine(FlickerCoRoutine4());
                    placeholders.Clear();
                }
            }
        }
        else
        {
            if (placeholders.Count < 4)
            {
                placeholders.Add(pressedButton);
            }
            else
            {
                if (pressedButton != corButtons[4] || placeholders[0] != corButtons[0] || placeholders[1] != corButtons[1] || placeholders[2] != corButtons[2] || placeholders[3] != corButtons[3])
                {
                    incorrect = true;
                }

                if (incorrect != true)
                {
                    moduleSolved = true;
                    GetComponent <KMBombModule>().HandlePass();
                    DebugMsg("Module solved. Have a nice day.");
                    StopAllCoroutines();
                    soundEnabled = false;
                }
                else
                {
                    GetComponent <KMBombModule>().HandleStrike();
                    incorrect = false;
                    DebugMsg("Incorrect sequence. You pressed " + placeholders[0].name + " " + placeholders[1].name + " " + placeholders[2].name + " " + placeholders[3].name + " " + pressedButton.name + ", when the correct sequence was " + corButtons[0].name + " " + corButtons[1].name + " " + corButtons[2].name + " " + corButtons[3].name + " " + corButtons[4].name);
                    pressedButton  = null;
                    FlickerRoutine = StartCoroutine(FlickerCoRoutine5());
                    placeholders.Clear();
                }
            }
        }
    }
    /// <summary>
    /// Helper method to determine whether or not the correct number has been entered and react appropriately
    /// </summary>
    private void CheckSolution()
    {
        //Movement/audio
        submitButton.AddInteractionPunch(.5f);
        bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);

        //Initial submission value
        submission = (digits[0] * 100) + (digits[1] * 10) + digits[2];
        Debug.LogFormat(@"[Modulus Manipulation #{0}] Submitted value {1}.", moduleId, submission);

        //Set up values calculated at solution check
        finalSolution           = startingNumber;
        otherModsRemainingCount = bombInfo.GetSolvableModuleNames().Count() - bombInfo.GetSolvedModuleNames().Count() - 1;
        strikeCount             = bombInfo.GetStrikes();
        minutesRemainingIsEven  = ((int)bombInfo.GetTime() / 60) % 2 == 0;
        Debug.LogFormat(@"[Modulus Manipulation #{0}] Starting value for calculations is {1}.", moduleId, startingNumber);
        Debug.LogFormat(@"[Modulus Manipulation #{0}] There are currently {1} other modules remaining.", moduleId, otherModsRemainingCount);

        //Apply calculations
        if (otherModsRemainingCount % 5 == 0)
        {
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Rule set 5 is applicable.", moduleId);
            //If the bomb has more than one battery, add 400
            if (batteryCount > 1)
            {
                finalSolution += 400;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has more than one battery, adding 400. Solution is now {1}.", moduleId, finalSolution);
            }
            //If the serial number contains the number 3 or 6, subtract 40
            if (serialNumberSpecial)
            {
                finalSolution -= 40;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Serial number contains a 3 or 6, subtracting 40. Solution is now {1}.", moduleId, finalSolution);
            }
        }
        if (otherModsRemainingCount % 4 == 0)
        {
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Rule set 4 is applicable.", moduleId);
            //If the bomb has at least one AA battery and at least one D battery, multiply by 2
            if (aaBatteryCount >= 1 && dBatteryCount >= 1)
            {
                finalSolution *= 2;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has at least one AA battery and one D battery, multiplying by 2. Solution is now {1}.", moduleId, finalSolution);
            }
            //If the serial number has 4 letters, subtract 290
            if (serialLetterSpecial)
            {
                finalSolution -= 290;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Serial number has 4 letters, subtracting 290. Solution is now {1}.", moduleId, finalSolution);
            }
        }
        if (otherModsRemainingCount % 3 == 0)
        {
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Rule set 3 is applicable.", moduleId);
            //If the bomb has more than three batteries, subtract 160
            if (batteryCount > 3)
            {
                finalSolution -= 160;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has more than three batteries, subtracting 160. Solution is now {1}.", moduleId, finalSolution);
            }
            //If the bomb has more lit indicators than unlit indicators, add 75
            if (litIndicatorCount > unlitIndicatorCount)
            {
                finalSolution += 75;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has more lit indicators than unlit indicators, adding 75. Solution is now {1}.", moduleId, finalSolution);
            }
        }
        if (otherModsRemainingCount % 2 == 0)
        {
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Rule set 2 is applicable.", moduleId);
            //If the serial number has a vowel, add 340
            if (serialVowel)
            {
                finalSolution += 340;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Serial number has a vowel, adding 340. Solution is now {1}.", moduleId, finalSolution);
            }
            //If the bomb has a PS/2, RJ-45, or Serial port, add 180
            if (containsSpecificPorts)
            {
                finalSolution += 180;
                Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has a PS/2, RJ-45, or Serial port, adding 180. Solution is now {1}.", moduleId, finalSolution);
            }
        }
        //Anything modulus 1 is 0, so rule set 1 always applies and needs no if statement
        Debug.LogFormat(@"[Modulus Manipulation #{0}] Rule set 1 is applicable.", moduleId);
        //If the bomb has at least one strike, subtract 45
        if (strikeCount >= 1)
        {
            finalSolution -= 45;
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has at least one strike, subtracting 45. Solution is now {1}.", moduleId, finalSolution);
        }
        //If the bomb has any unlit indicators, subtract 15
        if (unlitIndicatorCount > 0)
        {
            finalSolution -= 15;
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Bomb has at least one unlit indicator, subtracting 15. Solution is now {1}.", moduleId, finalSolution);
        }
        //If the last digit of the serial number is even, add 150
        if (serialLastDigitEven)
        {
            finalSolution += 150;
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Last digit of the serial number is even, adding 150. Solution is now {1}.", moduleId, finalSolution);
        }
        //If the number of minutes remaining on the countdown timer is even (or 0), add 6
        if (minutesRemainingIsEven)
        {
            finalSolution += 6;
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Minutes remaining is even or 0, adding 6. Solution is now {1}.", moduleId, finalSolution);
        }

        //Compare final solution with input
        if (finalSolution < 0)
        {
            finalSolution = 0;
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Calculated solution was negative, so final solution is 0.", moduleId);
        }
        else
        {
            finalSolution %= 1000;
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Final solution is {1}.", moduleId, finalSolution);
        }
        if (submission == finalSolution)
        {
            bombModule.HandlePass();
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Submission was correct. Module passed.", moduleId);
        }
        else
        {
            bombModule.HandleStrike();
            Debug.LogFormat(@"[Modulus Manipulation #{0}] Submission was incorrect. Strike occurred.", moduleId);
        }
    }
예제 #24
0
    public void PressDown()
    {
        if (moduleSolved || flashing)
        {
            return;
        }
        moveDown.AddInteractionPunch();
        if (currentStage == 1 || currentStage == 9)
        {
            currentLevelInfo = level1Info;
            foreach (Renderer indicator in level1Info.level1Indicators)
            {
                if (indicator.GetComponent <PositionRules>().isActive)
                {
                    currentActive = indicator;
                }
            }
        }
        else if (currentStage == 2 || currentStage == 8)
        {
            currentLevelInfo = level2Info;
            foreach (Renderer indicator in level2Info.level1Indicators)
            {
                if (indicator.GetComponent <PositionRules>().isActive)
                {
                    currentActive = indicator;
                }
            }
        }
        else if (currentStage == 3 || currentStage == 7)
        {
            currentLevelInfo = level3Info;
            foreach (Renderer indicator in level3Info.level1Indicators)
            {
                if (indicator.GetComponent <PositionRules>().isActive)
                {
                    currentActive = indicator;
                }
            }
        }
        else if (currentStage == 4 || currentStage == 6)
        {
            currentLevelInfo = level4Info;
            foreach (Renderer indicator in level4Info.level1Indicators)
            {
                if (indicator.GetComponent <PositionRules>().isActive)
                {
                    currentActive = indicator;
                }
            }
        }
        else if (currentStage == 5)
        {
            currentLevelInfo = level5Info;
            foreach (Renderer indicator in level5Info.level1Indicators)
            {
                if (indicator.GetComponent <PositionRules>().isActive)
                {
                    currentActive = indicator;
                }
            }
        }

        if (!currentActive.GetComponent <PositionRules>().canMoveDown)
        {
            GetComponent <KMBombModule>().HandleStrike();
            Debug.LogFormat("[The Labyrinth #{0}] Strike! You tried to move down from position {1} in layer {2}. That is not allowed.", moduleId, currentActive.name, currentLevelInfo.level);
            flashing = true;
            if (currentStage <= 5)
            {
                StartCoroutine(strikeFlash());
            }
            else
            {
                StartCoroutine(portalFlash());
            }
        }
        else
        {
            Audio.PlaySoundAtTransform("move", transform);
            currentActive.GetComponent <PositionRules>().toDown.enabled = true;
            currentActive.GetComponent <PositionRules>().toDown.GetComponent <PositionRules>().isActive = true;
            currentActive.GetComponent <PositionRules>().isActive = false;
            currentActive.enabled  = false;
            currentActive          = currentActive.GetComponent <PositionRules>().toDown;
            currentActive.material = level1Info.activeMat;
        }
        CheckForTarget();
    }
예제 #25
0
    void KeyPress(KMSelectable Key)
    {
        if (!moduleSolved && !currentlyCalculating)
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Key.transform);
            Key.AddInteractionPunch(.4f);
            Debug.LogFormat("[Kanji #{0}] You pressed '{1}'.", moduleId, Key.GetComponentInChildren <TextMesh>().text);

            if (unicorn && Key == Keys[3])
            {
                HandleSolve();
                return;
            }

            if (Stage == 1)
            {
                if (s1CorrectButton == 0 && Key == Keys[0])
                {
                    StageAdvance();
                }
                else if (s1CorrectButton == 1 && Key == Keys[1])
                {
                    StageAdvance();
                }
                else if (s1CorrectButton == 2 && Key == Keys[2])
                {
                    StageAdvance();
                }
                else if (s1CorrectButton == 3 && Key == Keys[3])
                {
                    StageAdvance();
                }
                else
                {
                    HandleStrike();
                }
            }
            else if (Stage == 2)
            {
                if (s2CorrectButton == 0 && Key == Keys[0])
                {
                    StageAdvance();
                }
                else if (s2CorrectButton == 1 && Key == Keys[1])
                {
                    StageAdvance();
                }
                else if (s2CorrectButton == 2 && Key == Keys[2])
                {
                    StageAdvance();
                }
                else if (s2CorrectButton == 3 && Key == Keys[3])
                {
                    StageAdvance();
                }
                else
                {
                    HandleStrike();
                }
            }
            else if (Stage == 3)
            {
                if (s3CorrectButton == 0 && Key == Keys[0])
                {
                    StageAdvance();
                }
                else if (s3CorrectButton == 1 && Key == Keys[1])
                {
                    StageAdvance();
                }
                else if (s3CorrectButton == 2 && Key == Keys[2])
                {
                    StageAdvance();
                }
                else if (s3CorrectButton == 3 && Key == Keys[3])
                {
                    StageAdvance();
                }
                else
                {
                    HandleStrike();
                }
            }
        }
    }
예제 #26
0
    protected IEnumerable ButtonPress(KMSelectable knob)
    {
        knob.AddInteractionPunch(0.5f);
        Audio.PlaySoundAtTransform("valve_spin", knob.transform);

        if (!SOLVED)
        {
            canPress = false;
            if ((knob == Hot && knob2Turn[curKnob]) || (knob == Cold && !knob2Turn[curKnob]))
            {
                coroutine = KnobTurn(knob, 2.5f);
                while (coroutine.MoveNext())
                {
                    yield return(coroutine.Current);
                }
                hotP  += knob == Hot ? 2.5f : 0;
                coldP += knob == Cold ? 2.5f : 0;
                if (curKnob == 2)
                {
                    if (rotate && c == 0 && spin > 1500)
                    {
                        c = 1;
                        WaitForSol();
                        yield break;
                    }
                    Solve();
                }
                else if (rotate && c == 0 && spin > 1295)
                {
                    c = 2;
                    WaitForSol();
                    yield break;
                }
                else if (rotate && c == 0)
                {
                    c = 3;
                    WaitForSol();
                    yield break;
                }
                curKnob++;
            }
            else
            {
                coroutine = KnobTurn(knob, -2.5f);
                while (coroutine.MoveNext())
                {
                    yield return(coroutine.Current);
                }
                hotP      += knob == Hot ? -2.5f : 0;
                coldP     += knob == Cold ? -2.5f : 0;
                coroutine  = KnobTurn(Cold, -coldP);
                coroutine2 = KnobTurn(Hot, -hotP);
                while (coroutine.MoveNext() && coroutine2.MoveNext())
                {
                    yield return(new [] { coroutine.Current, coroutine2.Current });
                }
                hotP  = 0;
                coldP = 0;
                Module.HandleStrike();
                processingInput = false;
                curKnob         = 0;
            }
            canPress = true;
        }
        yield return(null);
    }
예제 #27
0
    void Init()
    {
        realUnplayed = testCharacters[1];
        for (int q = 0; q < 15; q++)
        {
            gameType[q] = "X";
            contenderWins[q] = false;
            unplayedGames[q] = false;
            curGameState[q] = "B";
            meshC[q].material.color = colory[0];
            meshB[q].material.color = colory[1];
            buttonsB[q].GetComponentInChildren<TextMesh>().color = colory[0];
            buttonsC[q].GetComponentInChildren<TextMesh>().color = colory[3];
        }
        DumbDelegationThing();

        buttonSubmit.OnInteract += delegate () { OnPress(); PressedSubmit(); buttonSubmit.AddInteractionPunch(0.4f); return false; };

        buttonsU[0].OnInteract += delegate () { OnPress(); PressedUnplayed(0); buttonsU[0].AddInteractionPunch(0.2f); return false; };
        buttonsU[1].OnInteract += delegate () { OnPress(); PressedUnplayed(1); buttonsU[1].AddInteractionPunch(0.2f); return false; };
        buttonsU[2].OnInteract += delegate () { OnPress(); PressedUnplayed(2); buttonsU[2].AddInteractionPunch(0.2f); return false; };
        buttonsU[3].OnInteract += delegate () { OnPress(); PressedUnplayed(3); buttonsU[3].AddInteractionPunch(0.2f); return false; };

        buttonSubmit.OnInteractEnded += delegate () { OnRelease(); };

        buttonsU[0].OnInteractEnded += delegate () { OnRelease(); };
        buttonsU[1].OnInteractEnded += delegate () { OnRelease(); };
        buttonsU[2].OnInteractEnded += delegate () { OnRelease(); };
        buttonsU[3].OnInteractEnded += delegate () { OnRelease(); };

        meshUn[0].material.color = colory[0];
        meshUn[1].material.color = colory[0];
        meshUn[2].material.color = colory[0];
        meshUn[3].material.color = colory[0];
        buttonsU[0].GetComponentInChildren<TextMesh>().color = colory[1];
        buttonsU[1].GetComponentInChildren<TextMesh>().color = colory[1];
        buttonsU[2].GetComponentInChildren<TextMesh>().color = colory[1];
        buttonsU[3].GetComponentInChildren<TextMesh>().color = colory[1];
        numPorts = Math.Min(6, bomb.GetPortCount());
        numBatteries = Math.Min(5, bomb.GetBatteryCount());
        numIndicators = Math.Min(3, bomb.GetIndicators().Count());

        for (int i = 0; i < 6; i++)
        {
            snCharacter[i] = bomb.GetSerialNumber().Substring(i,1);
            if (snCharacter[i].Contains("1") || snCharacter[i].Contains("2") || snCharacter[i].Contains("3") ||
                snCharacter[i].Contains("4") || snCharacter[i].Contains("5") || snCharacter[i].Contains("6") ||
                snCharacter[i].Contains("7") || snCharacter[i].Contains("8") || snCharacter[i].Contains("9") ||
                snCharacter[i].Contains("0"))
            {
                snValue[i] = Int32.Parse(snCharacter[i]);
            }
            else
            {
                int cLetterNumber = 0;
                while (alphabet[cLetterNumber] != snCharacter[i])
                {
                    cLetterNumber++;
                }
                snValue[i] = 1 + cLetterNumber;
            }
        }
        
        tpStages = 0;
        contenderNumber = UnityEngine.Random.Range(0, 27);
        //TextMesh contenderText = c.GetComponentInChildren<TextMesh>();

        TextMesh contenderText = contenderName.GetComponent<TextMesh>();
        contenderText.text = contender[contenderNumber].ToUpperInvariant();
        contestantName = contender[contenderNumber];
        contenderRatings = ratings[contenderNumber];
        Debug.LogFormat("[Schlag den Bomb #{0}] Contender name is {1}. Ports = {2}, Batteries = {3}, Indicators = {4} (Over 6/5/3 counts as 6/5/3)", _moduleId, 
            contender[contenderNumber], numPorts, numBatteries, numIndicators);
        Debug.LogFormat("[Schlag den Bomb #{0}] SN {1}, values {2} {3} {4} {5} {6} {7}", _moduleId, bomb.GetSerialNumber(), snValue[0], snValue[1], snValue[2], snValue[3], snValue[4], snValue[5]);

        bool inLoop = false;
        int curGameTypeNum = 0;

        if (snValue[0] == 0)
        {
            snValue[0] = 15;
        }
        else if(snValue[0] > 15)
        {
            snValue[0] = snValue[0] - 15;
        }
        for (int pl = 0; pl < 6; pl++)
        {
            if (snValue[pl] == 0)
            {
                snValue[pl] = 1;
            }
        }
        gameType[snValue[0] - 1] = "O";
        //Debug.LogFormat("[Schlag den Bomb #{0}] Game {1} is now an O.", _moduleId, snValue[0]);
        int assignsLeft = 5;
        int stepsLeft = 0;
        int currentStep = snValue[0] - 1;
        //Debug.Log("Starting on game " + (snValue[0] - 1));
        
        while (assignsLeft > 0)
        {
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
            // 3 2 1 0
            stepsLeft = snValue[6 - assignsLeft];

            while (stepsLeft > 0 || !inLoop)
            {
                inLoop = true;
                if (gameType[currentStep] != "X")
                {
                    stepsLeft++;
                    //Debug.Log("Game " + currentStep + " is already type " + gameType[currentStep] + ".");
                }
                stepsLeft--;
                if (stepsLeft != 0 && (snValue[6 - assignsLeft] != 0))
                {
                    currentStep++;
                }
                

                if (currentStep > 14)
                {
                    currentStep = 0;
                }
                //Debug.LogFormat("Step to {0}, which is a {1}. {2} step(s) left.", currentStep, gameType[currentStep], stepsLeft);
            }

            gameType[currentStep] = "O";
            //Debug.LogFormat("[Schlag den Bomb #{0}] Game {0} is now an O.", _moduleId, currentStep + 1);
            assignsLeft--;
            inLoop = false;
        }
        curGameTypeNum = (contenderRatings / 100);
        Debug.LogFormat("[Schlag den Bomb #{0}] Phys rating = {1}", _moduleId, curGameTypeNum);
        assignsLeft = 3;
        stepsLeft = 0;
        inLoop = false;
        while (assignsLeft > 0)
        {
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
            // 3 2 1 0
            stepsLeft = portSteps[numPorts, 3 - assignsLeft];

            while (stepsLeft > 0 || !inLoop)
            {
                inLoop = true;
                if (gameType[currentStep] != "X")
                {
                    stepsLeft++;
                    //Debug.Log("Game " + currentStep + " is already type " + gameType[currentStep] + ".");
                }
                stepsLeft--;
                if (stepsLeft != 0 && (snValue[3 - assignsLeft] != 0))
                {
                    currentStep++;
                }


                if (currentStep > 14)
                {
                    currentStep = 0;
                }
                //Debug.LogFormat("Step to {0}, which is a {1}. {2} step(s) left.", currentStep, gameType[currentStep], stepsLeft);
            }

            gameType[currentStep] = "P";
            Debug.LogFormat("[Schlag den Bomb #{0}] Game {1} is now a Physical game.{2}", _moduleId, currentStep + 1, 3 - assignsLeft < curGameTypeNum ? " Contender wins." : "");
            if (3 - assignsLeft < curGameTypeNum)
            {
                contenderWins[currentStep] = true;
            }
            assignsLeft--;
            inLoop = false;
        }
        curGameTypeNum = (contenderRatings - ((contenderRatings / 100)*100)) / 10;
        Debug.LogFormat("[Schlag den Bomb #{0}] Mental rating = {1}", _moduleId, curGameTypeNum);
        assignsLeft = 3;
        stepsLeft = 0;
        inLoop = false;
        while (assignsLeft > 0)
        {
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
            // 3 2 1 0
            stepsLeft = batterySteps[numBatteries, 3 - assignsLeft];

            while (stepsLeft > 0 || !inLoop)
            {
                inLoop = true;
                if (gameType[currentStep] != "X")
                {
                    stepsLeft++;
                    //Debug.Log("Game " + currentStep + " is already type " + gameType[currentStep] + ".");
                }
                stepsLeft--;
                if (stepsLeft != 0 && (snValue[3 - assignsLeft] != 0))
                {
                    currentStep++;
                }


                if (currentStep > 14)
                {
                    currentStep = 0;
                }
                //Debug.LogFormat("Step to {0}, which is a {1}. {2} step(s) left.", currentStep, gameType[currentStep], stepsLeft);
            }

            gameType[currentStep] = "M";
            Debug.LogFormat("[Schlag den Bomb #{0}] Game {1} is now a Mental game.{2}", _moduleId, currentStep + 1, 3 - assignsLeft < curGameTypeNum ? " Contender wins." : "");
            if (3 - assignsLeft < curGameTypeNum)
            {
                contenderWins[currentStep] = true;
            }
            assignsLeft--;
            inLoop = false;
        }
        curGameTypeNum = (contenderRatings) - (100 * (contenderRatings / 100)) - (10 * ((contenderRatings - ((contenderRatings / 100) * 100)) / 10));
        Debug.LogFormat("[Schlag den Bomb #{0}] Quiz rating = {1}", _moduleId, curGameTypeNum);
        assignsLeft = 3;
        stepsLeft = 0;
        inLoop = false;
        while (assignsLeft > 0)
        {
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4
            // 3 2 1 0
            stepsLeft = indicatorSteps[numIndicators, 3 - assignsLeft];

            while (stepsLeft > 0 || !inLoop)
            {
                inLoop = true;
                if (gameType[currentStep] != "X")
                {
                    stepsLeft++;
                    //Debug.Log("Game " + (currentStep + 1) + " is already type " + gameType[currentStep] + ".");
                }
                stepsLeft--;
                if (stepsLeft != 0 && (snValue[3 - assignsLeft] != 0))
                {
                    currentStep++;
                }


                if (currentStep > 14)
                {
                    currentStep = 0;
                }
                //Debug.LogFormat("Step to {0}, which is a {1}. {2} step(s) left.", currentStep + 1, gameType[currentStep], stepsLeft);
            }

            gameType[currentStep] = "Q";
            Debug.LogFormat("[Schlag den Bomb #{0}] Game {1} is now a Quiz game.{2}", _moduleId, currentStep + 1, 3 - assignsLeft < curGameTypeNum ? " Contender wins." : "");
            if (3 - assignsLeft < curGameTypeNum)
            {
                contenderWins[currentStep] = true;
            }
            assignsLeft--;
        }
        //Debug.LogFormat("Game order: ");
        bool uhOh = true;
        string oddities = "";
        while (uhOh)
        {
            uhOh = false;
            for (int j = 0; j < 15; j++)
            {
                //Debug.LogFormat("Game {0} is {1}", ((j + 1)), gameType[j]);
                // Debug.LogFormat("Game {0} is {1}", (j + 1); gameType[j]);
                //Debug.Log("Game " + (j + 1) + " is " + gameType[j]);
                if (gameType[j] == "O")
                {
                    oddities = oddities + (j + 1) + " ";

                    if (UnityEngine.Random.Range(0, 2) == 1)
                    {
                        //Debug.LogFormat("Contender wins game {0}.", (j + 1));
                        contenderWins[j] = true;
                    }
                }

            }
            Debug.LogFormat("[Schlag den Bomb #{0}] Oddball games = {1}", _moduleId, oddities);
            oddities = "";
            scoreC = 0;
            scoreB = 0;
            for (int fs = 0; fs < 15; fs++)
            {
                if (scoreC > 60 || scoreB > 60)
                {
                    unplayedGames[fs] = true;
                    Debug.LogFormat("[Schlag den Bomb #{0}] Game number {1} is unplayed.", _moduleId, fs + 1);
                    realUnplayed = realUnplayed + (1 + fs) + " ";
                }
                else if (contenderWins[fs])
                {
                    scoreC = scoreC + 1 + fs;
                    //Debug.Log("Contender score " + scoreC);
                }
                else
                {
                    scoreB = scoreB + 1 + fs;
                    //Debug.Log("Bomb score " + scoreB);
                }
            }
            if (scoreC == 60)
            {
                Debug.LogFormat("[Schlag den Bomb #{0}] 60-60 tie detected, trying again.", _moduleId);
                uhOh = true;
            }

        }
        var potentialSolution = "One potential solution: ";
        for (int cg = 0; cg < 15; cg++)
        {
            if (contenderWins[cg] && !unplayedGames[cg])
            {
                potentialSolution = potentialSolution + "" + (cg + 1) + ", ";
            }
            else if (unplayedGames[cg])
            {
                potentialSolution = potentialSolution + "game " + (cg + 1) + " unplayed, ";
            }
        }
        potentialSolution = potentialSolution + "and that's it!";
        Debug.LogFormat("[Schlag den Bomb #{0}] Final score: Contender {1} - {2} Bomb. Contender {3}.", _moduleId, scoreC, scoreB, scoreC > 60 ? "wins" : "loses");
        Debug.LogFormat("[Schlag den Bomb #{0}] {1}", _moduleId, potentialSolution);
        TextMesh contyScore = contenderScore.GetComponent<TextMesh>();
        TextMesh bombaScore = bombScore.GetComponent<TextMesh>();

        contyScore.text = Convert.ToString(scoreC);
        bombaScore.text = Convert.ToString(scoreB);
        pressedAllowed = true;
    }
예제 #28
0
    void PressServe()
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, serve.transform);
        serve.AddInteractionPunch();
        if (_IsSolved)
        {
            return;
        }

        for (int slot = 0; slot < 2; slot++)
        {
            var preparedDrink = slot == 1 ? slot2input : slot1input;
            var expectedDrink = slot == 1 ? expectedDrink2 : expectedDrink1;

            if (preparedDrink.State == DrinkState.Bottled)
            {
                Debug.LogFormat("[Bartending #{0}] You served {1}. {2} wanted {3}.", moduleId, preparedDrink.Name, currentPatron, expectedDrink.Name);
                if (preparedDrink.Name == expectedDrink.Name)
                {
                    Debug.LogFormat("[Bartending #{0}] The {1} drink is correct!", moduleId, slot == 0 ? "first" : "second");
                }
                else
                {
                    StrikeAndRegenerate();
                    return;
                }
            }
            else if (preparedDrink.State == DrinkState.Mixed || preparedDrink.State == DrinkState.Blended)
            {
                if (expectedDrink.State == DrinkState.Bottled)
                {
                    Debug.LogFormat("[Bartending #{0}] You served a {3}, but {1} wanted a {2}.", moduleId, currentPatron, expectedDrink.Name, preparedDrink.Name);
                    StrikeAndRegenerate();
                    return;
                }
                var isBigDrink = preparedDrink.IsSameRecipeAs(expectedDrink, true);
                Debug.LogFormat("[Bartending #{0}] You served a {1}{2} ({3}). {4} wanted a {5}{6}.", moduleId,
                                isBigDrink ? "big " : "", preparedDrink.Name, preparedDrink.LoggingString(ingNames), currentPatron, bigDrinkExpected ? "big " : "", expectedDrink.Name);
                if (preparedDrink.Name == expectedDrink.Name && isBigDrink == bigDrinkExpected)
                {
                    Debug.LogFormat("[Bartending #{0}] The {1} drink is correct!", moduleId, slot == 0 ? "first" : "second");
                }
                else
                {
                    StrikeAndRegenerate();
                    return;
                }
            }
            else if (preparedDrink.State == DrinkState.Unprepared)
            {
                Debug.LogFormat("[Bartending #{0}] You served no drink in slot {1}. {2} wanted {3}.", moduleId, slot == 0 ? 1 : 2, currentPatron, expectedDrink2.State == DrinkState.Unprepared ? "1 drink" : "2 drinks");
                if (expectedDrink.State == DrinkState.Unprepared)
                {
                    Debug.LogFormat("[Bartending #{0}] The {1} drink is correct!", moduleId, slot == 0 ? "first" : "second");
                }
                else
                {
                    Debug.LogFormat("[Bartending #{0}] You served an unprepared drink when {1} expected a drink! Strike!", moduleId, currentPatron);
                    StrikeAndRegenerate();
                    return;
                }
            }
            else
            {
                Debug.LogFormat("[Bartending #{0}] You tried to serve a failed drink!", moduleId);
                StrikeAndRegenerate();
                return;
            }
        }

        // Both drinks were correct!
        Debug.LogFormat("[Bartending #{0}] Drinks correctly served! Module solved!", moduleId);
        Module.HandlePass();
        if (Bomb.GetSolvedModuleNames().Count < Bomb.GetSolvableModuleNames().Count)
        {
            Audio.PlaySoundAtTransform("solve", transform);
        }
        for (int i = 0; i < screens.Length; i++)
        {
            screens[i].material.mainTexture = GrayScreen;
        }
        for (int i = 0; i < ingNames.Length; i++)
        {
            ingValuesText[i].text = _Blank.ToString();
        }
        _IsSolved = true;
    }
예제 #29
0
    void buttonPress(KMSelectable button)
    {
        button.AddInteractionPunch(0.1f);
        for (int i = 0; i < 9; i++)
        {
            if (button == Buttons[i])
            {
                switch (state)
                {
                case 0:
                    firstdigitchosen = i;
                    state            = 1;
                    Texts[i].color   = Colors[1];
                    break;

                case 1:
                    seconddigitchosen = i;
                    if (firstdigitchosen > seconddigitchosen)
                    {
                        SwapTheTwoValues();
                    }
                    for (int k = firstdigitchosen; k < seconddigitchosen; k++)
                    {
                        Texts[k].color = Colors[1];
                    }
                    Texts[firstdigitchosen].color  = Colors[2];
                    Texts[seconddigitchosen].color = Colors[3];
                    state           = 2;
                    subnumberstring = numberstring.Substring(firstdigitchosen, (seconddigitchosen - firstdigitchosen) + 1);
                    if (firstdigitchosen == 0)
                    {
                        presub = "";
                    }
                    else
                    {
                        presub = numberstring.Substring(0, firstdigitchosen);
                    }
                    if (seconddigitchosen == numberstring.Length - 1)
                    {
                        postsub = "";
                    }
                    else
                    {
                        postsub = numberstring.Substring(seconddigitchosen + 1, (numberstring.Length - 1) - seconddigitchosen);
                    }
                    Debug.LogFormat("[Squeeze #{0}] Selected {1}({2}){3}.", moduleId, presub, subnumberstring, postsub);
                    subnumberint = Int32.Parse(subnumberstring);
                    if (subnumberint % 2 == 1)
                    {
                        subnumberint *= 2;
                        numberstring  = presub + subnumberint.ToString() + postsub;
                        state         = 0;
                        Debug.LogFormat("[Squeeze #{0}] Doubled. Results in {1}", moduleId, numberstring);
                        Audio.PlaySoundAtTransform("doub", transform);
                        ChangeButtons();
                    }
                    else if (firstdigitchosen == seconddigitchosen)
                    {
                        StartCoroutine(Blink(seconddigitchosen));
                        state = 3;
                    }
                    break;

                case 2:
                    if (i == firstdigitchosen)
                    {
                        subnumberint /= 2;
                        numberstring  = presub + subnumberint.ToString() + postsub;
                        state         = 0;
                        Debug.LogFormat("[Squeeze #{0}] Halved. Results in {1}", moduleId, numberstring);
                        Audio.PlaySoundAtTransform("halv", transform);
                        ChangeButtons();
                    }
                    else if (i == seconddigitchosen)
                    {
                        subnumberint *= 2;
                        numberstring  = presub + subnumberint.ToString() + postsub;
                        state         = 0;
                        Debug.LogFormat("[Squeeze #{0}] Doubled. Results in {1}", moduleId, numberstring);
                        Audio.PlaySoundAtTransform("doub", transform);
                        ChangeButtons();
                    }
                    break;

                case 3:
                    if (blinkingnumberstate == 0)
                    {
                        subnumberint /= 2;
                        numberstring  = presub + subnumberint.ToString() + postsub;
                        state         = 0;
                        Debug.LogFormat("[Squeeze #{0}] Halved. Results in {1}", moduleId, numberstring);
                        Audio.PlaySoundAtTransform("halv", transform);
                        ChangeButtons();
                    }
                    else
                    {
                        subnumberint *= 2;
                        numberstring  = presub + subnumberint.ToString() + postsub;
                        state         = 0;
                        Debug.LogFormat("[Squeeze #{0}] Doubled. Results in {1}", moduleId, numberstring);
                        Audio.PlaySoundAtTransform("doub", transform);
                        ChangeButtons();
                    }
                    StopAllCoroutines();
                    break;

                default: break;
                }
            }
        }
    }
예제 #30
0
 void PressButton(KMSelectable pressed)
 {
     if (moduleSolved != true && activated == true && !numDisplay.GetComponent <TextMesh>().text.Equals(" "))
     {
         pressed.AddInteractionPunch(0.25f);
         audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         if (pressed == buttons[0] && !moves[current].Equals("UP") && !moves[current].Equals("ANY"))
         {
             GetComponent <KMBombModule>().HandleStrike();
             Debug.LogFormat("[Yellow Arrows #{0}] The button 'UP' was incorrect, expected '{1}'! Resetting module...", moduleId, moves[current]);
             Start();
         }
         else if (pressed == buttons[1] && !moves[current].Equals("DOWN") && !moves[current].Equals("ANY"))
         {
             GetComponent <KMBombModule>().HandleStrike();
             Debug.LogFormat("[Yellow Arrows #{0}] The button 'DOWN' was incorrect, expected '{1}'! Resetting module...", moduleId, moves[current]);
             Start();
         }
         else if (pressed == buttons[2] && !moves[current].Equals("LEFT") && !moves[current].Equals("ANY"))
         {
             GetComponent <KMBombModule>().HandleStrike();
             Debug.LogFormat("[Yellow Arrows #{0}] The button 'LEFT' was incorrect, expected '{1}'! Resetting module...", moduleId, moves[current]);
             Start();
         }
         else if (pressed == buttons[3] && !moves[current].Equals("RIGHT") && !moves[current].Equals("ANY"))
         {
             GetComponent <KMBombModule>().HandleStrike();
             Debug.LogFormat("[Yellow Arrows #{0}] The button 'RIGHT' was incorrect, expected '{1}'! Resetting module...", moduleId, moves[current]);
             Start();
         }
         else
         {
             if (pressed == buttons[0])
             {
                 movesperf[current] = "UP";
                 Debug.LogFormat("[Yellow Arrows #{0}] The button 'UP' was correct.", moduleId);
             }
             else if (pressed == buttons[1])
             {
                 movesperf[current] = "DOWN";
                 Debug.LogFormat("[Yellow Arrows #{0}] The button 'DOWN' was correct.", moduleId);
             }
             else if (pressed == buttons[2])
             {
                 movesperf[current] = "LEFT";
                 Debug.LogFormat("[Yellow Arrows #{0}] The button 'LEFT' was correct.", moduleId);
             }
             else if (pressed == buttons[3])
             {
                 movesperf[current] = "RIGHT";
                 Debug.LogFormat("[Yellow Arrows #{0}] The button 'RIGHT' was correct.", moduleId);
             }
             current++;
             if (current == 5)
             {
                 moduleSolved = true;
                 StartCoroutine(victory());
             }
             else
             {
                 getMoves();
             }
         }
     }
 }