예제 #1
0
    public void ShowMsg(string msgStr)
    {
        Debug.Assert(MsgTemplate);
        if (gameObject.activeSelf == false)
        {
            gameObject.SetActive(true);
        }
        if (m_WaitingMsgList.Count == MSG_LIMIT)  // 超过限制了,隐藏第一个,并从等待列表中移除
        {
            XUIMidMsgAnimator msgSave = m_WaitingMsgList[0];
            m_WaitingMsgList.RemoveAt(0);
            msgSave.StopAnimate();                           // 先停止其显示协程
            msgSave.StartCoroutine(msgSave.WaitMsgDelete()); // 让其渐变淡出
        }

        // 将之前的,向上移位,并缩放效果
        m_WaitingMsgList.ForEach((msgSave) =>
        {
            Vector3 startPos = msgSave.transform.localPosition;  // 如果正在移位中...那么取当前移位结果位置进行下一步位移
            var endPos       = startPos + new Vector3(0, MSG_HEIGHT, 0);
            msgSave.transform.DOLocalMove(endPos, FADE_TIME);

            Vector3 startScale = msgSave.transform.localScale;  // 如果正在缩放中...那么取当前缩放结果位置进行下一步缩放
            Vector3 endScale   = startScale * 0.95f;
            msgSave.transform.DOScale(endScale, FADE_TIME);
        });

        XUIMidMsgAnimator msgInstance = PoolGet();

        // 开始执行动画~
        m_WaitingMsgList.Add(msgInstance);
        msgInstance.StartAnimate(msgStr);
    }
예제 #2
0
    public XUIMidMsgAnimator PoolGet()
    {
        XUIMidMsgAnimator msgInstance = null;

        if (m_MsgTempllatePool.Count > 0)
        {
            msgInstance = m_MsgTempllatePool.Pop();
        }

        if (msgInstance == null)
        {
            GameObject newGameObj = GameObject.Instantiate(MsgTemplate) as GameObject;
            msgInstance = newGameObj.AddComponent <XUIMidMsgAnimator>();
            msgInstance.transform.SetParent(this.transform);
            msgInstance.UICtrler = this;
        }


        //   UnityHelper.ResetTransform(msgInstance.transform);
        msgInstance.transform.localPosition    = Vector3.zero;
        msgInstance.transform.localEulerAngles = Vector3.zero;
        msgInstance.transform.localScale       = Vector3.one;
        msgInstance.gameObject.SetActive(true);

        return(msgInstance);
    }
예제 #3
0
    public XUIMidMsgAnimator PoolGet()
    {
        XUIMidMsgAnimator msgInstance = null;

        if (m_MsgTempllatePool.Count > 0)
        {
            msgInstance = m_MsgTempllatePool.Pop();
        }

        if (msgInstance == null)
        {
            GameObject newGameObj = GameObject.Instantiate(MsgTemplate) as GameObject;
            msgInstance = newGameObj.GetComponent <XUIMidMsgAnimator>();
            if (msgInstance == null)
            {
                msgInstance = newGameObj.AddComponent <XUIMidMsgAnimator>();
            }
            msgInstance.transform.SetParent(this.transform);
            msgInstance.UICtrler = this;
        }

        KTool.ResetLocalTransform(msgInstance.transform);
        msgInstance.gameObject.SetActive(true);

        return(msgInstance);
    }
예제 #4
0
 public void Update()
 {
     if (m_WaitingMsgList.Count >= 1)
     {
         if (calcTime <= 0)
         {
             XUIMidMsgAnimator msgInstance = PoolGet();
             msgInstance.StartAnimate(m_WaitingMsgList.Pop());
             calcTime = waitTime;
         }
         calcTime -= Time.deltaTime;
     }
 }
예제 #5
0
 public void PoolDelete(XUIMidMsgAnimator msgInstance)
 {
     msgInstance.gameObject.SetActive(false);
     m_MsgTempllatePool.Push(msgInstance);
 }