public void AddInstruction(Instruction instruction) { if (instruction is EventInstruction eventInstruction) { this.expectedEventActions.Add(new EventActionPair(eventInstruction.GetEvent())); } else if (instruction is ActionInstruction actionInstruction) { if (this.LastEventActionPair.Action != null) { throw new Exception($"Last event action already set with operation {this.LastEventActionPair.Action.Operation}"); } this.LastEventActionPair.Action = actionInstruction; } else if (instruction is PlayerStateInstruction playerStateInstruction) { if (this.LastEventActionPair.Action != null) { throw new Exception($"Last event action already set with operation {this.LastEventActionPair.Action.Operation}"); } this.LastEventActionPair.Action = playerStateInstruction.GetAction(); this.expectedEventActions.Add(new EventActionPair(playerStateInstruction.GetEvent())); } else if (instruction is MultipleEventInstruction multipleEventInstruction) { var eventActionPair = new EventActionPair(); foreach (var gameEvent in multipleEventInstruction.Events) { eventActionPair.Add(gameEvent); } this.expectedEventActions.Add(eventActionPair); } }
public static EventActionPair New() { var dialog = new SelectDualItem( EventActionFactory.AvailableEvents, EventActionFactory.AvailableActions, "New Event and Action Pair", "Event:", "Action:"); dialog.ShowDialog(); if (dialog.SelectedItem1 == null || dialog.SelectedItem2 == null) { return(null); } var newPair = new EventActionPair { Event = EventActionFactory.GetNewEventFromName((string)dialog.SelectedItem1), Action = EventActionFactory.GetNewActionFromName((string)dialog.SelectedItem2) }; newPair.Add(); newPair.Edit(); return(newPair); }
public static void New() { var dialog = new SelectDualItem( EventActionFactory.AvailableEvents, EventActionFactory.AvailableActions, "New Event and Action Pair", "Event:", "Action:"); dialog.ShowDialog(); if (dialog.SelectedItem1 == null || dialog.SelectedItem2 == null) return; var newPair = new EventActionPair { Event = EventActionFactory.GetNewEventFromName((string) dialog.SelectedItem1), Action = EventActionFactory.GetNewActionFromName((string) dialog.SelectedItem2) }; newPair.Add(); newPair.Edit(); }