public void ChangeState(EDayState newState) { SetObjectState(m_dawn, EDayState.DAWN, newState); SetObjectState(m_day, EDayState.DAY, newState); SetObjectState(m_dusk, EDayState.DUSK, newState); SetObjectState(m_night, EDayState.NIGHT, newState); }
private void SetObjectState(GameObject p_obj, EDayState p_matchstate, EDayState p_newState) { if (p_obj != null) { p_obj.SetActive(p_matchstate == p_newState); } }
private IEnumerator Fade(EDayState state) { Single rndStartOffset = UnityEngine.Random.value * 1f; yield return(new WaitForSeconds(rndStartOffset)); Single startIntensity = GetIntensity(); Single startRange = light.range; Color startColor = light.color; LightSetting targetSetting = GetTargetSetting(state); UpdateParticles(targetSetting); Single currTime = Time.time - Time.deltaTime; Single endTime = Time.time + 3.1f + UnityEngine.Random.value * 1f - rndStartOffset; WaitForEndOfFrame wait = new WaitForEndOfFrame(); while (currTime < endTime) { currTime += Time.deltaTime; if (currTime > endTime) { currTime = endTime; } Single lerp = (endTime - currTime) / 3.1f; Single nextIntensity = Mathf.Lerp(targetSetting.Intensity, startIntensity, lerp); Single nextRange = Mathf.Lerp(targetSetting.Range, startRange, lerp); Color nextColor = Color.Lerp(targetSetting.Color, startColor, lerp); light.enabled = (nextIntensity > 0f && nextRange > 0f && (nextColor.r > 0f || nextColor.g > 0f || nextColor.b > 0f)); SetIntensity(nextIntensity); light.range = nextRange; light.color = nextColor; yield return(wait); } yield break; }
public override void ChangeState(EDayState newState) { StopAllCoroutines(); if (gameObject.activeInHierarchy) { StartCoroutine(Fade(newState)); } }
private void OnGameTimeChanged(Object p_Sender, EventArgs p_Args) { EDayState dayState = LegacyLogic.Instance.GameTime.DayState; if (dayState != m_state) { m_state = dayState; foreach (DaytimeDependentBase daytimeDependentBase in m_Objects) { if (daytimeDependentBase != null) { daytimeDependentBase.ChangeState(dayState); } } } }
private GameObject GetTargetObject(EDayState state) { switch (state) { case EDayState.DAWN: return(m_dawn); case EDayState.DAY: return(m_day); case EDayState.DUSK: return(m_dusk); default: return(m_night); } }
private LightSetting GetTargetSetting(EDayState state) { switch (state) { case EDayState.DAWN: return(m_dawn); case EDayState.DAY: return(m_day); case EDayState.DUSK: return(m_dusk); default: return(m_night); } }
public override void ChangeState(EDayState newState) { StartCoroutine(UpdateObjects(GetTargetObject(newState))); }
public GameTimeEventArgs(EDayState currentDayState, EDayState lastDayState, ETimeChangeReason reason) { CurrentDayState = currentDayState; LastDayState = lastDayState; Reason = reason; }
private void OnFinishLoadViews(Object p_Sender, EventArgs p_Args) { m_state = (EDayState)(-1); OnGameTimeChanged(null, null); }
public abstract void ChangeState(EDayState newState);
public GameTimeEntryEventArgs(EDayState p_newDayState) { NewDayState = p_newDayState; }