示例#1
0
    FlyFont GetFlyFont(DamageType type)
    {
        int key = (int)type;

        if (!CanGetFont(key))
        {
            Log.Error("超出最大数量,不在实例化飘字");
            return(null);
        }
        FlyFont ft = null;

        if (flyPoolDic.ContainsKey(key))
        {
            ObjectPool <FlyFont> pool = flyPoolDic[key];
            ft = pool.GetObject();
        }
        else
        {
            ObjectPool <FlyFont> pool = new ObjectPool <FlyFont>();
            flyPoolDic.Add(key, pool);
            ft = pool.GetObject();
        }
        AddToUsingDic(key, ft);
        return(ft);
    }
示例#2
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;
        }
    }
示例#3
0
    public void ShowDamage(uint damageValue, uint damType, uint roleid, EntityType type, uint curHp, uint skillid = 1, uint attackerid = 0)
    {//伤害包
        // Log.LogGroup("ZDY", "show damage damagevalue is {0}", damageValue);
        Client.IEntity entity = GetEntity(roleid, type);
        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到实体roleid:{0},type :{1}", roleid, type);
            return;
        }
        SetEntityCurHP(entity, curHp);
        table.SkillDatabase skillData = GameTableManager.Instance.GetTableItem <table.SkillDatabase>(skillid);
        uint damageTimes  = 1;
        uint hurtinterval = 0;

        if (skillData != null)
        {
            damageTimes  = skillData.damagetimes;
            hurtinterval = skillData.hurtinterval;
        }


        DamageType dt = GetDamageType(damType);

        if (testType != DamageType.None)
        {
            dt = testType;
        }
        if (entity != null)
        {
            //if (damageTimes == 1 || dt == DamageType.Doge)
            {
                FlyFont font = GetFlyFont(dt);
                if (font == null)
                {
                    return;
                }
                font.InitDamageType(dt);
                AddFlyFont(entity, type, dt, font, damageValue);
            }
            //else
            //{
            //    uint damage = damageValue / damageTimes;
            //    List<int> damageList = new List<int>();
            //    int totalHurt = 0;
            //    uint averageValue = damage - damage / 4;
            //    for (int i = 0; i < damageTimes - 1; i++)
            //    {
            //        int hurt = UnityEngine.Random.Range((int)averageValue, (int)damage);
            //        damageList.Add(hurt);
            //        totalHurt += hurt;
            //    }

            //    int lastHurt = (int)damageValue - totalHurt;
            //    damageList.Add(lastHurt);
            //    StartCoroutine(AddDamage(roleid, damType, type, damageList, hurtinterval));
            //}
        }
    }
示例#4
0
    void PreLoadFont()
    {
        m_dicFt = new Dictionary <DamageType, List <FlyFont> >();
        Profiler.BeginSample("PreLoadFightFont");
        Array types = Enum.GetValues(typeof(DamageType));

        for (int i = 0; i < types.Length; i++)
        {
            DamageType dt = (DamageType)types.GetValue(i);
            if (dt == DamageType.Normal || dt == DamageType.AddHp)
            {
                for (int n = 0; n < m_nNormalFontPreLoad; n++)
                {
                    FlyFont ff = GetFlyFont(dt);
                    if (ff == null)
                    {
                        return;
                    }
                    ff.InitDamageType(dt);
                    AddFontPool(dt, ff);
                }
            }
            else if (dt == DamageType.None)
            {
                continue;
            }
            else
            {
                for (int n = 0; n < m_nOtherFontPreLoad; n++)
                {
                    FlyFont ff = GetFlyFont(dt);
                    if (ff == null)
                    {
                        return;
                    }
                    ff.InitDamageType(dt);
                    AddFontPool(dt, ff);
                }
            }
        }
        var iter = m_dicFt.GetEnumerator();

        while (iter.MoveNext())
        {
            var            dic = iter.Current;
            List <FlyFont> fl  = dic.Value;
            for (int i = 0; i < fl.Count; i++)
            {
                FlyFont ff = fl[i];
                ReturnFlyFont(dic.Key, ff);
            }
        }
        m_dicFt.Clear();
        m_dicFt = null;
        Profiler.EndSample();
    }
示例#5
0
 void RemoveFormUsingDic(int key, FlyFont font)
 {
     if (m_usingFontDic.ContainsKey(key))
     {
         List <FlyFont> list = m_usingFontDic[key];
         if (list.Contains(font))
         {
             list.Remove(font);
         }
     }
 }
示例#6
0
 public void SetData(float duringtime, float delay, MeshText text, FlyFont font, DamageType type)
 {
     precent    = 0.1f;
     StartTime  = Time.time;
     DuringTime = duringtime;
     DelayTime  = delay;
     CurPrecent = 1;
     mt         = text;
     Flyfont_   = font;
     Type_      = type;
     mt.uiAtlas.spriteMaterial.color = new Color(mt.uiAtlas.spriteMaterial.color.r, mt.uiAtlas.spriteMaterial.color.g, mt.uiAtlas.spriteMaterial.color.b, 1);
 }
示例#7
0
    void ShowExp(int exp)
    {
        DamageType dt   = DamageType.AddExp;
        FlyFont    font = GetFlyFont(dt);

        if (font == null)
        {
            return;
        }
        font.InitDamageType(dt);
        AddFlyFont(MainPlayerHelper.GetMainPlayer(), EntityType.EntityType_Player, dt, font, exp);
    }
示例#8
0
 void AddToUsingDic(int key, FlyFont ft)
 {
     if (!m_usingFontDic.ContainsKey(key))
     {
         List <FlyFont> fontList = new List <FlyFont>();
         fontList.Add(ft);
         m_usingFontDic.Add(key, fontList);
     }
     else
     {
         List <FlyFont> fontList = m_usingFontDic[key];
         fontList.Add(ft);
     }
 }
示例#9
0
    void AddFontPool(DamageType dt, FlyFont ft)
    {
        List <FlyFont> fl = null;

        if (m_dicFt.ContainsKey(dt))
        {
            fl = m_dicFt[dt];
        }
        else
        {
            fl = new List <FlyFont>();
            m_dicFt.Add(dt, fl);
        }
        fl.Add(ft);
    }
示例#10
0
    public void ShowBuffDamage(stBuffDamage damage)
    {
        Client.IEntity entity = GetEntity(damage.uid);
        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到实体roleid:{0}", damage.uid);
            return;
        }

        SetEntityCurHP(entity, damage.curHp);

        if (damage.uid != MainPlayerHelper.GetPlayerUID())
        {
            return;
        }

        EntityType entype = damage.entityType == (int)EntityType.EntityType_Player ? EntityType.EntityType_Player : EntityType.EntityType_NPC;

        DamageType dt = DamageType.Normal;

        if (damage.changeValue > 0)
        {
            dt = DamageType.AddHp;
        }
        if (testType != DamageType.None)
        {
            dt = testType;
        }
        if (entity != null)
        {
            if (damage.damagetype == (int)GameCmd.HPChangeType.HPChangeType_Buff || damage.damagetype == (int)GameCmd.HPChangeType.HPChangeType_Imme)
            {
                FlyFont font = GetFlyFont(dt);
                if (font == null)
                {
                    return;
                }
                font.InitDamageType(dt);
                AddFlyFont(entity, entype, dt, font, damage.changeValue);
            }
        }
    }
示例#11
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);
        }
    }
示例#12
0
    void SetFontText(FlyFont font, int damage, DamageType damType, bool isSelf)
    {
        damage = Math.Abs(damage);

        damagetext.Remove(0, damagetext.Length);
        if (isSelf)
        {
            if (damType == DamageType.Critical)
            {
                damagetext.Append("1005");
                damagetext.Append("0510");
            }
            else if (damType == DamageType.AddExp)
            {
                damagetext.Append("1004");
                damagetext.Append("0410");
            }
            else if (damType == DamageType.Buff || damType == DamageType.Resist)
            {
                damagetext.Append("1002");
            }
            else if (damType == DamageType.Doge)
            {
                damagetext.Append("1003");
            }
            else if (damType == DamageType.AddHp)
            {
                damagetext.Append("0310");
            }
            else
            {
                damagetext.Append("0510");
            }
        }
        else
        {
            if (damType == DamageType.Critical)
            {
                damagetext.Append("1001");
                damagetext.Append("0210");
            }
            else if (damType == DamageType.AddExp)
            {
                damagetext.Append("1004");
                damagetext.Append("0410");
            }
            else if (damType == DamageType.Buff || damType == DamageType.Resist)
            {
                damagetext.Append("1002");
            }
            else if (damType == DamageType.Doge)
            {
                damagetext.Append("1003");
            }
            else if (damType == DamageType.AddHp)
            {
                damagetext.Append("0310");
            }
            else
            {
                damagetext.Append("0110");
            }
        }
        bool bReplaceAdd = false;

        if (damage != 0)
        {
            string str = damage.ToString();
            //经验buff加成显示 先暂时去掉 (要区分打怪经验 )
            //if(damType == DamageType.AddExp)
            //{
            //    if (MainPlayerHelper.GetMainPlayer() != null)
            //    {
            //        int expbuff = MainPlayerHelper.GetMainPlayer().GetProp((int)PlayerProp.ExpAddBuff);
            //        expbuff = expbuff / 100;
            //        if (expbuff != 0)
            //        {
            //            bReplaceAdd = true;
            //            str = string.Format("{0}(+{1}%)", str, expbuff);
            //        }
            //    }
            //}

            for (int i = 0; i < str.Length; i++)
            {
                char c = str[i];
                damagetext.Append("0");
                switch ((int)damType)
                {
                case 0:
                    strtype = "0";
                    break;

                case 1:
                    strtype = "1";
                    break;

                case 2:
                    strtype = "2";
                    break;

                case 3:
                    strtype = "3";
                    break;

                case 4:
                    strtype = "4";
                    break;

                case 5:
                    strtype = "5";
                    break;

                case 6:
                    strtype = "6";
                    break;

                case 7:
                    strtype = "7";
                    break;
                }
                if (!isSelf)
                {
                    damagetext.Append(strtype);
                }
                else
                {
                    if (damType == DamageType.AddHp || damType == DamageType.AddExp)
                    {
                        damagetext.Append(strtype);
                    }
                    else
                    {
                        damagetext.Append("5");
                    }
                }
                if (bReplaceAdd)
                {
                    if (c.ToString() == "+")
                    {
                        damagetext.Append("10");
                    }
                    else
                    {
                        damagetext.Append("0");
                        damagetext.Append(c);
                    }
                }
                else
                {
                    damagetext.Append("0");
                    damagetext.Append(c);
                }
            }
        }

        font.SetText(damagetext.ToString());
    }
示例#13
0
 public void InitFlyFont(FlyFont ft)
 {
     m_ft = ft;
 }