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); }
public void InitDamageType(DamageType type) { if (go == null) { fontType = type; uint resID = GetFontResIDByType(type); //List<string> depend = null; //StringBuilder sb = new StringBuilder("prefab/FightNum_"); //sb.Append(type.ToString()); //string name = sb.ToString(); UnityEngine.Object obj = UIManager.GetResGameObj(resID); if (obj != null) { go = GameObject.Instantiate(obj) as GameObject; if (go != null) { go.SetActive(true); mt = go.GetComponent <MeshText>(); if (mt == null) { mt = go.AddComponent <MeshText>(); } mt.Init(); //animator = go.GetComponent<FlyFontAlpha>(); //if (animator == null) //{ // animator = go.AddComponent<FlyFontAlpha>(); // animator.enabled = false; //} } DOTweenAnimation[] aniArray = GetTweens(); for (int i = 0; i < aniArray.Length; i++) { DOTweenAnimation ani = aniArray[i]; if (ani.animationType == DOTweenAnimationType.Color) { ani.tween.Rewind(); ani.tween.Kill(); if (ani.isValid) { ani.CreateTween(); ani.tween.Play(); } } } } } }
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); } }