コード例 #1
0
    // Make light look like its faulty
    void Update()
    {
        if (!spawnRoomDoor.IsDoorOpen())
        {
            if (timePassed == 0f)
            {
                faultStart  = Random.Range(3f, 9f);
                faultLength = Random.Range(0.5f, 4f);
                timePassed  = Time.timeSinceLevelLoad;
            }

            // Fault effect begins after 3-9 sec
            if (Time.timeSinceLevelLoad - timePassed > faultStart)
            {
                FaultyEffect();
            }

            // Fault effect done after 0.5-4 sec
            if ((Time.timeSinceLevelLoad - timePassed > faultStart + faultLength))
            {
                NormalEffect();
            }
        }
        else if (lampSound.isPlaying)
        {
            lampSound.Stop();
        }
    }
コード例 #2
0
 void OnTriggerStay(Collider collider)
 {
     if (collider.tag == "Player" && (!door.HasTriedToOpen() || electroPanel.IsPowerDown()) && !door.IsDoorOpen() && !electroPanel.IsPlayingAudio() && !door.IsActive())
     {
         isColliding        = true;
         playerMessage.text = "F - Open Door";
     }
     else if ((door.HasTriedToOpen() && !electroPanel.IsPowerDown()) || door.IsDoorOpen() || electroPanel.IsPlayingAudio() || door.IsActive())
     {
         playerMessage.text = "";
     }
 }