Exemplo n.º 1
0
    void SolveModule()
    {
        amountMode = false;
        AmountGroup.SetActive(false);
        TypeGroup.SetActive(true);
        userInput = 0;

        addedCompounds.Clear();
        addedAmounts.Clear();
        solventAdded = 0;

        visibleContent = new Compound[14];
        visSolidIndex  = 0;
        for (int i = 0; i < visLiquidIndex; i++)
        {
            visibleContent[i] = chosenReaction.Product;
        }
        visLiquidIndex = 0;
        UpdateVesselContents();

        TypeText.text     = "Successful reaction.";
        TypeText.fontSize = 90;

        DebugLog("Reaction correctly started. Module solved.");
        Module.HandlePass();
        solved = true;
    }
Exemplo n.º 2
0
    void ResetModule()
    {
        amountMode = false;
        AmountGroup.SetActive(false);
        TypeGroup.SetActive(true);
        userInput = 0;

        addedCompounds.Clear();
        addedAmounts.Clear();
        solventAdded = chosenReaction.Solvent == null ? 100.000m : 0m;
        for (int i = 0; i < 14; i++)
        {
            visibleContent[i] = null;
        }
        visSolidIndex  = 0;
        visLiquidIndex = 0;
        UpdateVesselContents();
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        anim.UpdateAnimation();

        if (anim.AnimationDone && dispSwitchFollowup > 0)
        {
            if (dispSwitchFollowup == 1)
            {
                dispMode = prevMode;
            }
            else
            {
                dispMode = nextMode;
            }
            DeployDispenser();

            amountMode = false;
            AmountGroup.SetActive(false);
            TypeGroup.SetActive(true);
            userInput = 0;

            dispSwitchFollowup = 0;
        }
    }
Exemplo n.º 4
0
    void ConfirmButtonPress()
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);

        if (solved)
        {
            return;
        }

        if (amountMode)
        {
            amountMode = false;
            AmountGroup.SetActive(false);
            TypeGroup.SetActive(true);

            if (userInput > 0)
            {
                ConfirmButton.AddInteractionPunch(Mathf.Min((float)userInput / 2f, 2f));
                if (chosenReaction.Solvent == selectedCompound)
                {
                    solventAdded += userInput;
                    DebugLog("Added " + userInput + selectedCompound.GetUnit() + " of solvent. Total solvent amount is now " +
                             solventAdded + selectedCompound.GetUnit() + ".");
                    int slvLevel = (int)(7 * solventAdded / 100);
                    while (slvLevel > visLiquidIndex)
                    {
                        visibleContent[visLiquidIndex++] = chosenReaction.Solvent;
                    }
                    UpdateVesselContents();
                }
                else if (solventAdded != 100.000m)
                {
                    Module.HandleStrike();
                    DebugLog("Tried to add " + selectedCompound.GetLogString() + " before adding exactly 100ml of the correct solvent (added solvent amount is " +
                             solventAdded + chosenReaction.Solvent.GetUnit() + "). Strike.");
                }
                else if (!chosenReaction.Reagents.Contains(selectedCompound))     //if added compound isn't part of this reaction: strike
                {
                    Module.HandleStrike();
                    DebugLog("Tried to add " + selectedCompound.GetLogString() + ", which is not part of the reaction. Strike.");
                }
                else if (addedCompounds.Contains(selectedCompound))     //if compound was already added before: just increase added amount
                {
                    addedAmounts[addedCompounds.IndexOf(selectedCompound)] += userInput;
                    DebugLog("Added " + userInput + selectedCompound.GetUnit() + " of " + selectedCompound.GetLogString() +
                             ". Total amount is now " + addedAmounts[addedCompounds.IndexOf(selectedCompound)] + selectedCompound.GetUnit() + ".");
                }
                else     //add new compound
                {
                    addedCompounds.Add(selectedCompound);
                    addedAmounts.Add(userInput);
                    DebugLog("Added " + userInput + selectedCompound.GetUnit() + " of " + selectedCompound.GetLogString() + ".");
                    if (selectedCompound.DefState == Compound.State.Solid)
                    {
                        visibleContent[visSolidIndex++] = selectedCompound;
                        if (visSolidIndex < 4)
                        {
                            visibleContent[visSolidIndex++] = selectedCompound;
                        }
                    }
                    else if (selectedCompound.DefState == Compound.State.Liquid)
                    {
                        visibleContent[visLiquidIndex++] = selectedCompound;
                        if (visLiquidIndex < 4)
                        {
                            visibleContent[visLiquidIndex++] = selectedCompound;
                        }
                    }
                    UpdateVesselContents();
                }
            }

            userInput = 0;
        }
        else
        {
            amountMode = true;
            TypeGroup.SetActive(false);
            AmountGroup.SetActive(true);
            UpdateAmountDisplay();
        }
    }
Exemplo n.º 5
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("----------------------------------");
    }