/// <summary> /// 刷新头顶所有状态 /// </summary> /// <param name="status"></param> private void RefreshAllHeadStatus(HeadStatusType status) { IEntity entity = null; long uid = 0; var enumerator = m_dicActiveRoleStateBar.GetEnumerator(); while (enumerator.MoveNext()) { if (null == enumerator.Current.Value) { continue; } entity = RoleStateBarManager.GetEntity(enumerator.Current.Key); if (null == entity) { continue; } switch (status) { case HeadStatusType.Hp: break; case HeadStatusType.Name: break; case HeadStatusType.Clan: { if (entity.GetEntityType() != EntityType.EntityType_Player && entity.GetEntityType() != EntityType.EntityType_NPC) { continue; } } break; case HeadStatusType.Title: { if (entity.GetEntityType() != EntityType.EntityType_Player) { continue; } } break; case HeadStatusType.Collect: break; case HeadStatusType.HeadMaskIcon: case HeadStatusType.TaskStatus: { if (entity.GetEntityType() != EntityType.EntityType_NPC) { continue; } } break; } enumerator.Current.Value.UpdateHeadStatus(status); } }
private void UpdateHeadStaus(long uid, HeadStatusType type, bool adJustHp = true) { if (m_dicActiveRoleStateBar.ContainsKey(uid)) { m_dicActiveRoleStateBar[uid].UpdateHeadStatus(type, adJustHp); } }
/// <summary> /// 更新UI /// </summary> public void UpdateBarUI() { for (HeadStatusType i = HeadStatusType.None + 1, max = HeadStatusType.Max; i < max; i++) { UpdateHeadStatus(i, false); } // AdjustStatusPos(); }
private void AdjustStatusPos() { if (Visible && null != m_hpSlider) { int Gap = GameTableManager.Instance.GetGlobalConfig <int>("HeadTitleGap"); float gap = Gap * 1.0f; Vector3 pos = m_v3StartPos; Transform widget = null; Bounds widgetsBounds; int enableCount = 0; for (HeadStatusType i = HeadStatusType.None + 1, max = HeadStatusType.Max; i < max; i++) { if (i == HeadStatusType.CampMask) { continue; } widget = GetWidget(i); if (null == widget || !widget.gameObject.activeSelf) { continue; } widgetsBounds = NGUIMath.CalculateRelativeWidgetBounds(widget, false); if (enableCount != 0) { pos.y += widgetsBounds.size.y * 0.5f; if (i == HeadStatusType.HeadMaskIcon) { pos.y -= gap; } } widget.localPosition = pos; pos.y += widgetsBounds.size.y * 0.5f; pos.y += gap; enableCount++; } } }
/// <summary> /// 事件处理 /// </summary> /// <param name="nEventID"></param> /// <param name="param"></param> public void GlobalEventHandler(int eventID, object param) { switch (eventID) { case (int)Client.GameEventID.ENTITYSYSTEM_CHANGE: { if (null != param && param is Client.stPlayerChange) { Client.stPlayerChange change = (Client.stPlayerChange)param; IEntity entity = RoleStateBarManager.GetEntityByUserID <IPlayer>(change.uid); if (null == entity) { entity = RoleStateBarManager.GetEntityByUserID <INPC>(change.uid); } if (null != entity) { LateUpdateChangePos(entity.GetUID()); } } } break; case (int)Client.GameEventID.ENTITYSYSTEM_UNRIDE: { if (null != param && param is stEntityUnRide) { stEntityUnRide unride = (stEntityUnRide)param; LateUpdateChangePos(unride.uid); } } break; case (int)Client.GameEventID.ENTITYSYSTEM_RIDE: { if (null != param && param is stEntityRide) { stEntityRide ride = (stEntityRide)param; LateUpdateChangePos(ride.uid); } } break; case (int)Client.GameEventID.ENTITYSYSTEM_ENTITYBEGINMOVE: { if (null != param && param is stEntityBeginMove) { stEntityBeginMove move = (stEntityBeginMove)param; OnEntityMoving(move.uid); } } break; case (int)Client.GameEventID.ENTITYSYSTEM_ENTITYMOVE: { if (null != param && param is stEntityMove) { stEntityMove move = (stEntityMove)param; OnEntityMoving(move.uid); } } break; case (int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE: { if (null != param && param is stEntityStopMove) { stEntityStopMove move = (stEntityStopMove)param; OnEntityMoving(move.uid); } } break; case (int)Client.GameEventID.ENTITYSYSTEM_CREATEENTITY: { //实体创建 Client.stCreateEntity ce = (Client.stCreateEntity)param; OnCretateEntity(ce); } break; case (int)Client.GameEventID.ENTITYSYSTEM_REMOVEENTITY: { //实体删除 Client.stRemoveEntity removeEntiy = (Client.stRemoveEntity)param; RemoveRoleBar(removeEntiy.uid); } break; case (int)Client.GameEventID.ENTITYSYSTEM_PROPUPDATE: { //实体属性变更 stPropUpdate prop = (stPropUpdate)param; OnPropUpdate(ref prop); } break; case (int)Client.GameEventID.ENTITYSYSTEM_HPUPDATE: { //实体属性变更 stPropUpdate prop = (stPropUpdate)param; OnPropUpdate(ref prop); } break; case (int)Client.GameEventID.ENTITYSYSTEM_CHANGENAME: { //实体名称改变 stEntityChangename e = (stEntityChangename)param; UpdateHeadStaus(e.uid, HeadStatusType.Name); } break; case (int)Client.GameEventID.ENTITYSYSTEM_SETHIDE: { //实体名称改变 stEntityHide st = (stEntityHide)param; //UpdateHeadStaus(e.uid, HeadStatusType.Name); OnSetEntityHide(ref st); } break; case (int)Client.GameEventID.TITLE_WEAR: { Client.stTitleWear data = (Client.stTitleWear)param; IPlayer player = RoleStateBarManager.GetEntityByUserID <IPlayer>(data.uid); if (null != player) { //佩戴称号 UpdateHeadStaus(player.GetUID(), HeadStatusType.Title); } } break; case (int)Client.GameEventID.SKILLGUIDE_PROGRESSSTART: { //引导技能开始 } break; case (int)Client.GameEventID.SKILLGUIDE_PROGRESSBREAK: { //引导技能中断 } break; case (int)Client.GameEventID.SKILLGUIDE_PROGRESSEND: { //引导技能结束 } break; case (int)Client.GameEventID.CLANQUIT: case (int)Client.GameEventID.CLANJOIN: case (int)Client.GameEventID.CLANREFRESHID: case (int)Client.GameEventID.CITYWARWINERCLANID: case (int)Client.GameEventID.CLANDeclareInfoAdd: case (int)Client.GameEventID.CLANDeclareInfoRemove: { //氏族状态改变 OnRefreshAllClan(); } break; case (int)Client.GameEventID.CITYWARTOTEMCLANNAMECHANGE: { long uid = EntitySystem.EntityHelper.MakeUID(EntityType.EntityType_NPC, (uint)param); UpdateHeadStaus(uid, HeadStatusType.Clan); } break; case (int)Client.GameEventID.SYSTEM_GAME_READY: { OnRefresAllHp(); } break; case (int)Client.GameEventID.CAMERA_MOVE_END: { UpdateAllPos(); } break; case (int)Client.GameEventID.RFRESHENTITYHEADSTATUS: { HeadStatusType status = (HeadStatusType)param; RefreshAllHeadStatus(status); } break; //npc头顶任务状态 case (int)Client.GameEventID.TASK_ACCEPT: { uint taskId = (uint)param; OnUpdateNpcTaskStatus(taskId, Client.GameEventID.TASK_ACCEPT); } break; case (int)Client.GameEventID.TASK_DELETE: { uint taskId = (uint)param; OnUpdateNpcTaskStatus(taskId, Client.GameEventID.TASK_DELETE); } break; case (int)Client.GameEventID.TASK_DONE: { Client.stTaskDone td = (Client.stTaskDone)param; OnUpdateNpcTaskStatus(td.taskid, Client.GameEventID.TASK_DONE); } break; case (int)Client.GameEventID.TASK_CANSUBMIT: { Client.stTaskCanSubmit tcs = (Client.stTaskCanSubmit)param; OnUpdateNpcTaskStatus(tcs.taskid, Client.GameEventID.TASK_CANSUBMIT); } break; case (int)Client.GameEventID.TASK_CANACCEPT: { uint taskId = (uint)param; OnUpdateNpcTaskStatus(taskId, Client.GameEventID.TASK_CANACCEPT); } break; } }
private void UpdateHeadStaus(IEntity entity, HeadStatusType type) { UpdateHeadStaus(entity.GetUID(), type); }
/// <summary> /// 是否实体顶部栏可用 /// </summary> /// <param name="uid"></param> /// <param name="statusType"></param> /// <returns></returns> public static bool IsEntityHeadStatusTypeEnable(long uid, HeadStatusType statusType) { return(IsEntityHeadStatusTypeEnable(GetEntity(uid), statusType)); }
/// <summary> /// 是否实体顶部栏可用 /// </summary> /// <param name="entity"></param> /// <param name="statusType"></param> /// <returns></returns> public static bool IsEntityHeadStatusTypeEnable(IEntity entity, HeadStatusType statusType) { bool enable = false; if (null != entity) { switch (statusType) { case HeadStatusType.Hp: { EntityHpSprite hpSp = RoleStateBarManager.GetEntityHpSpData(entity); if (hpSp != null) { enable = hpSp.bShow; } } break; case HeadStatusType.Name: { enable = PlayerNameEnable; if (entity.GetEntityType() == EntityType.EntityType_NPC) { INPC npc = entity as INPC; enable = npc.WhetherShowHeadTips(); } } break; case HeadStatusType.Clan: { uint clanIdLow = (uint)entity.GetProp((int)CreatureProp.ClanIdLow); uint clanIdHigh = (uint)entity.GetProp((int)CreatureProp.ClanIdHigh); uint clanid = (clanIdHigh << 16) | clanIdLow; enable = ClanNameEnable && (clanid != 0); //enable = ClanNameEnable && ((uint)entity.GetProp((int)CreatureProp.ClanId) != 0); } break; case HeadStatusType.Title: { enable = PlayerTitleEnable && (entity.GetEntityType() == EntityType.EntityType_Player && (uint)entity.GetProp((int)PlayerProp.TitleId) != 0); } break; case HeadStatusType.Collect: { } break; case HeadStatusType.HeadMaskIcon: { enable = IsEntityHaveHeadIconMask(entity); } break; case HeadStatusType.TaskStatus: { if (entity.GetEntityType() == EntityType.EntityType_NPC) { QuestTraceInfo info = null; if (TryGetNPCTraceInfo(entity, out info)) { enable = true; } } } break; case HeadStatusType.CampMask: { int camp = entity.GetProp((int)Client.CreatureProp.Camp); if (camp == (int)GameCmd.eCamp.CF_Green || camp == (int)GameCmd.eCamp.CF_Red) { enable = true; } } break; case HeadStatusType.BossSay: { int baseID = entity.GetProp((int)EntityProp.BaseID); if (baseID == DataManager.Manager <RoleStateBarManager>().GetTalkingBossID()) { enable = DataManager.Manager <RoleStateBarManager>().GetBossTalkVisible(); } else { enable = false; } } break; } } return(enable); }
/// <summary> /// /// </summary> /// <param name="type"></param> public static void RefreshAllRoleBarHeadStatus(HeadStatusType type) { Engine.Utility.EventEngine.Instance().DispatchEvent((int)Client.GameEventID.RFRESHENTITYHEADSTATUS, type); }
/// <summary> /// 更新顶部栏状态 /// </summary> public void UpdateHeadStatus(HeadStatusType type, bool adjustPos = true) { RoleStateBarManager mgr = DataManager.Manager <RoleStateBarManager>(); IEntity entity = RoleStateBarManager.GetEntity(UID); if (null == entity) { return; } Transform widget = GetWidget(type); if (null != widget) { QuestTraceInfo traceInfo = null; bool visible = false; if (type != HeadStatusType.TaskStatus) { visible = RoleStateBarManager.IsEntityHeadStatusTypeEnable(entity, type); } else { if (RoleStateBarManager.TryGetNPCTraceInfo(entity, out traceInfo)) { visible = true; } } if (widget.gameObject.activeSelf != visible) { widget.gameObject.SetActive(visible); } if (type == HeadStatusType.Title && null != m_particleWidget) { m_particleWidget.ReleaseParticle(); } if (visible) { switch (type) { case HeadStatusType.Hp: if (null != m_hpSlider && null != m_spHpbg && null != m_spHpForg) { float hpPer = entity.GetProp((int)CreatureProp.Hp) / (float)entity.GetProp((int)CreatureProp.MaxHp); EntityHpSprite hpSp = RoleStateBarManager.GetEntityHpSpData(entity); if (hpSp != null) { m_spHpbg.spriteName = hpSp.bgSpriteName; m_spHpbg.MakePixelPerfect(); m_spHpForg.spriteName = hpSp.spriteName; m_spHpForg.MakePixelPerfect(); m_hpSlider.gameObject.SetActive(hpSp.bShow); m_hpSlider.value = hpPer; } } break; case HeadStatusType.Name: if (null != m_labName) { m_labName.text = ColorManager.GetColorString(mgr.GetNameColor(entity), entity.GetName()); } break; case HeadStatusType.Clan: if (null != m_labClanName) { Action <string, int> clanNameDlg = (clanName, getNameSeed) => { if (getNameSeed >= m_iGetNameSeed) { //保证先后 //string name = DataManager.Manager<TextManager>().GetLocalFormatText(LocalTextType.Clan_Commond_shizumingzi, clanName); //labelClan.fontSize = data.m_nFontSize; m_labClanName.text = ColorManager.GetColorString(RoleStateBarManager.GetClanNameColor(entity), clanName); } }; RoleStateBarManager.GetRoleBarClanName(entity, clanNameDlg, ++m_iGetNameSeed); } break; case HeadStatusType.Title: if (null != m_labTitle) { table.TitleDataBase titleDb = RoleStateBarManager.GetTitleText(entity); if (null != titleDb) { bool visibleTxt = (titleDb.UIState == 0); if (null != m_labTitle) { if (m_labTitle.gameObject.activeSelf != visibleTxt) { m_labTitle.gameObject.SetActive(visibleTxt); } m_labTitle.text = titleDb.SceneTextUI; } if (null != m_particleWidget) { if (m_particleWidget.gameObject.activeSelf == visibleTxt) { m_particleWidget.gameObject.SetActive(!visibleTxt); } m_particleWidget.AddParticle(titleDb.FxUI, m_particleRelativeWidget); } } } break; case HeadStatusType.Collect: if (null != m_labCollectTips) { m_labCollectTips.color = ColorManager.GetColor32OfType(ColorType.JSXT_CaiJiWu); } break; case HeadStatusType.HeadMaskIcon: if (null != m_spHeadMask) { table.NpcHeadMaskDataBase npcmaskDB = RoleStateBarManager.GetNPCHeadMaskDB(entity); string iconName = (null != npcmaskDB) ? npcmaskDB.headMaskIcon : ""; UIManager.GetAtlasAsyn(iconName, ref m_headCASD, () => { if (null != m_spHeadMask) { m_spHeadMask.atlas = null; } }, m_spHeadMask); } break; case HeadStatusType.TaskStatus: if (null != m_spTaskStatus && null != traceInfo) { long uid = 0; string icon = ""; if (RoleStateBarManager.TryGetQuestStatusIcon(traceInfo, out uid, out icon) && uid == UID) { UIManager.GetAtlasAsyn(icon, ref m_taskCASD, () => { if (null != m_spTaskStatus) { m_spTaskStatus.atlas = null; } }, m_spTaskStatus); } else { widget.gameObject.SetActive(false); } } break; case HeadStatusType.CampMask: { bool isGod = true; int camp = entity.GetProp((int)Client.CreatureProp.Camp); if (camp == (int)GameCmd.eCamp.CF_Red) { isGod = false; } if (null != m_tsDemonMask && m_tsDemonMask.gameObject.activeSelf == isGod) { m_tsDemonMask.gameObject.SetActive(!isGod); } if (null != m_tsGodMask && m_tsGodMask.gameObject.activeSelf != isGod) { m_tsGodMask.gameObject.SetActive(isGod); } } break; case HeadStatusType.BossSay: { uint npcID = DataManager.Manager <RoleStateBarManager>().GetTalkingBossID(); table.BossTalkDataBase db = GameTableManager.Instance.GetTableItem <table.BossTalkDataBase>(npcID); if (db != null) { uint textID = db.textID; table.LangTextDataBase ldb = GameTableManager.Instance.GetTableItem <table.LangTextDataBase>(textID); if (ldb != null) { m_bossText.text = ldb.strText; } m_bossTalk.gameObject.SetActive(visible); } else { m_bossTalk.gameObject.SetActive(false); } } break; } } if (adjustPos) { AdjustStatusPos(); } } }
private Transform GetWidget(HeadStatusType headType) { Transform widget = null; switch (headType) { case HeadStatusType.Name: { widget = m_labName.cachedTransform; } break; case HeadStatusType.HeadMaskIcon: { widget = m_spHeadMask.cachedTransform; } break; case HeadStatusType.Hp: { widget = m_hpSlider.cachedTransform; } break; case HeadStatusType.Title: { widget = m_labTitle.cachedTransform.parent; } break; case HeadStatusType.Clan: { widget = m_labClanName.cachedTransform; } break; case HeadStatusType.Collect: { widget = m_labCollectTips.cachedTransform; } break; case HeadStatusType.TaskStatus: { widget = m_spTaskStatus.cachedTransform; } break; case HeadStatusType.CampMask: { widget = m_tsCampMask; } break; case HeadStatusType.BossSay: { widget = m_bossTalk; } break; default: break; } return(widget); }
/// <summary> /// 初始化 /// </summary> /// <param name="ts"></param> private void InitWidget(Transform ts) { m_tsTran = ts; if (widget == null) { widget = ts.GetComponent <UIWidget>(); } for (HeadStatusType i = HeadStatusType.None + 1; i < HeadStatusType.Max; i++) { Transform child = m_tsTran.Find(i.ToString()); if (child != null) { switch (i) { case HeadStatusType.Name: { m_labName = child.GetComponent <UILabel>(); } break; case HeadStatusType.HeadMaskIcon: { m_spHeadMask = child.GetComponent <UISprite>(); } break; case HeadStatusType.Hp: { m_hpSlider = child.GetComponent <UISlider>(); m_spHpbg = child.Find("bg").GetComponent <UISprite>(); m_spHpForg = child.GetComponent <UISprite>(); } break; case HeadStatusType.Title: { m_labTitle = child.Find("TtitleTxt").GetComponent <UILabel>(); Transform pts = child.Find("ParticleEffect"); if (null != pts) { m_particleWidget = pts.GetComponent <UIParticleWidget>(); if (null == m_particleWidget) { m_particleWidget = pts.gameObject.AddComponent <UIParticleWidget>(); } if (null != m_particleWidget) { m_particleRelativeWidget = m_particleWidget.GetComponent <UISprite>(); } } } break; case HeadStatusType.Clan: { m_labClanName = child.GetComponent <UILabel>(); } break; case HeadStatusType.Collect: { m_labCollectTips = child.GetComponent <UILabel>(); } break; case HeadStatusType.TaskStatus: { m_spTaskStatus = child.GetComponent <UISprite>(); } break; case HeadStatusType.CampMask: { m_tsCampMask = child; if (null != m_tsCampMask) { m_tsGodMask = m_tsCampMask.Find("God"); m_tsDemonMask = m_tsCampMask.Find("Demon"); } } break; case HeadStatusType.BossSay: { m_bossTalk = child; if (m_bossTalk != null) { m_bossText = m_bossTalk.Find("text").GetComponent <UILabel>(); } } break; default: break; } } } if (null != m_hpSlider) { m_v3StartPos = m_hpSlider.cachedTransform.localPosition; } }