public void Clear() { UnitId = null; if (Attribute != null) { Attribute.Clear(); Attribute = null; } }
public void ProcessCharacterInfo(S2CPlayerSyncAttrs attrs) { // 有变化的属性 ActorAttribute actorAttributeOffset = new ActorAttribute(); actorAttributeOffset.Clear(); // 同步服务端数据 foreach (PkgAttrElm attrElm in attrs.attr_elm) { // 属性赋值 IActorAttribute attr = null; if (LocalActorAttribute.Attribute.TryGetValue(attrElm.attr, out attr)) { if ((ushort)attrElm.attr != GameConst.AR_BAT_PW) { // 属性增加才显示 if (attrElm.value > attr.Value) { actorAttributeOffset.Add(attrElm.attr, attrElm.value - attr.Value); } } attr.Value = attrElm.value; } else { if ((ushort)attrElm.attr != GameConst.AR_BAT_PW) { actorAttributeOffset.Add(attrElm.attr, attrElm.value); } //包含其他字段赋值 LocalActorAttribute.Attribute.Add(attrElm.attr, attrElm.value); } if ((ushort)attrElm.attr == GameConst.AR_BAT_PW)//战斗力赋值 { long new_battlepower = attrElm.value; long delta = new_battlepower - mLastBattlePower; if (new_battlepower != 0 && mLastBattlePower != 0) { //if (delta > 0) if (delta != 0) { TryShowFightRankAnim(delta); } } mLastBattlePower = new_battlepower; LocalActorAttribute.BattlePower = new_battlepower; if (delta != 0) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCALPLAYER_BATTLE_POWER_CHANGED, null); } } // 移动速度的同步需要特殊处理 Actor actor = Game.GetInstance().GetLocalPlayer(); if (null != actor) { if ((ushort)attrElm.attr == GameConst.AR_SPEED || (ushort)attrElm.attr == GameConst.AR_SPEED_ADD) { actor.SetMoveSpeedScale(LocalActorAttribute.MoveSpeedScale * GlobalConst.AttrConvert, LocalActorAttribute.MoveSpeedAdd); } } } if (mUpdateTipsShowLevelRange == null) { mUpdateTipsShowLevelRange = GameConstHelper.GetUintList("GAME_ATTR_UPDATE_TIPS_SHOW_LEVEL_RANGE"); } if (mUpdateTipsShowReasons == null) { mUpdateTipsShowReasons = GameConstHelper.GetUintList("GAME_ATTR_UPDATE_TIPS_SHOW_REASONS"); } bool meetShowReason = false; foreach (uint reason in mUpdateTipsShowReasons) { if (reason == attrs.reason) { meetShowReason = true; } } if (meetShowReason == true && Level >= mUpdateTipsShowLevelRange[0] && Level <= mUpdateTipsShowLevelRange[1] && attrs.init != 1 && actorAttributeOffset.Count > 0) { // 属性变化界面的弹出,如果战力提升界面正在显示,则等该界面关闭后再弹出属性变化界面 if (xc.ui.ugui.UIManager.Instance.GetExistingWindow("UIAttributeTipsWindow") != null) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_SHOW_ATTRS_UPDATE_WINDOW, new CEventBaseArgs(actorAttributeOffset)); } else { xc.ui.ugui.UIManager.Instance.ShowWindow("UIAttributeTipsWindow", actorAttributeOffset); } } // 设置本地玩家的属性 Actor local_player = Game.GetInstance().GetLocalPlayer(); if (null != local_player) { bool need_update_hp = false; if (mLastHp != LocalActorAttribute.HP || mLastHpMax != LocalActorAttribute.HPMax) { need_update_hp = true; mLastHp = LocalActorAttribute.HP; mLastHpMax = LocalActorAttribute.HPMax; } local_player.SetActorAttribute(LocalActorAttribute); ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_ACTOR_BASEINFO_UPDATE, new CEventActorArgs(local_player)); if (need_update_hp) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCAL_PLAYER_NWAR_CHANGED, new CEventEventParamArgs("hp", LocalActorAttribute.HP)); local_player.CurLife = local_player.CurLife;// 强制更新下当前血量, 发送相关的消息 local_player.FullLife = LocalActorAttribute.HPMax; } } }