Exemplo n.º 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);
    }
Exemplo n.º 2
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;
     }
 }