コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (RNZDFL == null)
        {
            RNZDFL = GameObject.FindObjectOfType <ReverNodeZoneDetectorForListener> ();
        }
        if (RNZDFL.playerIsInside)
        {
            filter.enabled = true;
        }
        else
        {
            filter.enabled = false;
        }

        //is the sun visible?
        if (sun.transform.position.y < -3)
        {
            sunBelowHorizon = true;
        }
        else
        {
            sunBelowHorizon = false;
        }

        //is it just before sunrise?
        if (sunBelowHorizon == false && sky.Cycle.Hour < 12 && fajrWasCalled == false)
        {
            CallToPrayer();
            fajrWasCalled = true;
        }

        //is it noon?
        if (sky.Cycle.Hour >= 12 && dhuhrWasCalled == false)
        {
            CallToPrayer();
            fajrWasCalled  = true;
            dhuhrWasCalled = true;
        }

        //is it afternoon?
        if (sky.Cycle.Hour >= 15 && asrWasCalled == false)
        {
            CallToPrayer();
            fajrWasCalled = true;
            asrWasCalled  = true;
        }

        if (sunBelowHorizon == true && maghribWasCalled == false && sky.Cycle.Hour >= 12)
        {
            CallToPrayer();
            fajrWasCalled    = true;
            maghribWasCalled = true;
        }

        if (sky.Cycle.Hour >= 22 && ishaWasCalled == false)
        {
            CallToPrayer();
            fajrWasCalled = true;
            ishaWasCalled = true;
        }

        //reset at midnght
        if (sky.Cycle.Hour < 1)
        {
            fajrWasCalled    = false;
            dhuhrWasCalled   = false;
            asrWasCalled     = false;
            maghribWasCalled = false;
            ishaWasCalled    = false;
        }
        //fade other audio when adhan happens
        if (fadeOutOtherSound)
        {
            for (int i = 0; i < sourcesToMute.Length; i++)
            {
                if (sourcesToMute [i].volume >= 0)
                {
                    sourcesToMute [i].volume -= fadeTime * Time.deltaTime;
                }
                if (sourcesToMute[i].volume <= 0)
                {
                    sourcesToMute [i].Stop();
                    sourcesToMute [i].volume = 1f;
                    fadeOutOtherSound        = false;
                }
            }
        }
    }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     RNZDFL = GameObject.FindObjectOfType <ReverNodeZoneDetectorForListener> ();
 }