/// <summary> /// 解析游戏动作 /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionEvent Resolve(ActionEventID id) { if (this.actionEventDict.TryGetValue(id, out var result) == false) { throw new ArgumentException($"动作事件ID{id}未注册"); } return((IActionEvent)Activator.CreateInstance(result.GetType())); }
/// <summary> /// 游戏动作事件ID /// </summary> /// <param name="uid">游戏动作ID</param> /// <param name="conditionsActions">条件动作组</param> /// <param name="executionActions">执行动作组</param> public BaseActionEvent( ActionEventID uid, List <IConditAction> conditionsActions = null, List <IExecuteAction> executionActions = null) { this.UID = uid; this.ConditionsActions = conditionsActions ?? new List <IConditAction> { new ActionPointConstraint() { ActionConfig = 2 }, new RangeConstraint() { ActionConfig = 2 }, }; this.ExecutionActions = executionActions ?? new List <IExecuteAction>(); }
/// 单例构造函数 /// </summary> private ActionEventContainer() { IEqualityComparer <ActionEventID> comparer = new ActionEventID(); this.actionEventDict = new ConcurrentDictionary <ActionEventID, IActionEvent>(comparer); }