Beispiel #1
0
    void BarPooling()
    {
        barList = new List <UIHpBar>();

        for (int i = 0; i < 10; ++i)
        {
            GameObject temp    = Instantiate(HpBarPrefab);
            UIHpBar    tempBar = temp.GetComponent <UIHpBar>();
            temp.transform.SetParent(HpBarCollecter);
            temp.SetActive(false);
            barList.Add(tempBar);
        }
    }
Beispiel #2
0
 public void HpBarReceiver(Acter _actor)
 {
     if (barList.Count <= 0)
     {
         GameObject temp    = Instantiate(HpBarPrefab);
         UIHpBar    tempBar = temp.GetComponent <UIHpBar>();
         temp.transform.SetParent(HpBarCollecter);
         temp.SetActive(true);
         tempBar.SetBattleCharacter(_actor);
         tempBar.AddEvent();
         return;
     }
     else if (barList.Count > 0)
     {
         UIHpBar tempBar = barList[0];
         tempBar.gameObject.SetActive(true);
         tempBar.SetBattleCharacter(_actor);
         barList.Remove(tempBar);
         tempBar.AddEvent();
         return;
     }
 }
Beispiel #3
0
 public void PushHpBar(UIHpBar hpBar)
 {
     hpBar.gameObject.SetActive(false);
     hpBar.RemoveEvent();
     barList.Add(hpBar);
 }