Exemple #1
0
    public void ReturnFlyFont(DamageType type, FlyFont font)
    {
        DOTweenAnimation[] tweenArray = font.GetTweens();
        foreach (var ani in tweenArray)
        {
            if (ani.onComplete != null)
            {
                ani.onComplete.RemoveAllListeners();
            }

            if (ani.onStart != null)
            {
                ani.onStart.RemoveAllListeners();
            }
            if (ani.onUpdate != null)
            {
                ani.onUpdate.RemoveAllListeners();
            }
            if (ani.onPlay != null)
            {
                ani.onPlay.RemoveAllListeners();
            }
        }

        int key = (int)type;

        RemoveFormUsingDic(key, font);
        font.ReleaseTextMesh();
        ObjectPool <FlyFont> pool = flyPoolDic[key];

        if (pool.GetPoolCount() > MAX_FONTCOUNT)
        {
            Log.Error("超出最大数量,销毁飘字");
            font.ReleaseObject();
            return;
        }
        pool.ReturnObject(font);
        Transform fontTrans = font.GetFontTransform();

        if (fontTrans != null)
        {
            Transform posroot = fontTrans.parent;
            if (posroot != null)
            {
                if (posroot.name != m_strFlyroot)
                {
                    m_posRootPool.Free(posroot.gameObject);
                }
            }
            if (m_flyRoot == null)
            {
                GameObject flyrootobj = new GameObject(m_strFlyroot);

                m_flyRoot        = flyrootobj.transform;
                m_flyRoot.parent = this.transform;
            }
            fontTrans.parent = m_flyRoot;
        }
    }
Exemple #2
0
    void AddFlyFont(IEntity entity, EntityType type, DamageType damType, FlyFont font, float damage = 0)
    {
        Transform  posRoot = null;
        DamageType dt      = damType;

        if (testType != DamageType.None)
        {
            dt = testType;
        }
        bool bSelf = false;

        if (type == EntityType.EntityType_Player)
        {
            if (ClientGlobal.Instance().MainPlayer.GetUID() == entity.GetUID())
            {
                bSelf = true;
            }
        }
        if (damage == 0 && damType == DamageType.Normal)
        {
            //  Log.Error("damage == 0 && damType == DamageType.Normal  parent is flyroot");
            ReturnFlyFont(dt, font);
            return;
        }
        SetFontText(font, (int)damage, dt, bSelf);
        font.SetActive(true);

        GameObject rootGo = m_posRootPool.Alloc();

        posRoot        = rootGo.transform;
        posRoot.parent = this.transform;
        Vector3 enpos = entity.GetPos();
        Vector3 pos   = Vector3.zero;

        entity.GetLocatorPos(m_strLocatorName, Vector3.zero, Quaternion.identity, ref pos, true);
        float r = 0;// entity.GetRadius() * 2;

        posRoot.position = new Vector3(enpos.x, pos.y + r, enpos.z);

        posRoot.transform.rotation = GetLookRotation();
        Transform fontTrans = font.GetFontTransform();

        posRoot.name = entity.GetName();
        if (fontTrans != null && posRoot != null)
        {
            fontTrans.parent        = posRoot;
            fontTrans.localPosition = Vector3.zero;
            fontTrans.localRotation = Quaternion.identity;
            MeshText mt = font.GetMt();
            if (mt != null)
            {
                DOTweenAnimation[] tweenArray = font.GetTweens();
                DOTweenPath        pathTween  = font.GetPathTween();

                Tween maxAni = null;
                float during = 0;
                for (int i = 0; i < tweenArray.Length; i++)
                {
                    DOTweenAnimation tweenAni = tweenArray[i];

                    float totalTime = tweenAni.duration + tweenAni.delay;
                    if (totalTime > during)
                    {
                        maxAni = tweenAni.tween;
                        during = totalTime;
                    }
                    if (pathTween != null)
                    {
                        if (pathTween.duration + pathTween.delay > during)
                        {
                            maxAni = pathTween.tween;
                            during = pathTween.duration + pathTween.delay;
                        }
                    }
                    if (tweenAni.animationType == DOTweenAnimationType.Color)
                    {
                        int a = 10;
                    }
                    tweenAni.tween.Restart();
                    tweenAni.tween.Play();
                    // tweenAni.DOPlay();
                    //if (tweenAni.animationType == DOTweenAnimationType.Color)
                    //{
                    //    tweenAni.tween.Restart();
                    //    tweenAni.tween.Kill();
                    //    tweenAni.CreateTween();
                    //    //tweenAni.DOPlay();
                    //}
                    //else
                    //{
                    //    tweenAni.tween.Kill();
                    //    tweenAni.CreateTween();
                    //   // tweenAni.tween.Restart();
                    //}
                }

                if (pathTween != null)
                {
                    pathTween.DORestart();
                    pathTween.DOPlay();
                }


                maxAni.OnComplete(() =>
                {
                    ReturnFlyFont(dt, font);
                });
            }
        }
        else
        {
            ReturnFlyFont(dt, font);
        }
    }