public static void CreateMyAsset() { BattleTextAnimation asset = ScriptableObject.CreateInstance <BattleTextAnimation>(); AssetDatabase.CreateAsset(asset, "Assets/BattleText/Fonts/Animations/NewAnimation.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
public static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Vector2 screenPosition) { return(SpawnText( text, prefab, animation, null, Vector3.zero, screenPosition, animation.DefaultColor )); }
public static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Vector3 worldPosition) { return(SpawnText( text, prefab, animation, null, Vector3.zero, BattleTextCamera.Instance.WorldToTextPosition(worldPosition), animation.DefaultColor )); }
public static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Transform target, Vector3 targetWorldOffset) { return(SpawnText( text, prefab, animation, target, targetWorldOffset, Vector2.zero, animation.DefaultColor )); }
public void DisplayText(string text, GameObject prefab, BattleTextAnimation animation, Color color) { if (!string.IsNullOrEmpty(text)) { if (SingleInstance && instance != null) { GameObject.Destroy(instance); } switch (Source) { case PositionSource.Screen: instance = BattleTextAnimator.SpawnText(text, prefab, animation, ScreenPosition, color); break; case PositionSource.Transform: if (FollowTargetPosition) { instance = BattleTextAnimator.SpawnText(text, prefab, animation, Target, TargetWorldOffset, color); } else { instance = BattleTextAnimator.SpawnText(text, prefab, animation, Target.position + TargetWorldOffset, color); } break; } // Set source specific properties instance.layer = gameObject.layer; if (!SingleInstance) { instance = null; } } }
static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Transform target, Vector3 targetWorldOffset, Vector2 screenPosition, Color color) { GameObject instance = (GameObject)GameObject.Instantiate(prefab); BattleTextRenderer renderer = instance.GetComponent <BattleTextRenderer>(); BattleTextAnimator animator = instance.AddComponent <BattleTextAnimator>(); if (!renderer.IsAnimated) { Debug.LogError(string.Format("[BattleTextAnimator] BattleTextRenderer script on '{0}' does not have 'Is Animated' set", prefab.name)); // Disable object instance.SetActiveRecursively(false); // Destroy it GameObject.Destroy(instance); return(null); } // Renderer settings renderer.InitialText = text; renderer.Color = color; renderer.FadeDelay = animation.FadeDelay; renderer.LockXRotation = false; renderer.LookAtMainCamera = animation.AnimateInWorld; // Animator settings animator.positions = animation.ClonePosition(); animator.Target = target; animator.Animation = animation; animator.WorldOffset = targetWorldOffset; animator.ScreenPosition = screenPosition; animator.RandomOffset = new Vector3( UnityEngine.Random.Range(-animation.RandomOffset.x, animation.RandomOffset.x), UnityEngine.Random.Range(-animation.RandomOffset.y, animation.RandomOffset.y), UnityEngine.Random.Range(-animation.RandomOffset.z, animation.RandomOffset.z) ); if (animation.HasRandomPosition) { for (int i = 0; i < animator.positions.Length; ++i) { if (animator.positions[i].Random) { Vector3 a = animator.positions[i].Amount; animator.positions[i].Amount.x = Random.Range(-a.x, a.x); animator.positions[i].Amount.y = Random.Range(-a.y, a.y); animator.positions[i].Amount.z = Random.Range(-a.z, a.z); } } } return(instance); }
static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Transform target, Vector3 targetWorldOffset, Vector2 screenPosition, Color color) { GameObject instance = (GameObject)GameObject.Instantiate(prefab); BattleTextRenderer renderer = instance.GetComponent<BattleTextRenderer>(); BattleTextAnimator animator = instance.AddComponent<BattleTextAnimator>(); if (!renderer.IsAnimated) { Debug.LogError(string.Format("[BattleTextAnimator] BattleTextRenderer script on '{0}' does not have 'Is Animated' set", prefab.name)); // Disable object instance.SetActiveRecursively(false); // Destroy it GameObject.Destroy(instance); return null; } // Renderer settings renderer.InitialText = text; renderer.Color = color; renderer.FadeDelay = animation.FadeDelay; renderer.LockXRotation = false; renderer.LookAtMainCamera = animation.AnimateInWorld; // Animator settings animator.positions = animation.ClonePosition(); animator.Target = target; animator.Animation = animation; animator.WorldOffset = targetWorldOffset; animator.ScreenPosition = screenPosition; animator.RandomOffset = new Vector3( UnityEngine.Random.Range(-animation.RandomOffset.x, animation.RandomOffset.x), UnityEngine.Random.Range(-animation.RandomOffset.y, animation.RandomOffset.y), UnityEngine.Random.Range(-animation.RandomOffset.z, animation.RandomOffset.z) ); if (animation.HasRandomPosition) { for (int i = 0; i < animator.positions.Length; ++i) { if (animator.positions[i].Random) { Vector3 a = animator.positions[i].Amount; animator.positions[i].Amount.x = Random.Range(-a.x, a.x); animator.positions[i].Amount.y = Random.Range(-a.y, a.y); animator.positions[i].Amount.z = Random.Range(-a.z, a.z); } } } return instance; }
public static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Vector2 screenPosition) { return SpawnText( text, prefab, animation, null, Vector3.zero, screenPosition, animation.DefaultColor ); }
public static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Vector3 worldPosition) { return SpawnText( text, prefab, animation, null, Vector3.zero, BattleTextCamera.Instance.WorldToTextPosition(worldPosition), animation.DefaultColor ); }
public static GameObject SpawnText( string text, GameObject prefab, BattleTextAnimation animation, Transform target, Vector3 targetWorldOffset, Color color) { return SpawnText( text, prefab, animation, target, targetWorldOffset, Vector2.zero, color ); }
public void DisplayText(string text, GameObject prefab, BattleTextAnimation animation) { DisplayText(text, prefab, animation, animation.DefaultColor); }
public void DisplayText(string text, Color color, BattleTextAnimation animation) { DisplayText(text, DefaultText, animation, color); }
void OnGUI() { GUILayout.BeginArea(new Rect(10, 10, 200, Screen.height - 20)); if (GUILayout.Button("Show Friendly Nameplate")) { friendlyNamePlate.active = true; neutralNamePlate.active = false; enemyNamePlate.active = false; } if (GUILayout.Button("Show Neutral Nameplate")) { friendlyNamePlate.active = false; neutralNamePlate.active = true; enemyNamePlate.active = false; } if (GUILayout.Button("Show Enemy Nameplate")) { friendlyNamePlate.active = false; neutralNamePlate.active = false; enemyNamePlate.active = true; } if (GUILayout.Button("Trigger Notice")) { noticeSource.DisplayText(noticeTexts[Random.Range(0, noticeTexts.Length)]); } if (GUILayout.Button("Trigger Damage")) { bool isCrit = Random.Range(0, 10) < 3; BattleTextAnimation animation = isCrit ? critAnimation : hitAnimation; int damage = isCrit ? Random.Range(1000, 2000) : Random.Range(1, 1000); damageSource.DisplayText(damage.ToString(), animation); } if (GUILayout.Button("Trigger Combat Text")) { int type = Random.Range(0, 3); BattleTextSource source = combatText[Random.Range(0, combatText.Length)]; string text = ""; switch (type) { case 0: text = "-" + Random.Range(0, 1000); break; case 1: text = "+" + Random.Range(0, 1000); break; case 2: text = "(Shielded)"; break; } source.DisplayText(text, combatColors[type]); } if (GUILayout.Button("Trigger Plume")) { int type = Random.Range(0, 2); string text = ""; switch (type) { case 0: text = "-" + Random.Range(0, 1000); break; case 1: text = "+" + Random.Range(0, 1000); break; } plumeText.DisplayText(text, combatColors[type]); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(Screen.width - 210, 10, 200, Screen.height - 20)); if (GUILayout.Button("Rotate Camera")) { cameraRotator.enabled = !cameraRotator.enabled; } if (GUILayout.Button("Viking Walking")) { vikingWalker.enabled = !vikingWalker.enabled; if (vikingWalker.enabled) { vikingWalker.animation.CrossFade("Walk"); } else { vikingWalker.animation.CrossFade("Idle"); } } if (GUILayout.Button("Nameplates Look At Camera")) { friendlyNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera = !friendlyNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera; neutralNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera = !neutralNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera; enemyNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera = !enemyNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera; if (!friendlyNamePlate.GetComponent <BattleTextRenderer>().LookAtMainCamera) { friendlyNamePlate.transform.rotation = Quaternion.Euler(0, -90, 0); neutralNamePlate.transform.rotation = Quaternion.Euler(0, -90, 0); enemyNamePlate.transform.rotation = Quaternion.Euler(0, -90, 0); } } if (GUILayout.Button("Damage Text Follows Viking")) { damageSource.FollowTargetPosition = !damageSource.FollowTargetPosition; } GUILayout.EndArea(); }