예제 #1
0
        /// <summary>
        /// 根据对象池名称获取
        /// </summary>
        /// <param name="poolName"></param>
        /// <returns></returns>
        public GameObject GetGameObject(string poolName)
        {
            GameObject result = null;

            if (m_GameObjectPools.ContainsKey(poolName))
            {
                GameObjectPool pool = m_GameObjectPools[poolName];
                result = pool.GetGameObject();
            }
            else
            {
                Debug.LogError("Invalid pool name specified: " + poolName);
            }
            return(result);
        }
 static int GetGameObject(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Framework.GameObjectPool obj = (Framework.GameObjectPool)ToLua.CheckObject <Framework.GameObjectPool>(L, 1);
         UnityEngine.GameObject   o   = obj.GetGameObject();
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #3
0
        /// <summary>
        /// 显示减血Tips
        /// </summary>
        /// <param name="content">内容</param>
        /// <param name="pos">位置</param>
        /// <param name="y">y偏移</param>
        public void ShowReduceTips(string content, Vector3 pos, float y = 120f)
        {
            var txtObject = m_ReducePool.GetGameObject();
            var tipsText  = txtObject.GetComponent <Text>();

            Util.SetParent(TipsCanvas, txtObject.transform);

            tipsText.text = content;
            txtObject.SetActive(true);

            txtObject.transform.localRotation = Quaternion.identity;
            txtObject.transform.localScale    = Vector3.one;
            txtObject.transform.localPosition = new Vector3(pos.x, pos.y - y, 0);

            var color = tipsText.color;

            color.a        = 0;
            tipsText.color = color;
            Sequence mySequence = DOTween.Sequence();
            Tweener  move1      = txtObject.transform.DOLocalMoveY(pos.y, 0.4f);

            move1.SetEase(Ease.InCubic);
            Tweener move2 = txtObject.transform.DOLocalMoveY(pos.y + y, 0.4f);

            move2.SetEase(Ease.OutCubic);
            Tweener alpha1 = tipsText.DOColor(new Color(color.r, color.g, color.b, 1), 0.4f);
            Tweener alpha2 = tipsText.DOColor(new Color(color.r, color.g, color.b, 0), 0.4f);
            Tweener scale1 = txtObject.transform.DOScale(new Vector3(2f, 2f, 1f), 0.4f);

            scale1.SetEase(Ease.InOutCubic);
            Tweener scale2 = txtObject.transform.DOScale(new Vector3(1f, 1f, 1f), 0.4f);

            scale2.SetEase(Ease.InOutCubic);

            mySequence.Append(move1);
            mySequence.Join(alpha1);
            mySequence.Join(scale1);
            mySequence.AppendInterval(0.4f);
            mySequence.Append(move2);
            mySequence.Join(alpha2);
            mySequence.Join(scale2);

            mySequence.OnComplete(delegate()
            {
                mySequence.Kill();
                m_ReducePool.RecyleToPool(txtObject);
            });
        }
예제 #4
0
        /// <summary>
        /// 显示一个Icon Tips
        /// </summary>
        /// <param name="type">icon 类型(也是Sprite名称)</param>
        /// <param name="content">加分</param>
        /// <param name="y"></param>
        public void ShowTips(string type, string content, float y = 120f)
        {
            var txtObject = m_IconPool.GetGameObject();
            var tipsIcon  = txtObject.GetComponentInChildren <Image>();
            var tipsText  = txtObject.GetComponentInChildren <TextMeshProUGUI>();

            Util.SetParent(TipsCanvas, txtObject.transform);

            tipsIcon.sprite = m_SpriteAtlas.GetSprite(type);
            tipsIcon.SetNativeSize();
            tipsText.text = content;
            txtObject.SetActive(true);

            var vector = string.IsNullOrEmpty(content) ? Vector2.zero : Random.insideUnitCircle * 240;

            txtObject.transform.localRotation = Quaternion.identity;
            txtObject.transform.localScale    = Vector3.one;
            txtObject.transform.localPosition = new Vector3(vector.x, vector.y - y, 0);

            var color = tipsText.color;

            color.a        = 0;
            tipsText.color = color;
            Sequence mySequence = DOTween.Sequence();
            Tweener  move1      = txtObject.transform.DOLocalMoveY(vector.y, 0.2f);
            Tweener  move2      = txtObject.transform.DOLocalMoveY(vector.y + 1.5f * y, 1.7f);
            Tweener  alpha1     = tipsText.DOColor(new Color(color.r, color.g, color.b, 1), 0.2f);
            Tweener  alpha2     = tipsText.DOColor(new Color(color.r, color.g, color.b, 0), 1.7f);

            mySequence.Append(move1);
            mySequence.Join(alpha1);
            mySequence.Append(move2);
            mySequence.Join(alpha2);

            mySequence.OnComplete(delegate()
            {
                mySequence.Kill();
                m_IconPool.RecyleToPool(txtObject);
            });
        }