Exemplo n.º 1
0
        protected override void Release(bool isShutdown)
        {
            ExpBarItem expBarItem = (ExpBarItem)Target;

            if (expBarItem == null)
            {
                return;
            }

            Object.Destroy(expBarItem.gameObject);
        }
Exemplo n.º 2
0
        private void Update()
        {
            for (int i = m_ActiveExpBarItems.Count - 1; i >= 0; i--)
            {
                ExpBarItem expBarItem = m_ActiveExpBarItems[i];
                if (expBarItem.Refresh())
                {
                    continue;
                }

                HideExpBar(expBarItem);
            }
        }
Exemplo n.º 3
0
        public void ShowExpBar(Entity entity, float fromHPRatio, float toHPRatio)
        {
            if (entity == null)
            {
                Log.Warning("Entity is invalid.");
                return;
            }

            ExpBarItem expBarItem = GetActiveExpBarItem(entity);

            if (expBarItem == null)
            {
                expBarItem = CreateExpBarItem(entity);
                m_ActiveExpBarItems.Add(expBarItem);
            }

            expBarItem.Init(entity, m_CachedCanvas, fromHPRatio, toHPRatio);
        }
Exemplo n.º 4
0
        private ExpBarItem CreateExpBarItem(Entity entity)
        {
            ExpBarItem       expBarItem       = null;
            ExpBarItemObject expBarItemObject = m_ExpBarItemObjectPool.Spawn();

            if (expBarItemObject != null)
            {
                expBarItem = (ExpBarItem)expBarItemObject.Target;
            }
            else
            {
                expBarItem = Instantiate(m_ExpBarItemTemplate);
                Transform transform = expBarItem.GetComponent <Transform>();
                transform.SetParent(m_ExpBarInstanceRoot);
                transform.localScale = Vector3.one;
                m_ExpBarItemObjectPool.Register(ExpBarItemObject.Create(expBarItem), true);
            }

            return(expBarItem);
        }
Exemplo n.º 5
0
 private void HideExpBar(ExpBarItem expBarItem)
 {
     expBarItem.Reset();
     m_ActiveExpBarItems.Remove(expBarItem);
     m_ExpBarItemObjectPool.Unspawn(expBarItem);
 }