예제 #1
0
파일: World.cs 프로젝트: JIy3AHKO/TaskMgr
 private void AddAction(BaseAction action)
 {
     if (action != null)
     {
         PendingActions.Add(action);
     }
 }
예제 #2
0
        public static BaseAction ValidateAction(BaseAction action)
        {
            var resultAction = CheckOutcomeConditions(action);
            resultAction = CheckIncomeConditions(resultAction);

            return resultAction;
        }
예제 #3
0
 private static BaseAction CheckOutcomeConditions(BaseAction action)
 {
     BaseAction result = action;
     if (action.Source.Conditions == null) return result;
     foreach (ICondition condition in action.Source.Conditions.OrderBy(x => x.Priority))
         result = condition.TransformOutcomeAction(result);
     return result;
 }
예제 #4
0
 public void Observe(BaseAction action, World world)
 {
     foreach (var gameEvent in Events)
     {
         if (gameEvent.Condition(action, world))
         {
             gameEvent.Reaction();
         }
     }
 }
예제 #5
0
 public virtual BaseAction TransformOutcomeAction(BaseAction action)
 {
     return action;
 }
예제 #6
0
 public abstract BaseAction TransformOutcomeAction(BaseAction action);
예제 #7
0
 private static BaseAction CheckIncomeConditions(BaseAction action)
 {
     var resultAction = action;
     if (resultAction as ISingleTargetAffecter == null) return action;
     return (action as ISingleTargetAffecter).Target.Conditions.OrderBy(x => x.Priority).Aggregate(resultAction, (current, condition) => condition.TransformIncomeAction(current));
 }