Ejemplo n.º 1
0
        /// <summary>
        /// Obtiene referencia a puerta y se suscribe a cuando sea abierta
        /// </summary>
        public override void OnAwake()
        {
            doorOpen = false;

            GameObject potionReceiverObject = GameObject.Find("PotionReceiver");

            if (!potionReceiverObject)
            {
                Debug.LogError("PotionReceiver no encontrado en la escena");
            }

            potionReceiver = potionReceiverObject.GetComponent <PotionReceiver>();

            if (!potionReceiver)
            {
                Debug.LogError("PotionReceiver no tiene el componente PotionReceiver");
            }

            potionReceiver.OnPotionPoured.AddListener(OnDoorOpen);
        }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (Vector3.Dot(transform.up, Vector3.down) > 0 && fillAmount > 0 && m_PlugIn == false)
        {
            if (particleSystemLiquid.isStopped)
            {
                particleSystemLiquid.Play();
                m_AudioSource.Play();
            }

            fillAmount -= 0.1f * Time.deltaTime;

            float fillRatio = fillAmount / m_StartingFillAmount;

            m_AudioSource.pitch = Mathf.Lerp(1.0f, 1.4f, 1.0f - fillRatio);

            RaycastHit hit;
            if (Physics.Raycast(particleSystemLiquid.transform.position, Vector3.down, out hit, 50.0f, ~0, QueryTriggerInteraction.Collide))
            {
                PotionReceiver receiver = hit.collider.GetComponent <PotionReceiver>();

                if (receiver != null)
                {
                    receiver.ReceivePotion(PotionType);
                }
            }
        }
        else
        {
            particleSystemLiquid.Stop();
            m_AudioSource.Stop();
        }

        MeshRenderer.GetPropertyBlock(m_MaterialPropertyBlock);
        m_MaterialPropertyBlock.SetFloat("LiquidFill", fillAmount);
        MeshRenderer.SetPropertyBlock(m_MaterialPropertyBlock);
    }