private void EmitParticles() { var enumerator = emitterDict.GetEnumerator(); while (enumerator.MoveNext()) { //foreach (KeyValuePair<string, ParticleSystem> item in emitterDict) { item = enumerator.Current; atmoSetting = GetAtmoParticleSetting(item.Key); // Reposition Emitter to playerPosition + ParticleOffset item.Value.transform.position = Player.Local.Position + atmoSetting.Offset; if (HasParticlesToEmit(item.Value, atmoSetting)) { // Prevent a wall of particles to appear by adjusting the "maxEmission" // on the ParticleSystem, Note: maxEmission is per second item.Value.emissionRate = atmoSetting.MaxParticles * atmoSetting.Density; item.Value.enableEmission = true; //update the color of the particles based on the time of day item.Value.startColor = Color.Lerp(Colors.Alpha(RenderSettings.fogColor, atmoSetting.BaseColor.a), atmoSetting.BaseColor, 0.65f); } else { item.Value.enableEmission = false; } } }
protected IEnumerator FadeOutOverTime() { mFadingOut = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mFadingOut = false; }); //once the fade out leading into the fade in is ready //start the actual fade in while (mFadingOut) { yield return(null); } //wait for us to arrive at our destination, or for us to cancel Frontiers.GUI.CameraFade.HoldAlphaFade(Colors.Alpha(Color.black, 1f)); while (State == FastTravelState.Traveling) { yield return(null); } //set this to false now so we can doulbe-up on fades mFadingOutOverTime = false; mFadingIn = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), true, 0.5f, 0f, () => { mFadingIn = false; }); while (mFadingIn) { yield return(null); } }
public override void OnLocalPlayerDespawn() { GetAmbientAudioSettings(); AmbientAudio.ChunkSettings = CurrentAudioSettings; AmbientAudio.UpdateStackVolumes(Colors.Alpha(Color.black, 0f)); AmbientAudio.ClearAudio(); MasterAmbientVolume = 0f; }
public void FixedUpdate() { mTargetColor.a = 1f * Profile.Get.CurrentPreferences.Immersion.PathGlowIntensity; mCurrentColor = Color.Lerp(mCurrentColor, mTargetColor, Time.fixedDeltaTime); if (!Paths.HasActivePath) { return; } switch (TravelManager.Get.State) { case FastTravelState.None: //only check this when we're not fast-traveling if (PlayerDistanceFromPath > Globals.PathStrayDistanceInMeters) { if (mTimeAwayFromPath > Globals.PathStrayMinTimeInSeconds) { if (mTimeAwayFromPath > Globals.PathStrayMaxTimeInSeconds) { GUIManager.PostWarning("Stopped following path"); Paths.ClearActivePath(); mTimeAwayFromPath = 0.0f; return; } } mTimeAwayFromPath += WorldClock.ARTDeltaTime; } else { mTimeAwayFromPath = 0.0f; } //see what color we're supposed to be every few seconds if (Paths.IsEvaluating) { mTargetColor = Color.Lerp(Colors.Get.PathEvaluatingColor1, Colors.Get.PathEvaluatingColor2, Mathf.Abs(Mathf.Sin((float)(WorldClock.RealTime * 2)))); } else if (mCheckPathColor > 5) { mCheckPathColor = 0; //TODO update this later //float meters = Paths.ParamToMeters(Follower.param, Paths.ActivePath.spline.Length);// Paths.ActivePath.MetersFromPosition(Follower.transform.position); mTargetColor = Colors.GetColorFromWorldPathDifficulty(Paths.ActivePath.SegmentFromMeters(0f).Difficulty); } else { mCheckPathColor++; } break; case FastTravelState.WaitingForNextChoice: mTargetColor = Colors.Alpha(mTargetColor, 0f); break; default: break; } }
public void Update() { if (GameManager.Is(FGameState.Cutscene | FGameState.GameLoading)) { mLerpThisFrame = 1f; mUpdateLights = 10; mUpdateMaterials = 30; } mUpdateLights++; if (mUpdateLights > 10) { mUpdateLights = 0; for (int i = WorldLights.LastIndex(); i >= 0; i--) { WorldLight wl = WorldLights [i]; if (wl == null) { WorldLights.RemoveAt(i); } else { wl.UpdateBrightness(); } } } mUpdateMaterials++; if (mUpdateMaterials > 5) { mUpdateMaterials = 0; bool lightsOn = WorldClock.IsNight || !Player.Local.Surroundings.IsOutside || GameWorld.Get.CurrentBiome.OuterSpace; if (lightsOn) { mTargetEmissionBrightness = 1f; } else { mTargetEmissionBrightness = 0f; } mEmissionBrightness = Mathf.Lerp(mEmissionBrightness, mTargetEmissionBrightness, 0.35f); for (int i = 0; i < Mats.Get.TimedGlowMaterials.Count; i++) { Material mat = Mats.Get.TimedGlowMaterials [i]; mat.SetColor("_EmiTint", Colors.Alpha(mat.GetColor("_EmiTint"), mEmissionBrightness)); } } }
public void UpdateLabel(float scale, float labelScale, float maxDistance, float minScale, float maxScale, float alpha, Camera perspectiveCamera, Camera interfaceCamera) { Vector3 pos = perspectiveCamera.WorldToViewportPoint(LocationTransform.position); float distanceFromCamera = 0f; // Determine the visibility and the target alpha bool isVisible = (pos.z > 0f && pos.x > 0f && pos.x <1f && pos.y> 0f && pos.y < 1f); // If visible, update the position if (isVisible) { if (LabelTransform != null) { LabelTransform.position = interfaceCamera.ViewportToWorldPoint(pos); pos = LabelTransform.localPosition; } else if (IconTransform != null) { IconTransform.position = interfaceCamera.ViewportToWorldPoint(pos); pos = IconTransform.localPosition; } pos.x = Mathf.RoundToInt(pos.x); pos.y = Mathf.RoundToInt(pos.y); float fadeStart = maxDistance * 0.75f; distanceFromCamera = Vector3.Distance(perspectiveCamera.transform.position, LocationTransform.position); pos.z = -distanceFromCamera; scale = Mathf.Clamp(scale / distanceFromCamera, minScale, maxScale); if (distanceFromCamera > maxDistance) { isVisible = false; alpha = 0f; } else if (distanceFromCamera >= fadeStart) { float fadeAmount = (distanceFromCamera - fadeStart) / (maxDistance - fadeStart); alpha = Mathf.Lerp(alpha, 0f, fadeAmount); } } if (!isVisible) { //Debug.Log(Name + " was not visible: " + pos.ToString()); if (Label != null) { Label.enabled = false; } if (Icon != null) { Icon.enabled = false; } if (Attention != null) { Attention.enabled = false; } if (Collider != null) { Collider.enabled = false; } return; } else { if (LabelTransform != null) { LabelTransform.localPosition = pos; Label.enabled = true; Label.depth = Mathf.FloorToInt(-distanceFromCamera * 1000); } if (IconTransform != null) { IconTransform.localPosition = pos; Icon.enabled = true; Icon.depth = Mathf.FloorToInt(-distanceFromCamera * 1000); } if (AttentionTransform != null) { AttentionTransform.localPosition = pos; Attention.enabled = true; Attention.depth = Mathf.FloorToInt(-distanceFromCamera * 1000); } if (Collider != null) { Collider.enabled = true; } } bool mouseOver = Icon != null && (UICamera.hoveredObject == Icon.gameObject); if (Label != null) { Label.color = Colors.Alpha(LabelColor, Label.alpha); if (Display) { if (SearchHit) { Label.alpha = Mathf.Lerp(Label.alpha, alpha, 0.25f); } else { switch (LabelStyle) { case MapLabelStyle.MouseOver: if (mouseOver || IsMarked) { Label.alpha = Mathf.Lerp(Label.alpha, alpha, 0.25f); } else { Label.alpha = Mathf.Lerp(Label.alpha, 0f, 0.25f); } break; case MapLabelStyle.Descriptive: //fade out descriptive labels when we get clsoe if (distanceFromCamera < (maxDistance / 5)) { alpha = 0f; } Label.alpha = Mathf.Lerp(Label.alpha, alpha, 0.25f); break; case MapLabelStyle.AlwaysVisible: if (mouseOver || IsMarked) { Label.alpha = Mathf.Lerp(Label.alpha, alpha, 0.25f); } else { Label.alpha = Mathf.Lerp(Label.alpha, alpha, 0.25f); } break; default: Label.alpha = Mathf.Lerp(Label.alpha, alpha, 0.25f); break; } } } else { Label.alpha = Mathf.Lerp(Label.alpha, 0f, 0.25f); } LabelTransform.localScale = ((LabelScale * labelScale) * scale) * Vector3.one; //LabelTransform.position = pos; } if (Icon != null) { if (Display) { if (IsMarked) { Icon.color = Attention.color; } else { Icon.color = Colors.Alpha(IconColor, alpha); } Icon.alpha = Mathf.Lerp(Icon.alpha, alpha, 0.25f); IconTransform.localScale = (IconScale * scale) * Vector3.one; } else { Icon.alpha = Mathf.Lerp(Icon.alpha, 0f, 0.25f); } } if (Attention != null) { if (Display) { if (IsMarked || IsNew) { Attention.alpha = Mathf.Lerp(Attention.alpha, alpha, 0.25f); } else { Attention.alpha = Mathf.Lerp(Attention.alpha, 0f, 0.25f); } } else { Attention.alpha = Mathf.Lerp(Attention.alpha, 0f, 0.25f); } AttentionTransform.localScale = IconTransform.localScale; } }
public void UpdateAmbientState() { if (!GameManager.Is(FGameState.InGame | FGameState.Cutscene) || !GameWorld.Get.WorldLoaded) { return; } if (!Player.Local.HasSpawned) { AmbientAudioManager.TerrainTypeVolume = 0.001f; mCurrentTerrainType = Colors.Alpha(Color.black, 0f); if (!Mathf.Approximately(mCurrentTerrainType.a, mLastTerrainType.a) || !Mathf.Approximately(mCurrentTerrainType.r, mLastTerrainType.r) || !Mathf.Approximately(mCurrentTerrainType.g, mLastTerrainType.g) || !Mathf.Approximately(mCurrentTerrainType.b, mLastTerrainType.b)) { AmbientAudio.UpdateStackVolumes(mCurrentTerrainType); mLastTerrainType = mCurrentTerrainType; } return; } if (GameManager.Is(FGameState.Cutscene)) { mCurrentTerrainType = Cutscene.CurrentCutscene.TerrainColor; AmbientAudio.WindIntensity = Cutscene.CurrentCutscene.WindIntensity; AmbientAudio.ThunderIntensity = Cutscene.CurrentCutscene.ThunderIntensity; AmbientAudio.RainIntensity = Cutscene.CurrentCutscene.RainIntensity; AmbientAudioManager.TerrainTypeVolume = 1f; } else { if (Player.Local.Status.IsStateActive("Airborne") || Player.Local.Status.IsStateActive("Traveling")) { AmbientAudioManager.TerrainTypeVolume = 0.001f; AmbientAudio.WindIntensity = 1.0f; } else { AmbientAudioManager.TerrainTypeVolume = 1.0f; AmbientAudio.WindIntensity = Biomes.Get.WindIntensity; } GetAmbientAudioSettings(); if (Player.Local.Surroundings.IsUnderground) { AmbientAudio.ThunderIntensity = 0f; AmbientAudio.RainIntensity = 0f; } else { AmbientAudio.ThunderIntensity = Biomes.Get.ThunderIntensity; AmbientAudio.RainIntensity = Biomes.Get.RainIntensity; } mCurrentTerrainType = Player.Local.Surroundings.TerrainType; } if (!Mathf.Approximately(mCurrentTerrainType.a, mLastTerrainType.a) || !Mathf.Approximately(mCurrentTerrainType.r, mLastTerrainType.r) || !Mathf.Approximately(mCurrentTerrainType.g, mLastTerrainType.g) || !Mathf.Approximately(mCurrentTerrainType.b, mLastTerrainType.b)) { AmbientAudio.UpdateStackVolumes(mCurrentTerrainType); mLastTerrainType = mCurrentTerrainType; } }
public void RefreshSettings(bool resetInterface) { //cutscene interfaces are handled on the fly by the interfaces themselves //since they're created / destroyed on the fly #if UNITY_EDITOR if (VRMode | VRTestingMode) { #else if (VRMode) { #endif try { if (TargetRenderTexture == null) { TargetRenderTexture = RenderTexture.GetTemporary(2048, 1024, 24); //, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default, 2); VRManager.Get.RenderQuad.sharedMaterial.mainTexture = TargetRenderTexture; } Debug.Log("Oculus mode enabled, refreshing settings - reset interface? " + resetInterface.ToString()); //first set the NGUI atlases to use the correct materials Mats.Get.SetNGUIOculusShaders(true); GUIManager.Get.PrimaryCamera.targetTexture = TargetRenderTexture; GUIManager.Get.PrimaryCamera.clearFlags = CameraClearFlags.SolidColor; GUIManager.Get.PrimaryCamera.backgroundColor = Colors.Alpha(Color.black, 0f); GUIManager.Get.SecondaryCamera.targetTexture = TargetRenderTexture; GUIManager.Get.SecondaryCamera.clearFlags = CameraClearFlags.Depth; GUIManager.Get.BaseCamera.targetTexture = TargetRenderTexture; GUIManager.Get.BaseCamera.clearFlags = CameraClearFlags.Depth; GUIManager.Get.HudCamera.targetTexture = TargetRenderTexture; GUIManager.Get.HudCamera.clearFlags = CameraClearFlags.Depth; GUILoading.Get.LoadingCamera.targetTexture = TargetRenderTexture; GUILoading.Get.LoadingCamera.clearFlags = CameraClearFlags.SolidColor; NGUIWorldMap.Get.MapBackgroundCamera.targetTexture = TargetRenderTexture; NGUIWorldMap.Get.MapBackgroundCamera.clearFlags = CameraClearFlags.Depth; CameraFX.Get.RefreshOculusMode(); } catch (Exception e) { Debug.Log("Error setting rift mode, proceeding normally: " + e.ToString()); } //TODO UNITY 5 /*if (!OvrManager.enabled) { * Debug.Log ("Setting ovr manager & ovr camera rig to enabled"); * OvrManager.enabled = true; * } * if (!OvrCameraRig.enabled) { * OvrCameraRig.enabled = true; * }*/ InterfaceActionManager.SoftwareMouse = true; if (!gDirectToRiftMode && Profile.Get.HasCurrentProfile) { Debug.Log("Setting oculus mode to true in preferences"); Profile.Get.CurrentPreferences.Video.OculusMode = true; } if (resetInterface) { AxisLock = true; CursorLock = true; if (Player.Local != null && Player.Local.Initialized) { ResetCameraOrientation(Player.Local.FPSCameraSeat.eulerAngles.y); } else { ResetCameraOrientation(0f); } ResetInterfacePosition(); } } else { Debug.Log("Oculus mode disabled, refreshing settings"); if (GameManager.Is(FGameState.InGame)) { Player.Local.FPSCameraSeat.localRotation = Quaternion.identity; GameManager.Get.GameCamera.transform.localRotation = Quaternion.identity; DirectionTransform.ResetLocal(); } RenderQuad.enabled = false; LockedRenderQuad.enabled = false; LockedCursorSprite.enabled = false; try { Mats.Get.SetNGUIOculusShaders(false); GUIManager.Get.PrimaryCamera.targetTexture = null; GUIManager.Get.PrimaryCamera.clearFlags = CameraClearFlags.Depth; GUIManager.Get.SecondaryCamera.targetTexture = null; GUIManager.Get.SecondaryCamera.clearFlags = CameraClearFlags.Depth; GUIManager.Get.BaseCamera.targetTexture = null; GUIManager.Get.BaseCamera.clearFlags = CameraClearFlags.Depth; GUIManager.Get.HudCamera.targetTexture = null; GUIManager.Get.HudCamera.clearFlags = CameraClearFlags.Depth; GUILoading.Get.LoadingCamera.targetTexture = null; GUILoading.Get.LoadingCamera.clearFlags = CameraClearFlags.Depth; NGUIWorldMap.Get.MapBackgroundCamera.targetTexture = null; NGUIWorldMap.Get.MapBackgroundCamera.clearFlags = CameraClearFlags.Depth; CameraFX.Get.RefreshOculusMode(); if (TargetRenderTexture != null) { RenderTexture.ReleaseTemporary(TargetRenderTexture); } } catch (Exception e) { Debug.Log("Error setting rift mode, proceeding normally: " + e.ToString()); } //TODO UNITY 5 /*if (OvrManager.enabled) { * Debug.Log ("Setting ovr manager & ovr camera rig to disabled"); * OvrManager.enabled = false; * } * if (OvrCameraRig.enabled) { * OvrCameraRig.enabled = false; * }*/ InterfaceActionManager.SoftwareMouse = false; if (Profile.Get.HasCurrentProfile) { Profile.Get.CurrentPreferences.Video.OculusMode = false; } } }
protected void BuildDescription() { StringBuilder sb = new StringBuilder(); Color currentColor = Colors.Alpha(Colors.BlendThree(LowColorValue, MidColorValue, HighColorValue, NormalizedValue), 1f); //static description sb.Append(Colors.ColorWrap(Name, KeeperColor)); sb.Append(Colors.ColorWrap(": ", KeeperColor)); sb.Append(Colors.ColorWrap(Description.Trim(), KeeperColor)); sb.Append("\n_\n"); //current value description bool overFlow = false; bool underFlow = false; if (mValueWithFlow > 1) { overFlow = true; sb.Append(Colors.ColorWrap(ValueDescriptionGreaterThanFull.Trim(), currentColor)); } else if (mValueWithFlow > 0.95) { sb.Append(Colors.ColorWrap(ValueDescriptionFull.Trim(), currentColor)); } else if (mValueWithFlow > 0.8) { sb.Append(Colors.ColorWrap(ValueDescriptionFourFifths.Trim(), currentColor)); } else if (mValueWithFlow > 0.6) { sb.Append(Colors.ColorWrap(ValueDescriptionThreeFifths.Trim(), currentColor)); } else if (mValueWithFlow > 0.4) { sb.Append(Colors.ColorWrap(ValueDescriptionTwoFifths.Trim(), currentColor)); } else if (mValueWithFlow > 0.2) { sb.Append(Colors.ColorWrap(ValueDescriptionOneFifth.Trim(), currentColor)); } else if (mValueWithFlow > 0.01) { sb.Append(Colors.ColorWrap(ValueDescriptionEmpty.Trim(), currentColor)); } else { underFlow = true; sb.Append(Colors.ColorWrap(ValueDescriptionLessThanEmpty, currentColor)); } //flows - how this affects other keepers //and how we are affected by other keepers if (overFlow && !string.IsNullOrEmpty(mActiveState.Overflow.TargetName) && mActiveState.Overflow.HasEffect && !string.IsNullOrEmpty(mActiveState.Overflow.Description.Trim())) { sb.Append("\n"); sb.Append(Colors.ColorWrap(mActiveState.Overflow.Description.Trim(), HighColorValue)); } else if (underFlow && !string.IsNullOrEmpty(mActiveState.Underflow.TargetName) && mActiveState.Underflow.HasEffect && !string.IsNullOrEmpty(mActiveState.Underflow.Description.Trim())) { sb.Append("\n"); sb.Append(Colors.ColorWrap(mActiveState.Underflow.Description.Trim(), LowColorValue)); } if (StatusFlows.Count > 0) { sb.Append("\n"); for (int i = 0; i < StatusFlows.Count; i++) { StatusFlow sf = StatusFlows [i]; if (sf.HasEffect && !string.IsNullOrEmpty(sf.Description.Trim())) { if (sf.FlowType == StatusSeekType.Negative) { sb.Append(Colors.ColorWrap(sf.Description.Trim(), LowColorValue)); } else { sb.Append(Colors.ColorWrap(sf.Description.Trim(), HighColorValue)); } } } } //current state description if (!string.IsNullOrEmpty(mActiveState.StateDescription)) { sb.Append("\n_\n"); sb.Append(mActiveState.StateDescription.Trim()); } mCurrentDescription = sb.ToString(); sb.Clear(); sb = null; }
public void Update() { if (!GameManager.Is(FGameState.InGame)) { return; } PathFollowSpeed = 0.125f; DistanceBetweenNodes = 2.0f; WaveAmount = 0.25f; TimeModifier = 1.0f; int startIndex = 0; if (Player.Local.State.IsHijacked) { PathFollowSpeed = 1.0f; DistanceBetweenNodes = 4.0f; WaveAmount = 0.05f; } transform.position = Player.Local.FPSCameraSeat.position + Player.Local.FPSCameraSeat.forward; if (!Paths.HasActivePath || !Paths.ActivePath.HasCachedSplinePositions) { mTargetColor = Colors.Alpha(Colors.GetColorFromWorldPathDifficulty(PathDifficulty.Easy), 0f); mTotalLength = -1f; } else if (Paths.HasActivePath) { mCachedSplinePositions.Clear(); if (mTotalLength < 0) { mTargetColor = Colors.Alpha(Colors.GetColorFromWorldPathDifficulty(PathDifficulty.Easy), 0f); mTotalLength = Paths.ActivePath.LengthInMeters; } PlayerDistanceFromPath = Vector3.Distance(Paths.Get.ActivePathFollower.tr.position, Player.Local.FPSCameraSeat.position) * Globals.InGameUnitsToMeters; mGroundPathSmoothTarget = Mathf.Lerp(mGroundPathSmoothTarget, Paths.Get.ActivePathFollower.param, PathFollowSpeed); mGroundActivePathSmoothTarget = Mathf.Lerp(mGroundActivePathSmoothTarget, Paths.Get.ActivePathFollower.param, PathFollowSpeed); mNormalizedTargetLength = (Globals.GroundPathFollowerNodes * DistanceBetweenNodes) / mTotalLength; mNormalizedExtent = (mNormalizedTargetLength / 2.0f); mNormalizedMidPoint = mGroundActivePathSmoothTarget; //mNormalizedStartPoint = Mathf.Clamp01(mNormalizedMidPoint - mNormalizedExtent); //mNormalizedEndPoint = mNormalizedMidPoint + mNormalizedExtent; //mNormalizedDistanceBetweenNodes = DistanceBetweenNodes / mTotalLength; mNormalizedDistance = mNormalizedStartPoint; Paths.ActivePath.GetCachedSplinePositions(mCachedSplinePositions, mNormalizedMidPoint, NumParticles, out mPathStartPosition, out startIndex); } int randomPositionIndex = (startIndex + Mathf.CeilToInt(Time.time * RandomPositionSpeed)) % RandomPositions.Length; int randomOpacityIndex = (startIndex + Mathf.CeilToInt(Time.time * RandomPositionSpeed / 2)) % RandomOpacity.Length; //float currentOffset = mNormalizedMidPoint - mNormalizedExtent; float distanceFromCenter = 0f; float distanceFromPath = Mathf.Clamp01(Paths.NormalizedDistanceFromPath - 0.2f); int midPoint = NumParticles / 2; mClearColor = Colors.Alpha(mCurrentColor, 0f); for (int i = 0; i < NumParticles; i++) { if (i < midPoint) { randomPositionIndex = (randomPositionIndex + 1) % RandomPositions.Length; randomOpacityIndex = (randomOpacityIndex + 1) % RandomOpacity.Length; distanceFromCenter = 1f - ((float)i / midPoint); } else { randomPositionIndex = randomPositionIndex > 0 ? randomPositionIndex - 1 : RandomPositions.Length - 1; randomOpacityIndex = randomOpacityIndex > 0 ? randomOpacityIndex - 1 : RandomOpacity.Length - 1; distanceFromCenter = ((float)(i - midPoint) / midPoint); } ParticleSystem.Particle p = particles[i]; p.rotation = Time.time + i * RotationSpeed; p.color = Color.Lerp(Color.Lerp(RandomColors [randomOpacityIndex], mCurrentColor, 0.75f), mClearColor, (distanceFromCenter /*/ RandomOpacity [randomOpacityIndex]*/ * mTargetColor.a)); if (i < mCachedSplinePositions.Count) { p.position = mCachedSplinePositions[i] + PositionAboveGround + ((RandomPositions[randomPositionIndex] * RandomPositionScale)); p.size = Mathf.Lerp(BasePathSize, 0f, distanceFromPath) * RandomOpacity [randomOpacityIndex]; particles[i] = p; } particles[i] = p; } ParticlePath.SetParticles(particles, NumParticles); }
public void PushInterfaceColors(IEnumerable <ColorKey> interfaceColors) { if (interfaceColors == null) { return; } Type type = typeof(Colors); foreach (ColorKey key in interfaceColors) { FieldInfo field = type.GetField(key.Name); if (field != null && field.FieldType == typeof(Color)) { field.SetValue(this, key.color); } else { Debug.Log("Couldn't set field " + key.Name + ", was null or not type of color"); } } //get all label and button setup components //set them all to the new colors UILabel[] labels = GameObject.FindObjectsOfType <UILabel>(); UITiledSprite[] bgSprites = GameObject.FindObjectsOfType <UITiledSprite>(); UISlicedSprite[] borderSprites = GameObject.FindObjectsOfType <UISlicedSprite>(); GUI.GUIButtonSetup[] buttonSetup = GameObject.FindObjectsOfType <GUI.GUIButtonSetup>(); GUI.GUISliderSetColors[] sliderColors = GameObject.FindObjectsOfType <GUI.GUISliderSetColors>(); GUI.GUIPopupSetup[] popupSetup = GameObject.FindObjectsOfType <GUI.GUIPopupSetup>(); for (int i = 0; i < labels.Length; i++) { if (labels[i].useDefaultLabelColor) { labels[i].color = Colors.Alpha(MenuButtonTextColorDefault, labels[i].alpha); } } for (int i = 0; i < bgSprites.Length; i++) { if (bgSprites[i].useDefaultBackgroundColor) { bgSprites[i].color = Colors.Alpha(TiledBackgroundColorDefault, bgSprites[i].alpha); } } for (int i = 0; i < borderSprites.Length; i++) { if (borderSprites[i].useDefaultBorderSpriteColor) { borderSprites[i].color = Colors.Alpha(WindowBorderColorDefault, borderSprites[i].alpha); } } for (int i = 0; i < buttonSetup.Length; i++) { buttonSetup[i].RefreshColors(); } for (int i = 0; i < sliderColors.Length; i++) { sliderColors[i].RefreshColors(); } for (int i = 0; i < popupSetup.Length; i++) { popupSetup[i].RefreshColors(); } }
public IEnumerator UpdateCutscene() { mUpdatingCutscene = true; while (StartSuspended) { yield return(null); } Manager.CutsceneStart(); if (FadeIn | VRMode) { //we have to fade in for vr mode or we'll get sick Frontiers.GUI.CameraFade.StartAlphaFade(FadeOutColor, true, FadeInDuration); } bool fadeTitleCard = !string.IsNullOrEmpty(TitleCard); if (fadeTitleCard) { StartCoroutine(DisplayTitleCard(TitleCard, FadeInDuration, 1.0f, FadeOutDuration)); } if (!string.IsNullOrEmpty(CameraAnimationStarting)) { CameraSeat.GetComponent <Animation>().Play(CameraAnimationStarting, AnimationPlayMode.Stop); } if (!string.IsNullOrEmpty(LookTargetAnimationStarting)) { CameraLookTarget.GetComponent <Animation>().Play(LookTargetAnimationStarting, AnimationPlayMode.Stop); } //get the camera animatinon started before hijacking Player.Local.HijackControl(); RefreshCamera(); Player.Local.SnapToHijackedPosition(); yield return(null); State = CutsceneState.Starting; Interfaces.BroadcastMessage("OnCutsceneStart", SendMessageOptions.DontRequireReceiver); Props.BroadcastMessage("OnCutsceneStart", SendMessageOptions.DontRequireReceiver); double startTime = WorldClock.RealTime; float startDuration = 0.01f; //if we're in vr mode and we have a specified hold period, use that for timing if (VRMode) { //this will end up waiting for zero seconds if there's no intro stuff set, which is fine if (HoldStaticCameraStart >= 0) { startTime += HoldStaticCameraStart; } else if (!string.IsNullOrEmpty(CameraAnimationStarting)) { startTime += CameraSeat.GetComponent <Animation>()[CameraAnimationStarting].length; } } else { //otherwise just use the camera animation if (!string.IsNullOrEmpty(CameraAnimationStarting)) { startTime += CameraSeat.GetComponent <Animation>()[CameraAnimationStarting].length; } } while (WorldClock.RealTime < (startTime + startDuration)) { yield return(null); } State = CutsceneState.Idling; if (VRMode && StaticCameraSeatStart != StaticCameraSeatIdle) { //we have to fade out/in before switching to a new static camera mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } } RefreshCamera(); Interfaces.BroadcastMessage("OnCutsceneIdleStart", SendMessageOptions.DontRequireReceiver); Props.BroadcastMessage("OnCutsceneIdleStart", SendMessageOptions.DontRequireReceiver); if (!FinishAutomatically) { while (State == CutsceneState.Idling) { yield return(null); } } Interfaces.BroadcastMessage("OnCutsceneIdleEnd", SendMessageOptions.DontRequireReceiver); Props.BroadcastMessage("OnCutsceneIdleEnd", SendMessageOptions.DontRequireReceiver); State = CutsceneState.Finishing; if (VRMode && StaticCameraSeatIdle != StaticCameraSeatEnd) { //we have to fade out/in before switching to a new static camera mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } mWaitingForStaticFade = true; Frontiers.GUI.CameraFade.StartAlphaFade(Colors.Alpha(Color.black, 1f), false, 0.5f, 0f, () => { mWaitingForStaticFade = false; }); while (mWaitingForStaticFade) { yield return(null); } } RefreshCamera(); //if we're in vr mode and we have a specified hold period, use that for timing double endStartTime = WorldClock.RealTime; float endDuration = 0.01f; if (VRMode) { if (HoldStaticCameraStart >= 0) { endDuration = HoldStaticCameraEnd; } else if (!string.IsNullOrEmpty(CameraAnimationFinishing)) { endDuration = CameraSeat.GetComponent <Animation>()[CameraAnimationFinishing].length; } //in vr mode we need at least 1 second to fade out endDuration = Mathf.Max(1f, endDuration); } else { //otherwise just use the camera animation if (!string.IsNullOrEmpty(CameraAnimationFinishing)) { endDuration = CameraSeat.GetComponent <Animation>()[CameraAnimationFinishing].length; } } //see if we need to start fading out before the animation is done double fadeOutStartTime = -1f; bool shouldFade = false; if (FadeOut | VRMode) { //we HAVE to fade out for vr mode or we'll get sick shouldFade = true; FadeOutDuration = Mathf.Min(FadeOutDuration, endDuration); fadeOutStartTime = endStartTime + endDuration - FadeOutDuration; } while (WorldClock.RealTime < (endStartTime + endDuration)) { //see if we're supposed to start fading if (shouldFade && WorldClock.RealTime > fadeOutStartTime) { Debug.Log("Starting fade out"); shouldFade = false; Frontiers.GUI.CameraFade.StartAlphaFade(FadeOutColor, false, FadeOutDuration); } yield return(null); } if (!VRMode && !string.IsNullOrEmpty(CameraAnimationFinishing)) { while (CameraSeat.GetComponent <Animation>()[CameraAnimationFinishing].normalizedTime < 1f) { yield return(null); } } State = CutsceneState.Finished; OnFinished(); yield break; }