Esempio n. 1
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();
        }
    }