private void ProcessMoney(S2CMoney s2cMoney) { string text = string.Empty; bool is_change = false; bool show_cost_or_add_tips = false; int change_money = 0; foreach (PkgMoneyInfo money in s2cMoney.info) { show_cost_or_add_tips = false; text = string.Empty; switch (money.money_type) { case GameConst.MONEY_COIN: { if (Coin != money.num) { show_cost_or_add_tips = true; change_money = (int)(money.num) - (int)(Coin); Coin = money.num; is_change = true; } break; } case GameConst.MONEY_TRIGRAM_SP: { if (TrigramSp != money.num) { if (TrigramSp < money.num) { uint add_sp = money.num - TrigramSp; var localplayer = Game.Instance.GetLocalPlayer(); if (localplayer != null) { localplayer.ShowDamageEffect(FightEffectHelp.FightEffectType.AddSp, 0, (int)(add_sp)); } } TrigramSp = money.num; is_change = true; } break; } case GameConst.MONEY_DIAMOND: { if (Diamond != money.num) { show_cost_or_add_tips = true; change_money = (int)(money.num) - (int)(Diamond); Diamond = money.num; is_change = true; } break; } case GameConst.MONEY_SOUL_CREAM: { if (SoulCream != money.num) { show_cost_or_add_tips = true; change_money = (int)(money.num) - (int)(SoulCream); SoulCream = money.num; is_change = true; } break; } case GameConst.MONEY_SOUL_HOLY_WATER: { if (SoulHolyWater != money.num) { show_cost_or_add_tips = true; change_money = (int)(money.num) - (int)(SoulHolyWater); SoulHolyWater = money.num; is_change = true; } break; } case GameConst.MONEY_COIN_BIND: { if (BindCoin != money.num) { BindCoin = money.num; is_change = true; } break; } case GameConst.MONEY_DIAMOND_BIND: { if (BindDiamond != money.num) { show_cost_or_add_tips = true; change_money = (int)(money.num) - (int)(BindDiamond); BindDiamond = money.num; is_change = true; } break; } case GameConst.MONEY_HANG_TIME: { if (HangTime != money.num) { show_cost_or_add_tips = true; int value = Mathf.Abs((int)HangTime - (int)money.num); string str = CommonTool.SecondsToStr_2(value); if (HangTime > money.num) { text = string.Format(DBConstText.GetText("BAG_LOST_HANG_TIME"), str); } else { text = string.Format(DBConstText.GetText("BAG_GET_HANG_TIME"), str); } HangTime = money.num; is_change = true; ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_OFFLINE_HANGE_TIME_UPDATE, null); } break; } default: { uint old_num = 0; if (MoneyData.ContainsKey((ushort)money.money_type)) { old_num = MoneyData[(ushort)money.money_type]; } MoneyData[(ushort)money.money_type] = money.num; if (old_num != money.num) { if (old_num < money.num) //获得货币 { var info = DBMoney.Instance.GetMoneyInfo(money.money_type); if (info != null) { show_cost_or_add_tips = info.show_get; } change_money = (int)(money.num - old_num); } is_change = true; } break; } } if (Game.Instance.AllSystemInited) { if (s2cMoney.op == GameConst.MONEY_OPERATE_NO_TIP) { show_cost_or_add_tips = false; //一定不飘字 } if (show_cost_or_add_tips && string.IsNullOrEmpty(text)) { string goods_name = GoodsHelper.GetGoodsNameByTypeId_blackBkg(money.money_type); if (change_money > 0) { text = string.Format(DBConstText.GetText("COMMON_ADD_ONE_MONEY_NUM"), goods_name, change_money); } } if (string.IsNullOrEmpty(text) == false) { UINotice.Instance.ShowMessage(text); } } } if (is_change == false) { return; } ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_MONEY_UPDATE, null); }
private void HandleServerData(ushort protocol, byte[] data) { Actor localActor = Game.GetInstance().GetLocalPlayer(); switch (protocol) { case NetMsg.MSG_ACC_GET_RAND_NAME: //获取随机名字 { S2CAccGetRandName s2cRandName = S2CPackBase.DeserializePack <S2CAccGetRandName>(data); string roleName = System.Text.Encoding.UTF8.GetString(s2cRandName.name); ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_RANDNAME_UPDATE, new CEventBaseArgs(roleName)); } break; case NetMsg.MSG_PLAYER_SYNC_ATTRS: //同步属性 { var sync_attr = S2CPackBase.DeserializePack <S2CPlayerSyncAttrs>(data); ProcessCharacterInfo(sync_attr); ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.EC_PLAYER_ATTRS_UPDATE, new CEventBaseArgs()); } break; case NetMsg.MSG_NWAR_BUFF_ADD_EN: //多人副本中的Buff加蓝 { var packData = S2CPackBase.DeserializePack <S2CNwarBuffAddEn>(data); Actor act = Game.GetInstance().GetLocalPlayer(); if (act != null && !act.IsDead() && act.UID.obj_idx == packData.uuid) { act.ShowDamageEffect(FightEffectHelp.FightEffectType.AddMp, 0, (int)packData.en); } } break; case NetMsg.MSG_NWAR_HP: //玩家血量 { S2CNwarHp rep = S2CPackBase.DeserializePack <S2CNwarHp>(data); if (rep.uuid == Game.GetInstance().LocalPlayerID.obj_idx) { if (LocalActorAttribute != null) { LocalActorAttribute.HP = rep.hp; } } Actor act = ActorManager.Instance.GetPlayer(rep.uuid); if (act != null) { act.CurLife = rep.hp; if (act.FullLife < rep.hp) { act.FullLife = rep.hp; } } if (rep.uuid == Game.GetInstance().LocalPlayerID.obj_idx) { ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCAL_PLAYER_NWAR_CHANGED, new CEventEventParamArgs("hp", rep.hp)); } } break; case NetMsg.MSG_NWAR_EN: //玩家蓝量 { S2CNwarEn rep = S2CPackBase.DeserializePack <S2CNwarEn>(data); if (rep.uuid == Game.GetInstance().LocalPlayerID.obj_idx) { if (LocalActorAttribute != null) { LocalActorAttribute.MP = rep.en; } ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_LOCAL_PLAYER_NWAR_CHANGED, new CEventEventParamArgs("en", rep.en)); } Actor act = ActorManager.Instance.GetPlayer(rep.uuid); if (act != null) { act.CurMp = rep.en; if (act.FullMp < rep.en) { act.FullMp = rep.en; } } } break; case NetMsg.MSG_NWAR_FURY: // 同步怒气数值 { var msg_fury = S2CPackBase.DeserializePack <S2CNwarFury>(data); Fury = msg_fury.fury; } break; case NetMsg.MSG_PLAYER_LV_EXP: //同步等级和经验 { var lv_exp = S2CPackBase.DeserializePack <S2CPlayerLvExp>(data); ProcessCharacterInfo(lv_exp); } break; case NetMsg.MSG_MONEY: //货币信息 { S2CMoney s2cMoney = S2CPackBase.DeserializePack <S2CMoney>(data); ProcessMoney(s2cMoney); } break; case NetMsg.MSG_PLAYER_WLV: //世界等级 { S2CPlayerWlv s2cPlayerWlv = S2CPackBase.DeserializePack <S2CPlayerWlv>(data); WorldLevel = s2cPlayerWlv.wlv; LimitLevel = s2cPlayerWlv.limit_lv; HiBreak = s2cPlayerWlv.limit_hilv; ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_WORLD_LEVEL_UPDATE, null); } break; case NetMsg.MSG_PLAYER_CHANGE_NAME: //改名 { S2CPlayerChangeName s2cPlayerChangName = S2CPackBase.DeserializePack <S2CPlayerChangeName>(data); Game.GetInstance().LocalPlayerName = System.Text.Encoding.UTF8.GetString(s2cPlayerChangName.name); UINotice.Instance.ShowMessage(DBConstText.GetText("ROLE_RENAME_SUCC") + Game.GetInstance().LocalPlayerName); ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.CE_ACTOR_BASEINFO_UPDATE, new CEventActorArgs(localActor)); } break; case NetMsg.MSG_PLAYER_LVPOINT_INFO: //等级加点信息 { var msg = S2CPackBase.DeserializePack <S2CPlayerLvpointInfo>(data); ReaminLvPoint = msg.remain; ClientEventMgr.GetInstance().FireEvent((int)ClientEvent.EC_PLAYER_LV_POINT_UPDATE, new CEventBaseArgs()); } break; case NetMsg.MSG_GOODS_ADD_HP: //物品加血 { var rep = S2CPackBase.DeserializePack <S2CGoodsAddHp>(data); Actor act = Game.GetInstance().GetLocalPlayer(); if (act != null && !act.IsDead()) { act.ShowDamageEffect(FightEffectHelp.FightEffectType.AddHp, 0, (int)rep.hp); } } break; } }