You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.2 KiB
121 lines
3.2 KiB
using System; |
|
using System.Collections.Generic; |
|
using MongoDB.Bson.Serialization.Attributes; |
|
using ProtoBuf; |
|
|
|
namespace ET |
|
{ |
|
[ProtoContract] |
|
[Config] |
|
public partial class MissionConfigCategory : ProtoObject, IMerge |
|
{ |
|
public static MissionConfigCategory Instance; |
|
|
|
[ProtoIgnore] |
|
[BsonIgnore] |
|
private Dictionary<int, MissionConfig> dict = new Dictionary<int, MissionConfig>(); |
|
|
|
[BsonElement] |
|
[ProtoMember(1)] |
|
private List<MissionConfig> list = new List<MissionConfig>(); |
|
|
|
public MissionConfigCategory() |
|
{ |
|
Instance = this; |
|
} |
|
|
|
public void Merge(object o) |
|
{ |
|
MissionConfigCategory s = o as MissionConfigCategory; |
|
this.list.AddRange(s.list); |
|
} |
|
|
|
public override void EndInit() |
|
{ |
|
foreach (MissionConfig config in list) |
|
{ |
|
config.EndInit(); |
|
this.dict.Add(config.Id, config); |
|
} |
|
this.AfterEndInit(); |
|
} |
|
|
|
public MissionConfig Get(int id) |
|
{ |
|
this.dict.TryGetValue(id, out MissionConfig item); |
|
|
|
if (item == null) |
|
{ |
|
throw new Exception($"配置找不到,配置表名: {nameof (MissionConfig)},配置id: {id}"); |
|
} |
|
|
|
return item; |
|
} |
|
|
|
public bool Contain(int id) |
|
{ |
|
return this.dict.ContainsKey(id); |
|
} |
|
|
|
public Dictionary<int, MissionConfig> GetAll() |
|
{ |
|
return this.dict; |
|
} |
|
|
|
public List<MissionConfig> GetList() |
|
{ |
|
return this.list; |
|
} |
|
|
|
public MissionConfig GetOne() |
|
{ |
|
if (this.dict == null || this.dict.Count <= 0) |
|
{ |
|
return null; |
|
} |
|
return this.dict.Values.GetEnumerator().Current; |
|
} |
|
} |
|
|
|
[ProtoContract] |
|
public partial class MissionConfig: ProtoObject, IConfig |
|
{ |
|
/// <summary>编号</summary> |
|
[ProtoMember(1)] |
|
public int Id { get; set; } |
|
/// <summary>标题</summary> |
|
[ProtoMember(2)] |
|
public string Title { get; set; } |
|
/// <summary>任务简述</summary> |
|
[ProtoMember(3)] |
|
public string MissionShortDescription { get; set; } |
|
/// <summary>完成类型</summary> |
|
[ProtoMember(4)] |
|
public int CompletionType { get; set; } |
|
/// <summary>目标类型</summary> |
|
[ProtoMember(5)] |
|
public int[] ChildMission { get; set; } |
|
/// <summary>目标参数</summary> |
|
[ProtoMember(6)] |
|
public int[] MissionReward { get; set; } |
|
/// <summary>目标进度</summary> |
|
[ProtoMember(7)] |
|
public int[] TimeLimitType { get; set; } |
|
/// <summary>任务对白</summary> |
|
[ProtoMember(8)] |
|
public int[] MissionDialogue { get; set; } |
|
/// <summary>奖励类型</summary> |
|
[ProtoMember(9)] |
|
public int[] RewardType { get; set; } |
|
/// <summary>具体物品</summary> |
|
[ProtoMember(10)] |
|
public int[] RewardItem { get; set; } |
|
/// <summary>奖励数量</summary> |
|
[ProtoMember(11)] |
|
public int[] ItemAccount { get; set; } |
|
/// <summary>任务描述</summary> |
|
[ProtoMember(12)] |
|
public string MissionDescription { get; set; } |
|
|
|
} |
|
}
|
|
|