コード例 #1
0
        protected override void Release()
        {
            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);
 }