void StartVisit() { gameController.player.Stats.AddToStat(PlayerStat.Decay, 1); if (gameController.player.Stats.Decay >= 10) { gameController.player.ChangeState(new PlayerState_Visiting(gameController.player)); return; // Game over, don't start revealing text because it will not look nice } topTextRevealer.ResetRevealer(); middleTextRevealer.ResetRevealer(); bottomTextRevealer.ResetRevealer(); topTextRevealer.text.alpha = 1f; middleTextRevealer.text.alpha = 1f; bottomTextRevealer.text.alpha = 1f; currentTextRevealer = topTextRevealer; gameController.fadeController.StartFadeOut(1f); gameController.fadeController.FadeOutComplete += OnFadeOutComplete; isVisiting = true; isFadingOut = true; gameController.player.ChangeState(new PlayerState_Visiting(gameController.player)); }
void AddInteraction() { for (int i = 0; i < AllObjects.Length; i++) { GameObject mainObject = animalList[i]; //Debug.Log(mainObject.transform.position); //Debug.Log(mainObject); GameObject textObject = Instantiate(textObjectPrefab); // Make a copy of the original text object. textObject.SetActive(true); textObject.transform.SetParent(AllObjects[i].transform); textObject.transform.position = new Vector3(mainObject.transform.position.x, mainObject.transform.position.y + 50, 0); textObject.transform.Rotate(0, 0, 0); Collider barCollider = AllObjects[i].transform.GetComponentInChildren <SphereCollider>(); textRevealer = barCollider.gameObject.AddComponent <TextRevealer>(); // Instantiate (create) a new script and add it to colliders gameobject. //TextObject of "TextRevealer" script equals textObject declared in this script textRevealer.textObject = textObject; textObject.layer = 10; textObject.GetComponent <TextMesh>().characterSize = 5; textObject.GetComponent <TextMesh>().text = animalList[i].name; } }
private void OnFadeOutComplete() { gameController.fadeController.FadeOutComplete -= OnFadeOutComplete; GenerateMessages(); topTextRevealer.RevealText(); currentTextRevealer = topTextRevealer; isFadingOut = false; }
public void OnTopTextFinished() { currentTextRevealer = middleTextRevealer; middleTextRevealer.RevealText(); int statModifier = Random.Range(1, 3); if (gameController.player.Stats.GetStatVal(topTextStatToModify) - statModifier >= 0) { gameController.player.Stats.AddToStat(topTextStatToModify, -1 * statModifier); } }
void AddInteraction() { foreach (Person person in _people) { GameObject mainObject = _mainObjectLookup[person.id]; GameObject textObject = Instantiate(textObjectPrefab); // Make a copy of the original text object. textObject.SetActive(true); textObject.transform.SetParent(mainObject.transform); textObject.transform.localPosition = Vector3.zero; textObject.transform.Rotate(0, 0, -45); textObject.GetComponent <TextMesh>().text = person.firstName; Collider barCollider = mainObject.GetComponentInChildren <SphereCollider>(); TextRevealer textRevealer = barCollider.gameObject.AddComponent <TextRevealer>(); // Instantiate (create) a new script and add it to colliders gameobject. //TextObject of "TextRevealer" script equals textObject declared in this script textRevealer.textObject = textObject; } }
/* * void ColorChange(GameObject currSphere, float minRad, float maxRad, float circRad) * { * circleRadius.Add(circRad); * float normalized = Mathf.InverseLerp(minRad, maxRad, circRad); * lerpedColor = Color.Lerp(Color.yellow, Color.red, normalized); * //Debug.Log(sphereObject.name + " " + normalized); * currSphere.GetComponent<MeshRenderer>().material.color = lerpedColor * 1.1f; * * } */ void AddInteraction() { foreach (Virus virus in _viruses) { GameObject mainObject = _mainObjectLookUp[virus.id]; GameObject textObject = Instantiate(textObjectPrefab); // Make a copy of the original text object. textObject.SetActive(true); textObject.transform.SetParent(mainObject.transform); textObject.transform.localPosition = mainObject.transform.position; textObject.transform.Rotate(0, 0, 0); textObject.GetComponent <TextMesh>().text = virus.name; Collider barCollider = mainObject.GetComponentInChildren <Collider>(); TextRevealer textRevealer = barCollider.gameObject.AddComponent <TextRevealer>(); // Instantiate (create) a new script and add it to colliders gameobject. textRevealer.textObject = textObject; } }
private void OnMiddleTextFinished() { currentTextRevealer = bottomTextRevealer; bottomTextRevealer.RevealText(); }
public override void OnInspectorGUI() { TextRevealer myScript = (TextRevealer)target; myScript.textComponent = (MonoBehaviour)EditorGUILayout.ObjectField(new GUIContent("Target Text"), myScript.textComponent, typeof(MonoBehaviour), true); if (myScript.textComponent != null && (myScript.textComponent is Text || myScript.textComponent is TextMeshProUGUI || myScript.textComponent is TextMeshPro)) { if (textComponent != myScript.textComponent) { myScript.UpdateTextComponent(false); } textComponent = myScript.textComponent; myScript.AutomaticUnreveal = EditorGUILayout.Toggle(new GUIContent("Auto Unreveal"), myScript.AutomaticUnreveal); myScript.RevealOnEnabled = EditorGUILayout.Toggle(new GUIContent("Reveal On Enabled"), myScript.RevealOnEnabled); myScript.UnrevealOnDisabled = EditorGUILayout.Toggle(new GUIContent("Unreveal On Disabled"), myScript.UnrevealOnDisabled); if (myScript.AutomaticUnreveal) { myScript.AutomaticUnrevealAfterSeconds = EditorGUILayout.FloatField(new GUIContent("Unreveal after (seconds)"), myScript.AutomaticUnrevealAfterSeconds); myScript.AutomaticUnrevealAfterSeconds = Math.Max(myScript.AutomaticUnrevealAfterSeconds, 0); } showRevealOptions = EditorGUILayout.Foldout(showRevealOptions, "Reveal Options", true); if (showRevealOptions) { EditorGUILayout.LabelField("Character Options", new GUIStyle() { fontStyle = FontStyle.Bold }); myScript.RevealSmoothOverlap = EditorGUILayout.Toggle(new GUIContent("Smooth Overlap"), myScript.RevealSmoothOverlap); if (myScript.RevealSmoothOverlap) { myScript.RevealSmoothOverlapSmoothness = EditorGUILayout.Slider(new GUIContent("Smooth Overlap Smoothness"), myScript.RevealSmoothOverlapSmoothness, 0.1f, 1f); } myScript.RevealAnimationDirection = (AnimationDirections)EditorGUILayout.EnumPopup(new GUIContent("Animation Direction"), myScript.RevealAnimationDirection); if (myScript.RevealAnimationDirection == AnimationDirections.Both || myScript.RevealAnimationDirection == AnimationDirections.Horizontal) { myScript.RevealAnimationHorizontalDirection = (AnimationHorizontalDirections)EditorGUILayout.EnumPopup(new GUIContent("Horizontal Direction"), myScript.RevealAnimationHorizontalDirection); myScript.revealMinHorizontalDistance = EditorGUILayout.FloatField(new GUIContent("Min Horizontal Starting Distance:"), myScript.revealMinHorizontalDistance); myScript.revealMaxHorizontalDistance = EditorGUILayout.FloatField(new GUIContent("Max Horizontal Starting Distance:"), myScript.revealMaxHorizontalDistance); EditorGUILayout.MinMaxSlider(new GUIContent("Horizontal Starting Distance Range"), ref myScript.revealMinHorizontalDistance, ref myScript.revealMaxHorizontalDistance, 0f, 5000); } if (myScript.RevealAnimationDirection == AnimationDirections.Both || myScript.RevealAnimationDirection == AnimationDirections.Vertical) { myScript.RevealAnimationVerticalDirection = (AnimationVerticalDirections)EditorGUILayout.EnumPopup(new GUIContent("Vertical Direction"), myScript.RevealAnimationVerticalDirection); myScript.revealMinVerticalDistance = EditorGUILayout.FloatField(new GUIContent("Min Vertical Starting Distance:"), myScript.revealMinVerticalDistance); myScript.revealMaxVerticalDistance = EditorGUILayout.FloatField(new GUIContent("Max Vertical Starting Distance:"), myScript.revealMaxVerticalDistance); EditorGUILayout.MinMaxSlider(new GUIContent("Vertical Starting Distance Range"), ref myScript.revealMinVerticalDistance, ref myScript.revealMaxVerticalDistance, 0f, 5000); } EditorGUILayout.LabelField("Text Options", new GUIStyle() { fontStyle = FontStyle.Bold }); myScript.RevealTime = EditorGUILayout.FloatField(new GUIContent("Reveal Duration (Seconds)"), myScript.RevealTime); myScript.RevealLetterOpacityBegin = EditorGUILayout.FloatField(new GUIContent("Initial Opacity"), myScript.RevealLetterOpacityBegin); myScript.RevealLetterOpacityEnd = EditorGUILayout.FloatField(new GUIContent("Final Opacity"), myScript.RevealLetterOpacityEnd); myScript.RevealRandomRotation = EditorGUILayout.Toggle(new GUIContent("Apply Random Rotation"), myScript.RevealRandomRotation); myScript.RevealReverse = EditorGUILayout.Toggle(new GUIContent("Reverse"), myScript.RevealReverse); myScript.RevealTime = Math.Max(myScript.RevealTime, 0f); myScript.RevealLetterOpacityBegin = Math.Min(myScript.RevealLetterOpacityBegin, 1); myScript.RevealLetterOpacityBegin = Math.Max(myScript.RevealLetterOpacityBegin, 0); myScript.RevealLetterOpacityEnd = Math.Min(myScript.RevealLetterOpacityEnd, 1); myScript.RevealLetterOpacityEnd = Math.Max(myScript.RevealLetterOpacityEnd, 0); EditorGUILayout.LabelField("Events", new GUIStyle() { fontStyle = FontStyle.Bold }); EditorGUILayout.PropertyField(serializedObject.FindProperty("OnRevealStarted")); EditorGUILayout.PropertyField(serializedObject.FindProperty("OnRevealCompleted")); } showUnrevealOptions = EditorGUILayout.Foldout(showUnrevealOptions, "Unreveal Options", true); if (showUnrevealOptions) { EditorGUILayout.LabelField("Character Options", new GUIStyle() { fontStyle = FontStyle.Bold }); myScript.UnrevealSmoothOverlap = EditorGUILayout.Toggle(new GUIContent("Smooth Overlap"), myScript.UnrevealSmoothOverlap); if (myScript.UnrevealSmoothOverlap) { myScript.UnrevealSmoothOverlapSmoothness = EditorGUILayout.Slider(new GUIContent("Smooth Overlap Smoothness"), myScript.UnrevealSmoothOverlapSmoothness, 0.1f, 1f); } myScript.UnrevealAnimationDirection = (AnimationDirections)EditorGUILayout.EnumPopup(new GUIContent("Animation Direction"), myScript.UnrevealAnimationDirection); if (myScript.UnrevealAnimationDirection == AnimationDirections.Both || myScript.UnrevealAnimationDirection == AnimationDirections.Horizontal) { myScript.UnrevealAnimationHorizontalDirection = (AnimationHorizontalDirections)EditorGUILayout.EnumPopup(new GUIContent("Horizontal Direction"), myScript.UnrevealAnimationHorizontalDirection); myScript.unrevealMinHorizontalDistance = EditorGUILayout.FloatField(new GUIContent("Min Ending Horizontal Distance:"), myScript.unrevealMinHorizontalDistance); myScript.unrevealMaxHorizontalDistance = EditorGUILayout.FloatField(new GUIContent("Max Ending Horizontal Distance:"), myScript.unrevealMaxHorizontalDistance); EditorGUILayout.MinMaxSlider(new GUIContent("Horizontal Ending Distance Range"), ref myScript.unrevealMinHorizontalDistance, ref myScript.unrevealMaxHorizontalDistance, 0f, 5000); } if (myScript.UnrevealAnimationDirection == AnimationDirections.Both || myScript.UnrevealAnimationDirection == AnimationDirections.Vertical) { myScript.UnrevealAnimationVerticalDirection = (AnimationVerticalDirections)EditorGUILayout.EnumPopup(new GUIContent("Vertical Direction"), myScript.UnrevealAnimationVerticalDirection); myScript.unrevealMinVerticalDistance = EditorGUILayout.FloatField(new GUIContent("Min Ending Vertical Distance:"), myScript.unrevealMinVerticalDistance); myScript.unrevealMaxVerticalDistance = EditorGUILayout.FloatField(new GUIContent("Max Ending Vertical Distance:"), myScript.unrevealMaxVerticalDistance); EditorGUILayout.MinMaxSlider(new GUIContent("Vertical Ending Distance Range"), ref myScript.unrevealMinVerticalDistance, ref myScript.unrevealMaxVerticalDistance, 0f, 5000); } EditorGUILayout.LabelField("Text Options", new GUIStyle() { fontStyle = FontStyle.Bold }); myScript.UnrevealTime = EditorGUILayout.FloatField(new GUIContent("Unreveal Duration (Seconds)"), myScript.UnrevealTime); myScript.UnrevealLetterOpacityBegin = EditorGUILayout.FloatField(new GUIContent("Initial Opacity"), myScript.UnrevealLetterOpacityBegin); myScript.UnrevealLetterOpacityEnd = EditorGUILayout.FloatField(new GUIContent("Final Opacity"), myScript.UnrevealLetterOpacityEnd); myScript.UnrevealRandomRotation = EditorGUILayout.Toggle(new GUIContent("Apply Random Rotation"), myScript.UnrevealRandomRotation); myScript.UnrevealReverse = EditorGUILayout.Toggle(new GUIContent("Reverse"), myScript.UnrevealReverse); myScript.UnrevealTime = Math.Max(myScript.UnrevealTime, 0.0f); myScript.UnrevealLetterOpacityBegin = Math.Min(myScript.UnrevealLetterOpacityBegin, 1f); myScript.UnrevealLetterOpacityBegin = Math.Max(myScript.UnrevealLetterOpacityBegin, 0f); myScript.UnrevealLetterOpacityEnd = Math.Min(myScript.UnrevealLetterOpacityEnd, 1f); myScript.UnrevealLetterOpacityEnd = Math.Max(myScript.UnrevealLetterOpacityEnd, 0f); EditorGUILayout.LabelField("Events", new GUIStyle() { fontStyle = FontStyle.Bold }); EditorGUILayout.PropertyField(serializedObject.FindProperty("OnUnrevealStarted")); EditorGUILayout.PropertyField(serializedObject.FindProperty("OnUnrevealCompleted")); } using (new EditorGUI.DisabledScope(myScript.IsEditorPlayingAnimation)) { if (GUILayout.Button("Preview Reveal")) { myScript.Reveal(); } if (GUILayout.Button("Preview Unreveal")) { myScript.Unreveal(); } } using (new EditorGUI.DisabledScope(!myScript.IsEditorPlayingAnimation)) { if (GUILayout.Button("Stop Preview")) { myScript.StopAnimation(); } } if (GUI.changed) { serializedObject.ApplyModifiedProperties(); } } else { EditorGUILayout.LabelField("Target text must be of type Text, TextMeshPro or TextMeshProUGUI"); } }