123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections.Generic;
- using MongoDB.Bson.Serialization.Attributes;
- using ProtoBuf;
- namespace ET
- {
- [ProtoContract]
- [Config]
- public partial class CharacterConfigCategory : ConfigSingleton<CharacterConfigCategory>, IMerge
- {
- [ProtoIgnore]
- [BsonIgnore]
- private Dictionary<int, CharacterConfig> dict = new Dictionary<int, CharacterConfig>();
-
- [BsonElement]
- [ProtoMember(1)]
- private List<CharacterConfig> list = new List<CharacterConfig>();
-
- public void Merge(object o)
- {
- CharacterConfigCategory s = o as CharacterConfigCategory;
- this.list.AddRange(s.list);
- }
-
- [ProtoAfterDeserialization]
- public void ProtoEndInit()
- {
- foreach (CharacterConfig config in list)
- {
- config.AfterEndInit();
- this.dict.Add(config.Id, config);
- }
- this.list.Clear();
-
- this.AfterEndInit();
- }
-
- public CharacterConfig Get(int id)
- {
- this.dict.TryGetValue(id, out CharacterConfig item);
- if (item == null)
- {
- throw new Exception($"配置找不到,配置表名: {nameof (CharacterConfig)},配置id: {id}");
- }
- return item;
- }
-
- public bool Contain(int id)
- {
- return this.dict.ContainsKey(id);
- }
- public Dictionary<int, CharacterConfig> GetAll()
- {
- return this.dict;
- }
- public CharacterConfig GetOne()
- {
- if (this.dict == null || this.dict.Count <= 0)
- {
- return null;
- }
- return this.dict.Values.GetEnumerator().Current;
- }
- }
- [ProtoContract]
- public partial class CharacterConfig: ProtoObject, IConfig
- {
- /// <summary>Id</summary>
- [ProtoMember(1)]
- public int Id { get; set; }
- /// <summary>职业名称</summary>
- [ProtoMember(2)]
- public string ProName { get; set; }
- /// <summary>职业ID</summary>
- [ProtoMember(3)]
- public int Pro { get; set; }
- /// <summary>单位模板id</summary>
- [ProtoMember(4)]
- public int TemplateId { get; set; }
- /// <summary>等级上限</summary>
- [ProtoMember(5)]
- public int FinalLevel { get; set; }
- /// <summary>初始等级</summary>
- [ProtoMember(6)]
- public int InitLevel { get; set; }
- /// <summary>初始生命</summary>
- [ProtoMember(7)]
- public int InitMaxHP { get; set; }
- /// <summary>初始攻击</summary>
- [ProtoMember(8)]
- public int InitAttack { get; set; }
- /// <summary>基础攻速</summary>
- [ProtoMember(9)]
- public int BaseAtkSpeed { get; set; }
- /// <summary>基础移动速度</summary>
- [ProtoMember(10)]
- public int BaseMoveSpeed { get; set; }
- /// <summary>基础移速值</summary>
- [ProtoMember(11)]
- public string InitSpeed { get; set; }
- /// <summary>初始技能列表</summary>
- [ProtoMember(12)]
- public string InitSkill { get; set; }
- }
- }
|