public void ChangeType(FloatFontType type) { if (m_type == type) { return; } m_type = type; bNeedToUpdateValue = true; }
/// <summary> /// 计算位置 /// </summary> /// <param name="t">飘字类型</param> /// <param name="WorldPos">世界坐标</param> /// <param name="CreatureHeightInMeters">实体高度</param> /// <returns></returns> static Vector3 GenratePos(FloatFontType t,Vector3 WorldPos,float CreatureHeightInMeters) { Vector3 pixelPos = Vector3.zero; //高度超过3m,取3m if (CreatureHeightInMeters > 4) { CreatureHeightInMeters = 4; } switch (t) { case FloatFontType.TYPE_CURE: WorldPos.y += CreatureHeightInMeters; pixelPos = Initialize.mainCam.WorldToScreenPoint(WorldPos); break; case FloatFontType.TYPE_ENEMY_DAMGE: WorldPos.y += CreatureHeightInMeters; pixelPos = Initialize.mainCam.WorldToScreenPoint(WorldPos); break; case FloatFontType.TYPE_ENEMY_FATAL: WorldPos.y += CreatureHeightInMeters; pixelPos = Initialize.mainCam.WorldToScreenPoint(WorldPos); //策划要求,暴击飘字实现偏左和偏右逐次交替切换效果 bLeftOffset = !bLeftOffset; if (bLeftOffset) { pixelPos.x += -100 * GfxUtil.ScreenScale.x; } else { pixelPos.x += 100 * GfxUtil.ScreenScale.x; } break; case FloatFontType.TYPE_SELF_DMAGE: //CreatureHeightInMeters *= 0.5f;//自己的伤害在腰间,也就是高度取一半 WorldPos.y += CreatureHeightInMeters; pixelPos = Initialize.mainCam.WorldToScreenPoint(WorldPos); break; case FloatFontType.TYPE_TLANT_POINT: WorldPos.y += CreatureHeightInMeters; pixelPos = Initialize.mainCam.WorldToScreenPoint(WorldPos); // pixelPos.x += 50.0f * GfxUtil.ScreenScale.x; break; case FloatFontType.TYPE_LEVELUP: WorldPos.y += CreatureHeightInMeters; pixelPos = Initialize.mainCam.WorldToScreenPoint(WorldPos); break; } return pixelPos; }
/// <summary> /// 创建一个飘字,成功返回实例,失败返回null /// </summary> /// <param name="entry">实体</param> /// <param name="text">飘字的内容,目前只能是数字,像暴击、躲闪之类的尚未实现</param> /// <param name="type">飘字的类型</param> /// <param name="followEntity">跟随实体</param> /// <returns></returns> public static FloatFontNode CreateFloatFont(GameObject entry, string text, FloatFontType type = FloatFontType.TYPE_ENEMY_DAMGE, bool followEntity = false) { FloatFontNode tempNode = null; if (!bInit) { Trace.LogError("FloatFontManager必须初始化!"); return(tempNode); } if (SFGFxMovieManager.Instance == null) { Trace.LogError("SFGFxMovieManager没有初始化,请不要在Awake中创建!"); return(tempNode); } //有可能FloatFontMovie还没有创建完成. if (Movie.GetSingleton <FloatFontMovie>() == null) { //Trace.LogError("FloatFontMovie尚未创建完成,请等待创建完成后再调用,请不要在Awake或者Start中创建"); return(tempNode); } //有可能FloatFontMovie还没有创建完成. if (FloatFontMovie.Instance == null) { //Trace.LogError("FloatFontMovie尚未创建完成,请等待创建完成后再调用,请不要在Awake或者Start中创建"); return(tempNode); } if (!NeedToCreate(entry)) { return(null); } if (UnActiviteList.Count > 0) { tempNode = UnActiviteList.First.Value; UnActiviteList.RemoveFirst(); EnableFloatNode(tempNode); tempNode.ChangeHostEntity(entry); tempNode.ChangeType(type); tempNode.SetText(text); tempNode.UpdatePos(); } else { tempNode = CreateNewNode(entry); if (null == tempNode) { return(null); } tempNode.ChangeType(type); tempNode.SetText(text); tempNode.UpdatePos(); tempNode.SetEnable(true); ActiviteList.AddLast(tempNode); } tempNode.bFollowEntity = followEntity; return(tempNode); }