using System; using System.Collections.Generic; using MongoDB.Bson.Serialization.Attributes; using ProtoBuf; namespace ET { [ProtoContract] [Config] public partial class SkillUpConfigCategory : ProtoObject, IMerge { public static SkillUpConfigCategory Instance; [ProtoIgnore] [BsonIgnore] private Dictionary dict = new Dictionary(); [BsonElement] [ProtoMember(1)] private List list = new List(); public SkillUpConfigCategory() { Instance = this; } public void Merge(object o) { SkillUpConfigCategory s = o as SkillUpConfigCategory; this.list.AddRange(s.list); } public override void EndInit() { foreach (SkillUpConfig config in list) { config.EndInit(); this.dict.Add(config.Id, config); } this.AfterEndInit(); } public SkillUpConfig Get(int id) { this.dict.TryGetValue(id, out SkillUpConfig item); if (item == null) { throw new Exception($"配置找不到,配置表名: {nameof (SkillUpConfig)},配置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 SkillUpConfig GetOne() { if (this.dict == null || this.dict.Count <= 0) { return null; } return this.dict.Values.GetEnumerator().Current; } } [ProtoContract] public partial class SkillUpConfig: ProtoObject, IConfig { /// 编号 [ProtoMember(1)] public int Id { get; set; } /// 技能ID [ProtoMember(2)] public int SkillId { get; set; } /// 1级解锁 [ProtoMember(3)] public int[] Level1UnlockParameter { get; set; } /// 2级解锁 [ProtoMember(4)] public int[] Level2UnlockParameter { get; set; } /// 3级解锁 [ProtoMember(5)] public int[] Level3UnlockParameter { get; set; } /// 4级解锁 [ProtoMember(6)] public int[] Level4UnlockParameter { get; set; } /// 5级解锁 [ProtoMember(7)] public int[] Level5UnlockParameter { get; set; } /// 6级解锁 [ProtoMember(8)] public int[] Level6UnlockParameter { get; set; } /// 7级解锁 [ProtoMember(9)] public int[] Level7UnlockParameter { get; set; } /// 8级解锁 [ProtoMember(10)] public int[] Level8UnlockParameter { get; set; } /// 9级解锁 [ProtoMember(11)] public int[] Level9UnlockParameter { get; set; } /// 10级解锁 [ProtoMember(12)] public int[] Level10UnlockParameter { get; set; } } }