//===================================================================== #region Initialization //===================================================================== private static Transform InstantiateTransform(Vector3 position, TextAnimName animation) { switch (animation) { case TextAnimName.DAMAGE: return(Instantiate( GameAssets.Instance.DamageTextPopup, position, Quaternion.Euler(45, 0, 0))); case TextAnimName.INCREMENTATION: return(Instantiate( GameAssets.Instance.IncrementationTextPopup, position, Quaternion.Euler(45, 0, 0))); default: if (animation != TextAnimName.NONE) { Debug.LogWarning("Invalid animation name detected."); } return(Instantiate( GameAssets.Instance.TextPopup, position, Quaternion.Euler(45, 0, 0))); } }
/// <summary> /// Instantiates a text popup matching the input values. /// </summary> /// <param name="position">The instantiation position.</param> /// <param name="value">The string value of the popup.</param> /// <param name="animation">The animation of the popup.</param> /// <param name="color">The color of the popup.</param> /// <returns>Initialized TextPopup.</returns> public static TextPopup CreateTextPopup( Vector3 position, string value, TextAnimName animation = TextAnimName.NONE, Color32?color = null) { Transform textPopupTransform = InstantiateTransform(position, animation); SetupStr(textPopupTransform, value, color); return(textPopupTransform.GetComponent <TextPopup>()); }
//===================================================================== #region Class methods //===================================================================== /// <summary> /// Instantiates a text popup matching the input values. /// </summary> /// <param name="position">The instantiation position.</param> /// <param name="value">The integer value of the popup.</param> /// <param name="animation">The animation of the popup.</param> /// <param name="crit">Whether the value is a crit.</param> /// <returns>Initialized TextPopup.</returns> public static TextPopup CreateIntPopup( Vector3 position, int value, TextAnimName animation = TextAnimName.NONE, bool crit = false) { Transform textPopupTransform = InstantiateTransform(position, animation); SetupInt(textPopupTransform, value, crit); return(textPopupTransform.GetComponent <TextPopup>()); }