Example #1
0
    IEnumerator reloadRoutine()
    {
        Color original = GetComponent <Image>().color;
        Color faded    = new Color(original.r, original.g, original.b, 0.5f);

        GetComponent <Image>().color = faded;
        float currProgress = progressImage.fillAmount;
        float addAmmount   = refreshTime * 0.05f;

        Debug.Log("reloadRoutine(): addAmount = " + addAmmount);
        while (progressImage.fillAmount < 1)
        {
            progressImage.fillAmount = progressImage.fillAmount + addAmmount;
            yield return(new WaitForSeconds(0.05f));
        }
        if (isButton)
        {
            int tmp = HUDInfo.resetAmmo(key);
            if (tmp == -1)
            {
                Debug.Log("reload(): unable to reset for button");
            }
            else
            {
                Debug.Log("tmp = " + tmp);
                GetComponent <Image>().color = original;
            }
        }
        else
        {
            int tmp = HUDInfo.resetAmmo(axis);
            if (tmp == -1)
            {
                Debug.Log("reload(): unable to reset for trigger");
            }
            else
            {
                Debug.Log("tmp = " + tmp);
                GetComponent <Image>().color = original;
            }
        }
        //GetComponent<Image>().color = original;
    }