/// <summary> /// 创建Buff,以天为单位 /// </summary> /// <param name="template"></param> /// <param name="ValidDate"></param> /// <returns></returns> public static AbstractBuffer CreateBuffer(ItemTemplateInfo template , int ValidDate) { BufferInfo buffer = new BufferInfo(); buffer.BeginDate = DateTime.Now; buffer.ValidDate = ValidDate * 24 * 60; buffer.Value = template.Property2; buffer.Type = template.Property1; buffer.ValidCount = 1; buffer.IsExist = true; return CreateBuffer(buffer); }
public static AbstractBuffer CreateBuffer(BufferInfo info) { AbstractBuffer buffer = null; switch (info.Type) { case 11: buffer = new KickProtectBuffer(info); break; case 12: buffer = new OfferMultipleBuffer(info); break; case 13: buffer = new GPMultipleBuffer(info); break; case 15: buffer = new PropsBuffer(info); break; } return buffer; }
public OfferMultipleBuffer(BufferInfo info) : base(info) { }
public void HandleGameRoomCreate(GSPacketIn pkg) { int roomId = pkg.ReadInt(); int gameType = pkg.ReadInt(); int guildId = pkg.ReadInt(); int count = pkg.ReadInt(); int totalLevel = 0; IGamePlayer[] players = new IGamePlayer[count]; for (int i = 0; i < count; i++) { PlayerInfo info = new PlayerInfo(); info.ID = pkg.ReadInt(); info.NickName = pkg.ReadString(); info.Sex = pkg.ReadBoolean(); info.Hide = pkg.ReadInt(); info.Style = pkg.ReadString(); info.Colors = pkg.ReadString(); info.Skin = pkg.ReadString(); info.Offer = pkg.ReadInt(); info.GP = pkg.ReadInt(); info.Grade = pkg.ReadInt(); info.Repute = pkg.ReadInt(); info.ConsortiaID = pkg.ReadInt(); info.ConsortiaName = pkg.ReadString(); info.ConsortiaLevel = pkg.ReadInt(); info.ConsortiaRepute = pkg.ReadInt(); info.Attack = pkg.ReadInt(); info.Defence = pkg.ReadInt(); info.Agility = pkg.ReadInt(); info.Luck = pkg.ReadInt(); double baseAttack = pkg.ReadDouble(); double baseDefence = pkg.ReadDouble(); double baseAgility = pkg.ReadDouble(); double baseBlood = pkg.ReadDouble(); int templateId = pkg.ReadInt(); bool canUserProp = pkg.ReadBoolean(); int secondWeapon = pkg.ReadInt(); int strengthLevel = pkg.ReadInt(); double gprate = pkg.ReadDouble(); double offerrate = pkg.ReadDouble(); double rate = pkg.ReadDouble(); int serverid = pkg.ReadInt(); ItemTemplateInfo itemTemplate = ItemMgr.FindItemTemplate(templateId); ItemInfo item = null; if (secondWeapon != 0) { ItemTemplateInfo secondWeaponTemp = ItemMgr.FindItemTemplate(secondWeapon); item = ItemInfo.CreateFromTemplate(secondWeaponTemp, 1, 1); item.StrengthenLevel = strengthLevel; } List<BufferInfo> infos = new List<BufferInfo>(); int buffercout = pkg.ReadInt(); for (int j = 0; j < buffercout; j++) { BufferInfo buffinfo = new BufferInfo(); buffinfo.Type = pkg.ReadInt(); buffinfo.IsExist = pkg.ReadBoolean(); buffinfo.BeginDate = pkg.ReadDateTime(); buffinfo.ValidDate = pkg.ReadInt(); buffinfo.Value = pkg.ReadInt(); if (info != null) infos.Add(buffinfo); } players[i] = new ProxyPlayer(this, info, itemTemplate, item, baseAttack, baseDefence, baseAgility, baseBlood, gprate, offerrate, rate, infos, serverid); players[i].CanUseProp = canUserProp; int ec = pkg.ReadInt(); for (int j = 0; j < ec; j++) { players[i].EquipEffect.Add(pkg.ReadInt()); } totalLevel += info.Grade; } ProxyRoom room = new ProxyRoom(ProxyRoomMgr.NextRoomId(), roomId, players, this); room.GuildId = guildId; room.GameType = (eGameType)gameType; lock (m_rooms) { if (!m_rooms.ContainsKey(roomId)) { m_rooms.Add(roomId, room); } else { room = null; } } if (room != null) { ProxyRoomMgr.AddRoom(room); } else { log.ErrorFormat("Room already exists:{0}", roomId); } }
public GSPacketIn SendUpdateBuffer(GamePlayer player, BufferInfo[] infos) { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.BUFF_UPDATE, player.PlayerId); pkg.WriteInt(infos.Length); foreach (BufferInfo info in infos) { pkg.WriteInt(info.Type); pkg.WriteBoolean(info.IsExist); pkg.WriteDateTime(info.BeginDate); pkg.WriteInt(info.ValidDate); pkg.WriteInt(info.Value); } SendTCP(pkg); return pkg; }
public bool SaveBuffer(BufferInfo info) { bool flag = false; try { flag = this.db.RunProcedure("SP_User_Buff_Add", new SqlParameter[9] { new SqlParameter("@UserID", (object) info.UserID), new SqlParameter("@Type", (object) info.Type), new SqlParameter("@BeginDate", (object) info.BeginDate), new SqlParameter("@Data", info.Data == null ? (object) "" : (object) info.Data), new SqlParameter("@IsExist", (object) (int) (info.IsExist ? 1 : 0)), new SqlParameter("@ValidDate", (object) info.ValidDate), new SqlParameter("@Value", (object) info.Value), new SqlParameter("@Value", (object) info.ValidCount), new SqlParameter("@TemplateID", (object) info.TemplateID) }); info.IsDirty = false; } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } return flag; }
public BufferInfo[] GetUserBuffer(int userID) { List<BufferInfo> list1 = new List<BufferInfo>(); SqlDataReader ResultDataReader = (SqlDataReader)null; try { SqlParameter[] SqlParameters = new SqlParameter[1] { new SqlParameter("@UserID", SqlDbType.Int, 4) }; SqlParameters[0].Value = (object)userID; this.db.GetReader(ref ResultDataReader, "SP_User_Buff_All", SqlParameters); while (ResultDataReader.Read()) { List<BufferInfo> list2 = list1; BufferInfo bufferInfo1 = new BufferInfo(); bufferInfo1.BeginDate = (DateTime)ResultDataReader["BeginDate"]; bufferInfo1.Data = ResultDataReader["Data"] == null ? "" : ResultDataReader["Data"].ToString(); bufferInfo1.Type = (int)ResultDataReader["Type"]; bufferInfo1.UserID = (int)ResultDataReader["UserID"]; bufferInfo1.ValidDate = (int)ResultDataReader["ValidDate"]; bufferInfo1.Value = (int)ResultDataReader["Value"]; bufferInfo1.IsExist = (bool)ResultDataReader["IsExist"]; bufferInfo1.ValidCount = (int)ResultDataReader["ValidCount"]; bufferInfo1.TemplateID = (int)ResultDataReader["TemplateID"]; bufferInfo1.IsDirty = false; BufferInfo bufferInfo2 = bufferInfo1; list2.Add(bufferInfo2); } } catch (Exception ex) { if (BaseBussiness.log.IsErrorEnabled) BaseBussiness.log.Error((object)"Init", ex); } finally { if (ResultDataReader != null && !ResultDataReader.IsClosed) ResultDataReader.Close(); } return list1.ToArray(); }
public PropsBuffer(BufferInfo buffer) : base(buffer) { }
public KickProtectBuffer(BufferInfo info) : base(info) { }
public AbstractBuffer(BufferInfo info) { m_info = info; }
public bool SaveBuffer(BufferInfo info) { bool result = false; try { SqlParameter[] para = new SqlParameter[7]; para[0] = new SqlParameter("@UserID", info.UserID); para[1] = new SqlParameter("@Type", info.Type); para[2] = new SqlParameter("@BeginDate", info.BeginDate); para[3] = new SqlParameter("@Data", info.Data == null ? "" : info.Data); para[4] = new SqlParameter("@IsExist", info.IsExist); para[5] = new SqlParameter("@ValidDate", info.ValidDate); para[6] = new SqlParameter("@Value", info.Value); result = db.RunProcedure("SP_User_Buff_Add", para); info.IsDirty = false; } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { } return result; }
public BufferInfo[] GetUserBuffer(int userID) { List<BufferInfo> infos = new List<BufferInfo>(); SqlDataReader reader = null; try { SqlParameter[] para = new SqlParameter[1]; para[0] = new SqlParameter("@UserID", SqlDbType.Int, 4); para[0].Value = userID; db.GetReader(ref reader, "SP_User_Buff_All", para); while (reader.Read()) { BufferInfo info = new BufferInfo(); info.BeginDate = (DateTime)reader["BeginDate"]; info.Data = reader["Data"] == null ? "" : reader["Data"].ToString(); info.Type = (int)reader["Type"]; info.UserID = (int)reader["UserID"]; info.ValidDate = (int)reader["ValidDate"]; info.Value = (int)reader["Value"]; info.IsExist = (bool)reader["IsExist"]; info.IsDirty = false; infos.Add(info); } } catch (Exception e) { if (log.IsErrorEnabled) log.Error("Init", e); } finally { if (reader != null && !reader.IsClosed) reader.Close(); } return infos.ToArray(); }
public static XElement CreateBuffInfo(BufferInfo info) { return new XElement("Item", new XAttribute("BeginDate", info.BeginDate.ToString("yyyy-MM-dd HH:mm:ss")), new XAttribute("Data", info.Data == null ? "" : info.Data), new XAttribute("IsExist", info.IsExist), new XAttribute("Type", info.Type), new XAttribute("UserID", info.UserID), new XAttribute("ValidDate", info.ValidDate), new XAttribute("Value", info.Value)); }