Beispiel #1
0
    /// <summary>
    /// Spawns the effects that shows HP gain or lost
    /// </summary>
    /// <param name="amount"></param>
    void DisplayHPChange(int amount, Color color)
    {
        if (m_hpDisplayPrefab != null && m_hpDisplaySpawnPoint != null)
        {
            GameObject go = Instantiate(m_hpDisplayPrefab, transform, true);
            go.transform.position = m_hpDisplaySpawnPoint.position;

            HPChangeDisplay display = go.GetComponentInChildren <HPChangeDisplay>();
            display.SetText(amount.ToString());
            display.SetColor(color);
        }
    }
    /// <summary>
    /// Spawns the text that shows total exp earned when clicked
    /// </summary>
    /// <param name="exp"></param>
    /// <param name="color"></param>
    public void OnClick()
    {
        EXPManager.instance.OnClickToEarn();

        if (m_prefab != null)
        {
            string  text     = string.Format("+{0} exp", EXPManager.instance.ClickExp);
            Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            GameObject go = Instantiate(m_prefab, transform, true);
            go.transform.position = mousePos;

            HPChangeDisplay display = go.GetComponentInChildren <HPChangeDisplay>();
            display.SetText(text.ToString());
            display.SetColor(m_color);
        }
    }