using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class MonsterConfigCategory : ProtoObject, IMerge { public static MonsterConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public MonsterConfigCategory() { Instance = this; } public void Merge(object o) { MonsterConfigCategory s = o as MonsterConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (MonsterConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public MonsterConfig Get(int id) { this.dict.TryGetValue(id, out MonsterConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (MonsterConfig)},配置id: {id}"); } return item; } public bool Contain(int id) { return this.dict.ContainsKey(id); } public Dictionary GetAll() { return this.dict; } public List GetList() { return this.list; } public MonsterConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class MonsterConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 怪物名称 [ProtoMember(2)] public string Name { get; set; } /// 等级 [ProtoMember(3)] public int LV { get; set; } /// 生命 [ProtoMember(4)] public int HP { get; set; } /// 攻击 [ProtoMember(5)] public int ATK { get; set; } /// 防御 [ProtoMember(6)] public int DEF { get; set; } /// 攻击速度 [ProtoMember(7)] public int AttackSpeed { get; set; } /// 命中率 [ProtoMember(8)] public int HitRate { get; set; } /// 招架率 [ProtoMember(9)] public int ParryRate { get; set; } /// 闪避率 [ProtoMember(10)] public int DodgeRate { get; set; } /// 移动速度 [ProtoMember(11)] public int MoveSpeed { get; set; } /// 使用武器 [ProtoMember(12)] public int Weapon { get; set; } /// 无武器普通攻击 [ProtoMember(13)] public int UnarmedAttack { get; set; } /// 普通攻击 [ProtoMember(14)] public int NormalAttack { get; set; } /// 技能 [ProtoMember(15)] public int SkillSet { get; set; } /// 经验产出 [ProtoMember(16)] public int EXP { get; set; } /// 修为产出 [ProtoMember(17)] public int Sophisticate { get; set; } /// 物品掉落 [ProtoMember(18)] public int DropGroup { get; set; } } }