// 包解析 private void ParsePackage(Pmd.ForwardNullUserPmd_CS package, int buffLen = 0) { if (package == null) { return; } // 消息解压 if ((package.bitmask & (uint)Pmd.FrameHeader.Bitmask_Compress) != 0) { package.bitmask &= ~(uint)Pmd.FrameHeader.Bitmask_Compress; // 去掉压缩标记 package.data = Common.ZlibCodec.Decode(package.data); } // 嵌套打包 if ((package.bitmask & (uint)Pmd.FrameHeader.Bitmask_Header) != 0) { package.bitmask &= ~(uint)Pmd.FrameHeader.Bitmask_Header; // 去掉嵌套打包标记 using (var mem = new MemoryStream(package.data)) { while (mem.Position < mem.Length) { var embed = Pmd.ForwardNullUserPmd_CS.DeserializeLengthDelimited(mem); ParsePackage(embed); } if (mem.Position >= mem.Length) { return; } } } Engine.PackageIn pack = PackageInPool.Alloc(); pack.buffLen = buffLen; try { package.SerializeLengthDelimited(pack); } catch (System.Exception ex) { //Engine.Utility.Log.Error(""); //string str = ex.ToString(); } m_lstPackageIn.Add(pack); }
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); } }
/// <summary> /// 严格检查两点之间是否通畅 /// </summary> /// <returns><c>true</c>, if path clear was lined, <c>false</c> otherwise.</returns> /// <param name="src">Vec source.</param> /// <param name="dst">Vec dst.</param> private bool LinePathClear(Vector2 src, Vector2 dst) { MapGrid dstPt = MapGridPool.Alloc(); MapGrid.GetMapGrid(dst, ref dstPt); Vector2 dir = dst - src; dir.Normalize(); dir *= ShortestMoveDst; MapGrid curPt = MapGridPool.Alloc(); curPt.x = 0; curPt.z = 0; float fDistance = Vector2.Distance(src, dst); bool bDiff = false; bool bSame = false; for (; fDistance > ShortestMoveDst; src += dir) { //UnityEngine.Profiler.BeginSample("LinePathClear 1"); MapGrid tmp = MapGridPool.Alloc(); MapGrid.GetMapGrid(src, ref tmp); //UnityEngine.Profiler.EndSample(); //UnityEngine.Profiler.BeginSample("LinePathClear same"); bDiff = (curPt != tmp); //UnityEngine.Profiler.EndSample(); //UnityEngine.Profiler.BeginSample("LinePathClear distance"); fDistance = Vector2.Distance(src, dst);////Engine.Utility.Geometry.GetDistance(ref src, ref dst, false); //UnityEngine.Profiler.EndSample(); //UnityEngine.Profiler.BeginSample("LinePathClear 2"); if (bDiff) { curPt = tmp; } else { MapGridPool.Free(tmp); //UnityEngine.Profiler.EndSample(); continue; } MapGridPool.Free(tmp); //UnityEngine.Profiler.EndSample(); if (!MapObstacle.Instance.CanWalk((int)curPt.x, (int)curPt.z)) { MapGridPool.Free(dstPt); MapGridPool.Free(curPt); return(false); } bSame = (curPt == dstPt); if (bSame) { break; } } MapGridPool.Free(dstPt); MapGridPool.Free(curPt); return(true); }