/// <summary> /// Checks the light sources equiped by the player and makes sure the brightest one is in use /// </summary> public void UpdateLightSources() { //Check for lights if (lt == null) { lt = this.gameObject.GetComponentInChildren <Light> (); } ls = null; float MaxBrightness = LightSource.MagicBrightness; //Start with magically generated light. for (int i = 5; i <= 8; i++) { ls = null; //Update the gameobject at the slot if needed if (LightGameObjects [i - 5] != null) { if (GetObjectAtSlot(i) != LightGameObjects [i - 5].name) { LightGameObjects [i - 5] = GetGameObjectAtSlot(i); } } else { //No object if (GetObjectAtSlot(i) != "") { LightGameObjects [i - 5] = GetGameObjectAtSlot(i); } } if (GetObjectAtSlot(i) != "") { //GameObject objAtSlot = GetGameObjectAtSlot(i); //GameObject.Find (GetObjectAtSlot(i)); if (LightGameObjects [i - 5] != null) { ls = LightGameObjects [i - 5].GetComponent <LightSource> (); if (ls != null) { if (ls.IsOn() == true) { if (MaxBrightness < ls.Brightness()) { MaxBrightness = ls.Brightness(); } } } } } } lt.range = LightSource.BaseBrightness + MaxBrightness; if (MaxBrightness > 0) { playerUW.LightActive = true; } else { playerUW.LightActive = false; } }