Exemple #1
0
    void SwitchPress()
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
        Switch.AddInteractionPunch();

        if (solved)
        {
            return;
        }

        foreach (Compound r in chosenReaction.Reagents)
        {
            if (solventAdded < 100.000m)   //Missing solvent, nothing inputted.
            {
                Module.HandleStrike();
                DebugLog("Not enough solvent was added (" + solventAdded + chosenReaction.Solvent.GetUnit() + "), strike. Vessel contents reset.");
                ResetModule();
                return;
            }
            if (!addedCompounds.Contains(r))     //Missing an ingredient.
            {
                Module.HandleStrike();
                DebugLog("Missing reagent " + r.GetLogString() + ". Strike, vessel contents reset.");
                ResetModule();
                return;
            }
            else if (addedAmounts[addedCompounds.IndexOf(r)] != chosenReaction.GetReagentAmount(r, productAmount))     //Incorrect amount.
            {
                Module.HandleStrike();
                DebugLog("Incorrect amount " + addedAmounts[addedCompounds.IndexOf(r)] + r.GetUnit() + " for reagent " + r.GetLogString() + ". Strike, vessel contents reset.");
                ResetModule();
                return;
            }
        }
        SolveModule();
        Switch.transform.Rotate(-24, 0, 0, Space.Self);
    }
Exemple #2
0
    void Init()
    {
        for (int i = 0; i < formulaShow.Length; i++)
        {
            formulaShow[i] = Random.value < .5 ? true : false;
        }
        AmountGroup.SetActive(false);

        readChar       = (char)Random.Range(65, 91);
        readColor      = Random.Range(0, 8);
        ReadText.text  = "" + readChar;
        ReadText.color = readColors[readColor];
        DebugLog("Displayed letter is " + readColorLogs[readColor] + " " + readChar);

        int serialSum   = KMBombInfoExtensions.GetSerialNumberNumbers(Info).Sum();
        int reactionNum = readChar - 65;

        if (reactionNum > serialSum)
        {
            reactionNum -= serialSum;
        }
        reactionNum   %= 8;
        chosenReaction = reactions[reactionNum];

        productAmount  = readColorValues[readColor];
        productAmount += KMBombInfoExtensions.GetOffIndicators(Info).Count();
        int portCount = KMBombInfoExtensions.GetPortCount(Info);

        if (portCount > 1)
        {
            productAmount *= portCount;
        }
        productAmount %= 50;
        if (productAmount == 0)
        {
            productAmount = 50;
        }
        productAmount *= 10;
        productAmount -= KMBombInfoExtensions.GetOnIndicators(Info).Count();
        if (productAmount <= 0)
        {
            DebugLog("That's a lot of lit indicators. I guess you deserve this.");
            SolveModule();
            return;
        }

        if (chosenReaction.Solvent == null)
        {
            solventAdded = 100.000m;
        }

        DebugLog("Reaction: " + chosenReaction.Product.GetLogString());
        DebugLog("Product amount: " + productAmount + "g");
        DebugLog("Solvent: " + (chosenReaction.Solvent == null ? "None" : chosenReaction.Solvent.GetLogString()));
        DebugLog("Required reagents:");
        foreach (Compound r in chosenReaction.Reagents)
        {
            DebugLog(" - " + chosenReaction.GetReagentAmount(r, productAmount) + r.GetUnit() + " of " + r.GetLogString());
        }
        DebugLog("----------------------------------");
    }