public override void Read(ByteArray by) { base.Read(by); unit_idx.Read(by); action = (eUnitAttrAction)by.ReadUShort(); type = (eUnitModType)by.ReadUShort(); value = by.ReadString(); }
/// <summary> /// 发给客户端-string /// </summary> /// <param name="type"></param> /// <param name="nValue"></param> private void Send2Client(eUnitModType type, string nValue, eUnitAttrAction action) { Player player = m_owner_unit as Player; if (player == null) { return; } ss2c.NotifyUpdatePlayerAttribString msg = PacketPools.Get(ss2c.msg.UNIT_MODIFY_STRING) as ss2c.NotifyUpdatePlayerAttribString; msg.client_uid = player.client_uid; msg.unit_idx.Set(player.unit_type, player.obj_type, player.char_idx); msg.action = action; msg.type = type; msg.value = nValue; Send2Client(type, msg); }
public virtual bool SetAttribString(eUnitModType type, string nValue, bool sync_db = true, bool sync_client = true, bool sync_ws = true, bool sync_gl = true, bool sync_fs = true, eUnitAttrAction action = eUnitAttrAction.Unknow) { return(false); }
/// <summary> /// 根据Key值改变角色的类型为int的属性 /// </summary> /// <param name="type"></param> /// <param name="nValue"></param> /// <param name="operate"></param> /// <param name="sync_db"></param> /// <param name="sync_client"></param> /// <param name="sync_ws"></param> /// <param name="sync_gl"></param> /// <param name="action"></param> /// <returns></returns> public virtual bool ChangeAttribInteger(eUnitModType type, long nValue, eUnitAttrOperate operate, bool sync_db = true, bool sync_client = true, bool sync_ws = true, bool sync_gl = true, bool sync_fs = true, eUnitAttrAction action = eUnitAttrAction.Unknow) { return(false); }
public bool SetAttrib(eUnitModType type, long nValue, string strValue, bool sync_db = true, bool sync_client = true, bool sync_ws = true, bool sync_gl = true, bool sync_fs = true, eUnitAttrAction action = eUnitAttrAction.Unknow) { Player player = m_owner_unit as Player; if (player == null) { return(false); } switch (type) { case eUnitModType.UMT_char_name: return(SetAttribString(type, strValue, sync_db, sync_client, sync_ws, sync_gl, sync_fs, action)); default: return(SetAttribInteger(type, nValue, sync_db, sync_client, sync_ws, sync_gl, sync_fs, action)); } }
public override bool SetAttribString(eUnitModType type, string nValue, bool sync_db = true, bool sync_client = true, bool sync_ws = true, bool sync_gl = true, bool sync_fs = true, eUnitAttrAction action = eUnitAttrAction.Unknow) { Player player = m_owner_unit as Player; if (player == null) { return(false); } switch (type) { case eUnitModType.UMT_char_name: m_player_info.char_name = nValue; break; default: return(false); } if (sync_client && IsNeedSyncClient(type)) { Send2Client(type, nValue, action); } if (sync_db) { Send2DB(type, nValue); } if (sync_ws && IsNeedSyncWS(type)) { Send2WS(type, nValue); } if (sync_gl && IsNeedSyncGL(type)) { Send2GL(type, nValue); } if (sync_fs && IsNeedSyncFS(type)) { Send2FS(type, nValue); } return(true); }
public override bool ChangeAttribInteger(eUnitModType type, long nValue, eUnitAttrOperate operate, bool sync_db = true, bool sync_client = true, bool sync_ws = true, bool sync_gl = true, bool sync_fs = true, eUnitAttrAction action = eUnitAttrAction.Unknow) { if (nValue == 0) { return(false); } Player player = m_owner_unit as Player; if (player == null) { return(false); } long base_value = this.GetAttribInteger(type); long dst_value = base_value; switch (operate) { case eUnitAttrOperate.Add: dst_value += nValue; break; case eUnitAttrOperate.Sub: dst_value -= nValue; break; case eUnitAttrOperate.Mul: dst_value *= nValue; break; case eUnitAttrOperate.Div: dst_value /= nValue; break; } if (dst_value == base_value) { return(false); } if (sync_client && IsNeedSyncClient(type)) { Send2Client(type, dst_value, action); } if (sync_db) { Send2DB(type, nValue); } if (sync_ws && IsNeedSyncWS(type)) { Send2WS(type, nValue); } if (sync_gl && IsNeedSyncGL(type)) { Send2GL(type, nValue); } if (sync_fs && IsNeedSyncFS(type)) { Send2FS(type, nValue); } return(true); }
public override bool SetAttribInteger(eUnitModType type, long nValue, bool sync_db = true, bool sync_client = true, bool sync_ws = true, bool sync_gl = true, bool sync_fs = true, eUnitAttrAction action = eUnitAttrAction.Unknow) { Player player = m_owner_unit as Player; if (player == null) { return(false); } switch (type) { case eUnitModType.UMT_char_type: m_player_info.char_type = (byte)nValue; break; case eUnitModType.UMT_fs_uid: m_player_info.fs_id = (ushort)nValue; break; case eUnitModType.UMT_flags: m_player_info.flags = (uint)nValue; break; case eUnitModType.UMT_scene_type: m_player_info.scene_type_idx = (uint)nValue; break; case eUnitModType.UMT_model_idx: m_player_info.model_idx = (uint)nValue; break; case eUnitModType.UMT_job: m_player_info.job = (byte)nValue; break; case eUnitModType.UMT_level: m_player_info.level = (ushort)nValue; break; case eUnitModType.UMT_exp: m_player_info.exp = (uint)nValue; break; case eUnitModType.UMT_energy: m_player_info.energy = (uint)nValue; break; case eUnitModType.UMT_gold: m_player_info.gold = (uint)nValue; break; case eUnitModType.UMT_coin: m_player_info.coin = (uint)nValue; break; case eUnitModType.UMT_hp: m_player_info.hp = (uint)nValue; break; case eUnitModType.UMT_vip_grade: m_player_info.vip_grade = (uint)nValue; break; case eUnitModType.UMT_vip_flags: m_player_info.vip_flags = (uint)nValue; break; case eUnitModType.UMT_base_energy: m_player_info.energy = (uint)nValue; break; case eUnitModType.UMT_base_hurt: m_player_info.hurt = (uint)nValue; break; case eUnitModType.UMT_base_run_speed: m_player_info.run_speed = (uint)nValue; break; case eUnitModType.UMT_hp_max: m_player_info.hp_max = (uint)nValue; break; case eUnitModType.UMT_hurt: m_player_info.hurt = (uint)nValue; break; case eUnitModType.UMT_range: m_player_info.range = (uint)nValue; break; case eUnitModType.UMT_run_speed: m_player_info.run_speed = (uint)nValue; break; case eUnitModType.UMT_time_last_login: m_player_info.time_last_login = (long)nValue; break; case eUnitModType.UMT_time_last_logout: m_player_info.time_last_logout = (long)nValue; break; default: return(false); } if (sync_client && IsNeedSyncClient(type)) { Send2Client(type, nValue, action); } if (sync_db) { Send2DB(type, nValue); } if (sync_ws && IsNeedSyncWS(type)) { Send2WS(type, nValue); } if (sync_gl && IsNeedSyncGL(type)) { Send2GL(type, nValue); } if (sync_fs && IsNeedSyncFS(type)) { Send2FS(type, nValue); } return(true); }