Пример #1
0
    private IEnumerator BurnEthanolCoroutine()
    {
        m_fireRenderer.gameObject.SetActive(true);
        m_burning = true;

        float timeToBurn  = m_compound.ElementQuantity(Compound.Elements.Ethanol) / m_fullVolume * 10;
        float currentTime = 0;

        AudioClip baseClip = m_audioSource.clip;

        m_audioSource.clip    = SimulationData.fireLoop;
        m_audioSource.pitch   = 1;
        m_audioSource.volume /= 2;

        while (currentTime < timeToBurn)
        {
            m_fireRenderer.material.SetFloat(m_hashFluwidHeight, m_renderer.material.GetFloat(m_hashFluwidHeight));

            m_compound -= new Compound(Compound.Elements.Ethanol, m_compound.ElementQuantity(Compound.Elements.Ethanol) / timeToBurn * Time.deltaTime);
            yield return(new WaitForEndOfFrame());

            currentTime += Time.deltaTime;
        }

        m_compound -= new Compound(Compound.Elements.Ethanol, m_compound.ElementQuantity(Compound.Elements.Ethanol));
        m_fireRenderer.gameObject.SetActive(false);

        m_audioSource.volume *= 2;
        m_audioSource.clip    = baseClip;

        m_burning = false;
    }
Пример #2
0
    private bool CheckFluwidsQuantities(out FailCondition failCondition)
    {
        failCondition = new FailCondition(FailCondition.FailType.NoMoreReagents);

        if (m_mercuryThiocyanateStack.stackSize > 0.1f)
        {
            return(false);
        }

        float reagentsQuantity = 0;

        float hydrogenNitrate = 0;
        float mercury         = 0;
        float mercuryNitrate  = 0;
        float potassium       = 0;

        foreach (SmartFluwid fluwidManager in m_allFluwidManagers)
        {
            if (fluwidManager.stackSize > 0.1f)
            {
                return(false);
            }

            Compound compound = fluwidManager.compound;

            hydrogenNitrate += compound.ElementQuantity(Compound.Elements.HydrogenNitrate);
            mercury         += compound.ElementQuantity(Compound.Elements.ElementalMercury) * 50;
            mercuryNitrate  += compound.ElementQuantity(Compound.Elements.MercuryNitrate);
            potassium       += compound.ElementQuantity(Compound.Elements.PotassiumThiocyanate);

            reagentsQuantity += compound.ElementQuantity(Compound.Elements.MercuryThiocyanate);
        }

        float mercuryNitrateDoable     = Mathf.Min(hydrogenNitrate, mercury);
        float mercuryThiocyanateDoable = Mathf.Min(mercuryNitrate + mercuryNitrateDoable, potassium);

        reagentsQuantity += mercuryThiocyanateDoable;


        failCondition.failed = reagentsQuantity <= 0;

        return(failCondition.failed);
    }
Пример #3
0
    private void UpdateCompoundElements()
    {
        float mercuryThiocyanateQuantityBefore = m_compound.ElementQuantity(Compound.Elements.MercuryThiocyanate);

        if (m_heatManager)
        {
            m_heat      = m_heatManager.temperature;
            m_agitation = m_heatManager.agitation;
            m_compound.UpdateCompound(m_heat, m_agitation, Time.deltaTime);
        }
        else
        {
            m_compound.UpdateCompound(0, 0, Time.deltaTime);
        }

        if (m_stack)
        {
            float mercuryThiocyanateQuantityAfter = m_compound.ElementQuantity(Compound.Elements.MercuryThiocyanate);
            UpdateMercuryThiocyanateStack(mercuryThiocyanateQuantityAfter - mercuryThiocyanateQuantityBefore);
        }
    }
Пример #4
0
    private bool ContainsEnoughEthanolToReactToFire()
    {
        if (m_fluwidManager.currentVolume == 0)
        {
            return(false);
        }


        Compound compound = m_fluwidManager.compound;

        float explosiveElementQuantity = 0;

        explosiveElementQuantity += compound.ElementQuantity(Compound.Elements.Ethanol);

        return((explosiveElementQuantity / m_fluwidManager.currentVolume) > 0.5f);
    }