/// <summary> /// Setup to play the time line. /// </summary> /// <param name="playerOneTimeLine"> /// The Player One timeline. /// </param> /// <param name="playerTwoTimeLine"> /// The Player Two timeline. /// </param> /// <param name="repeatAmount"> /// The number of times to repeat the timeline. /// </param> public void PlayTimeLine( TimeLineViewModel playerOneTimeLine, TimeLineViewModel playerTwoTimeLine, int repeatAmount) { if (!DelayPlayBack()) { return; } // if we aren't in a match (defined by being on a menu or pause is selected) the play timeline stops. if (_inMatch) { while (repeatAmount > 0) { TwoPlayerAction(playerOneTimeLine, playerTwoTimeLine); repeatAmount--; } } else { string message = "The combo trainer has detected that SF4 didn't produce any new frames in the last 3 seconds. Make sure that\n\na) Street Fighter 4 is running and inside a match or training mode\nb) Street Fighter is not paused\nc) You are running the latest version of Street Fighter 4 AEv2012\nd) Stage Quality in your SF4 graphic settings is set to HIGH"; MessageBox.Show(message); } ReleaseAll(); }
/// <summary> /// Initializes a new instance of the <see cref="TimeLineItemViewModel"/> class. /// </summary> /// <param name="parent">The parent <see cref="TimeLineViewModel"/>.</param> public TimeLineItemViewModel(TimeLineViewModel parent) { _parent = parent; _inputItemViewModel = new InputItemViewModel(); InputItemViewModel.PropertyChanged += InputItemViewModel_PropertyChanged; _inputItemViewModel.WaitFrames = 1; }
/// <summary> /// Initializes a new instance of the <see cref="ComboTrainerViewModel"/> class. /// </summary> /// <param name="events">The event aggregator.</param> public ComboTrainerViewModel(IEventAggregator events) { _events = events; _events.Subscribe(this); _isBusy = false; _injector = new Injector(); PlayerOneTimeLineEnabled = true; PlayerTwoTimeLineEnabled = false; PlayerOneTimeLineViewModel = new TimeLineViewModel(events); PlayerTwoTimeLineViewModel = new TimeLineViewModel(events); }
/// <summary> /// Performs all presses and releases for a time line item. /// </summary> /// <param name="playerOneTimeLine"> /// </param> /// <param name="playerTwoTimeLine"> /// </param> private void TwoPlayerAction(TimeLineViewModel playerOneTimeLine, TimeLineViewModel playerTwoTimeLine) { // These queues will contain the actual time line items and dequeue them as they are consumed by their frame counter Queue <TimeLineItemViewModel> playerOneQueue = new Queue <TimeLineItemViewModel>(); Queue <TimeLineItemViewModel> playerTwoQueue = new Queue <TimeLineItemViewModel>(); playerOneTimeLine.TimeLineItems.Apply(o => playerOneQueue.Enqueue(o)); playerTwoTimeLine.TimeLineItems.Apply(o => playerTwoQueue.Enqueue(o)); // QueueFrames is the overall frames in each time line. int playerOneQueueFrames = playerOneQueue.Sum <TimeLineItemViewModel>(t => t.WaitFrames); int playerTwoQueueFrames = playerTwoQueue.Sum <TimeLineItemViewModel>(t => t.WaitFrames); int longestQueueTime = Math.Max(playerOneQueueFrames, playerTwoQueueFrames); if (playerOneQueueFrames != playerTwoQueueFrames) { if (playerOneQueueFrames > playerTwoQueueFrames) { playerTwoQueue.Enqueue( new TimeLineItemViewModel() { WaitFrames = playerOneQueueFrames - playerTwoQueueFrames }); } else { playerOneQueue.Enqueue( new TimeLineItemViewModel() { WaitFrames = playerTwoQueueFrames - playerOneQueueFrames }); } } // The cache for the player individual time line items. TimeLineItemViewModel playerOneCurrentItem = playerOneQueue.Dequeue(); TimeLineItemViewModel playerTwoCurrentItem = playerTwoQueue.Dequeue(); // Highlight item in time line new Action(() => playerOneTimeLine.SelectedTimeLineItem = playerOneCurrentItem).BeginOnUIThread(); new Action(() => playerTwoTimeLine.SelectedTimeLineItem = playerTwoCurrentItem).BeginOnUIThread(); // This counts down each players frames for individual time line items. int playerOneCountdown = playerOneCurrentItem.WaitFrames; int playerTwoCountdown = playerTwoCurrentItem.WaitFrames; for (int x = 0; x < longestQueueTime; x++) { if (playerOneCountdown == 0) { playerOneCurrentItem = playerOneQueue.Dequeue(); new Action(() => playerOneTimeLine.SelectedTimeLineItem = playerOneCurrentItem).BeginOnUIThread(); playerOneCountdown = playerOneCurrentItem.WaitFrames; } if (playerTwoCountdown == 0) { playerTwoCurrentItem = playerTwoQueue.Dequeue(); new Action(() => playerTwoTimeLine.SelectedTimeLineItem = playerTwoCurrentItem).BeginOnUIThread(); playerTwoCountdown = playerTwoCurrentItem.WaitFrames; } if (playerOneTimeLine.SendInputs) { SendPlayerInput(1, playerOneCurrentItem); } if (playerTwoTimeLine.SendInputs) { SendPlayerInput(2, playerTwoCurrentItem); } if (playerOneCurrentItem.InputItemViewModel.PlaySound && playerOneCurrentItem.WaitFrames == playerOneCountdown) { Input[] inputs = playerOneCurrentItem.InputItemViewModel.InputItem.Inputs; if (!inputs.Intersect(Directions).Any() && !inputs.Intersect(Buttons).Any()) { Roadie.Instance.PlaySound(Roadie.WAIT_SOUND); } else { if (inputs.Intersect(Buttons).Any()) { Roadie.Instance.PlaySound(Roadie.PRESS_BUTTON_SOUND); } if (inputs.Intersect(Directions).Any()) { Roadie.Instance.PlaySound(Roadie.PRESS_DIRECTION_SOUND); } } } playerOneCountdown--; playerTwoCountdown--; WaitForFrames(1); } }
public ComboTrainerViewModel(IEventAggregator events) { _events = events; _timeLineViewModel = new TimeLineViewModel(events); }