コード例 #1
0
    // TODO: Create individual prefabs for each type of floatign text (damage, healing, etc) and add them to an array
    //       Specify the array number when requesting floating text - this will allow for much more stylistic displays
    public FloatingPopupText CreateFloatingPopupText(string text, Vector2 location, Color color = new Color(), FloatingFadeMethod method = FloatingFadeMethod.None, float speedMult = 1, float randomXRange = 0, float randomSpeedMult = 1, float textTime = 2, float maxPlaneDistance = 0)
    {
        if (floatingTextDisabled)
        {
            return(null);
        }
        GameObject        newFloatingText = Instantiate(floatingTextPrefab);
        FloatingPopupText popupText       = newFloatingText.GetComponent <FloatingPopupText>();

        popupText.StartFloating(text, globalSpeedMult, randomXRange, randomSpeedMult, textTime, maxPlaneDistance);
        newFloatingText.transform.position = location;
        newFloatingText.transform.SetParent(mainCanvas, false);
        if (method != FloatingFadeMethod.None)
        {
            newFloatingText.GetComponent <FloatingPopupText>().SelectFadeMethod(method);
        }
        if (color != new Color())
        {
            popupText.proFloatingText.color = color;
        }

        // Add a small delay to further popups
        floatingTextDisabled = true;
        Invoke("EnableFloatingText", 1);
        return(popupText);
    }