示例#1
0
        protected override void Release(bool isShutdown)
        {
            HPBarItem hpBarItem = (HPBarItem)Target;

            if (hpBarItem == null)
            {
                return;
            }

            Object.Destroy(hpBarItem.gameObject);
        }
示例#2
0
        private void Update()
        {
            for (int i = m_ActiveHPBarItems.Count - 1; i >= 0; i--)
            {
                HPBarItem hpBarItem = m_ActiveHPBarItems[i];
                if (hpBarItem.Refresh())
                {
                    continue;
                }

                HideHPBar(hpBarItem);
            }
        }
示例#3
0
        public void ShowHPBar(Entity entity, float fromHPRatio, float toHPRatio)
        {
            if (entity == null)
            {
                Log.Warning("Entity is invalid.");
                return;
            }

            HPBarItem hpBarItem = GetActiveHPBarItem(entity);

            if (hpBarItem == null)
            {
                hpBarItem = CreateHPBarItem(entity);
                m_ActiveHPBarItems.Add(hpBarItem);
            }

            hpBarItem.Init(entity, m_CachedCanvas, fromHPRatio, toHPRatio);
        }
示例#4
0
        private HPBarItem CreateHPBarItem(Entity entity)
        {
            HPBarItem       hpBarItem       = null;
            HPBarItemObject hpBarItemObject = m_HPBarItemObjectPool.Spawn();

            if (hpBarItemObject != null)
            {
                hpBarItem = (HPBarItem)hpBarItemObject.Target;
            }
            else
            {
                hpBarItem = Instantiate(m_HPBarItemTemplate);
                Transform transform = hpBarItem.GetComponent <Transform>();
                transform.SetParent(m_HPBarInstanceRoot);
                transform.localScale = Vector3.one;
                m_HPBarItemObjectPool.Register(new HPBarItemObject(hpBarItem), true);
            }

            return(hpBarItem);
        }
示例#5
0
 private void HideHPBar(HPBarItem hpBarItem)
 {
     hpBarItem.Reset();
     m_ActiveHPBarItems.Remove(hpBarItem);
     m_HPBarItemObjectPool.Unspawn(hpBarItem);
 }