예제 #1
0
        public void AddMomentum(float momentumAdded)
        {
            // if not yet started counting, the counting starts now.
            if (!m_startedGame)
            {
                StartCoroutine(WaitAndDecayMomentum());
                m_startedGame = true;
            }


            if (momentumAdded < 0)
            {
                Debug.LogError("AddMomentum() cannot accept negative value: " + momentumAdded);
                return;
            }

            Momentum += momentumAdded;

            UpdateMomentum();

            //creating momentum floatingText
            if (m_floatingTextPrefab)
            {
                GameObject floatingDamageInstance =
                    Instantiate(m_floatingTextPrefab, transform.position, Quaternion.identity);
                FloatingText floatingText = floatingDamageInstance.GetComponent <FloatingText>();
                floatingText.Init(
                    string.Format("+{0} mntm", momentumAdded),
                    m_momentumText.transform.position
                    );
                floatingText.text.color = new Color(0, 255, 255, 255);
            }
        }
    public void AddScore()
    {
        FloatingText floating = Instantiate(floatingNumberPrefab, transform.position, floatingNumberPrefab.transform.rotation);

        floating.Init(string.Format("<b>{0}</b>", scoreToAdd.ToString()));
        ScoreManager.singleton.score += scoreToAdd;
    }
예제 #3
0
    public static GameObject CreateFloatingText(Vector3 iPosition, string iText, float iDuration, Color?iColor = null)
    {
        GameObject   obj          = (GameObject)GameObject.Instantiate(Active.FloatingTextPrefab, iPosition, Quaternion.identity);
        FloatingText floatingText = obj.GetComponent <FloatingText>();

        floatingText.transform.parent = Active.FloatingTextContainer.transform;

        floatingText.Init(iText, iDuration, iColor ?? Color.black);


        return(obj);
    }
예제 #4
0
    /// <inheritdoc />
    protected override void OnPickup(GameObject picker)
    {
        Health health = picker.GetComponent <Health>() ?? picker.GetComponentInParent <Health>();

        if (health)
        {
            health.AddHealth(regenAmount);
        }
        else
        {
            Debug.LogWarning("Pickup picker does not contain a Health script: " + picker.name);
        }
        if (floatingHealthText)
        {
            GameObject   floatingTextInstance = Instantiate(floatingHealthText, transform.position, Quaternion.identity);
            FloatingText floatingText         = floatingTextInstance.GetComponent <FloatingText>();
            floatingText.Init(string.Format("+{0}HP", regenAmount), Vector3.up * 5, false);
            floatingText.text.color     = Color.red;
            floatingText.text.fontSize -= 3;
        }
    }