예제 #1
0
    public void UpdateTimeImage()
    {
        foreach (Image img in m_PreRemoveImgList)
        {
            if (m_TimeImageDict.ContainsKey(img))
            {
                if (m_TimeImageDict[img].hideObjOnRemove != null)
                {
                    m_TimeImageDict[img].hideObjOnRemove.SetActive(false);
                }

                m_TimeImageDict.Remove(img);
            }
        }

        m_PreRemoveImgList.Clear();

        List <Image> list = new List <Image>(m_TimeImageDict.Keys);

        foreach (Image img in list)
        {
            CountdownImgInfo info = m_TimeImageDict[img];
            if (info.text)
            {
                int sec = (int)System.Math.Ceiling(img.fillAmount * info.time);
                info.text.text = sec.ToString();
            }

            img.fillAmount -= Time.unscaledDeltaTime / info.time;
            if (img.fillAmount <= 0.0f)
            {
                img.fillAmount = 0.0f;

                if (info.text)
                {
                    info.text.text = "0";
                }

                bool bRemove = true;
                if (info.callFuc != null)
                {
                    bRemove = info.callFuc(0, false, img, info.userdata);
                }

                if (bRemove)
                {
                    m_PreRemoveImgList.Add(img);
                }
            }
        }
    }
예제 #2
0
 public void RemoveTimeImage(Image img, bool bCallFun = false)
 {
     if (m_TimeImageDict.ContainsKey(img))
     {
         CountdownImgInfo info = m_TimeImageDict[img];
         img.fillAmount = 0;
         bool bRemove = true;
         if (bCallFun && info.callFuc != null)
         {
             bRemove = info.callFuc(0, false, img, info.userdata);
         }
         if (bRemove)
         {
             m_PreRemoveImgList.Add(img);
         }
     }
 }