private void AnimateComputerTeam(double possession = 0d) { var storyBoard = new Storyboard(); AnimatePlayer(storyBoard, ComputerTeamFormation[0].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer1LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[0].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer1TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[1].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer2LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[1].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer2TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[2].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer3LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[2].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer3TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[3].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer4LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[3].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer4TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[4].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer5LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[4].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer5TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[5].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer6LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[5].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer6TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[6].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer7LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[6].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer7TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[7].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer8LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[7].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer8TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[8].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer9LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[8].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer9TopProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[9].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.ComputerPlayer10LeftProperty); AnimatePlayer(storyBoard, ComputerTeamFormation[9].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.ComputerPlayer10TopProperty); if (Math.Abs(possession) > 1E-6) { AnimatePossessionBar(storyBoard, 1000 * possession, MatchAnimations.HomePossessionProperty); AnimatePossessionBar(storyBoard, 1000 * (1 - possession), MatchAnimations.AwayPossessionProperty); } storyBoard.Begin(); }
private void AnimatePlayerTeam() { var storyBoard = new Storyboard(); AnimatePlayer(storyBoard, TeamFormation[0].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player1LeftProperty); AnimatePlayer(storyBoard, TeamFormation[0].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player1TopProperty); AnimatePlayer(storyBoard, TeamFormation[1].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player2LeftProperty); AnimatePlayer(storyBoard, TeamFormation[1].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player2TopProperty); AnimatePlayer(storyBoard, TeamFormation[2].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player3LeftProperty); AnimatePlayer(storyBoard, TeamFormation[2].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player3TopProperty); AnimatePlayer(storyBoard, TeamFormation[3].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player4LeftProperty); AnimatePlayer(storyBoard, TeamFormation[3].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player4TopProperty); AnimatePlayer(storyBoard, TeamFormation[4].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player5LeftProperty); AnimatePlayer(storyBoard, TeamFormation[4].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player5TopProperty); AnimatePlayer(storyBoard, TeamFormation[5].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player6LeftProperty); AnimatePlayer(storyBoard, TeamFormation[5].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player6TopProperty); AnimatePlayer(storyBoard, TeamFormation[6].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player7LeftProperty); AnimatePlayer(storyBoard, TeamFormation[6].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player7TopProperty); AnimatePlayer(storyBoard, TeamFormation[7].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player8LeftProperty); AnimatePlayer(storyBoard, TeamFormation[7].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player8TopProperty); AnimatePlayer(storyBoard, TeamFormation[8].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player9LeftProperty); AnimatePlayer(storyBoard, TeamFormation[8].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player9TopProperty); AnimatePlayer(storyBoard, TeamFormation[9].Location.XamlX * MatchAnimations.GetPitchWidth(MatchAnimations), MatchAnimations.Player10LeftProperty); AnimatePlayer(storyBoard, TeamFormation[9].Location.XamlY * MatchAnimations.GetPitchHeight(MatchAnimations), MatchAnimations.Player10TopProperty); storyBoard.Begin(); }
private void UpdateStaticFixtureData() { ComputerTeamName = Fixture.TeamHome.TeamName == TeamName ? Fixture.TeamAway.TeamName : Fixture.TeamHome.TeamName; Team = Fixture.TeamHome.TeamName == TeamName ? Fixture.TeamHome : Fixture.TeamAway; var computerTeam = Fixture.TeamHome.TeamName == ComputerTeamName ? Fixture.TeamHome : Fixture.TeamAway; TeamFormation = Team.FormationClone(); ComputerTeamFormation = computerTeam.FormationClone(); HomePrimaryColour = Fixture.TeamHome.PrimaryColour; HomeSecondaryColour = Fixture.TeamHome.SecondaryColour; AwayPrimaryColour = Fixture.TeamAway.PrimaryColour; AwaySecondaryColour = Fixture.TeamAway.SecondaryColour; MatchAnimations.UpdateComputerTeamFormation(ComputerTeamFormation); MatchAnimations.SetHomePossession(MatchAnimations, 500); MatchAnimations.SetAwayPossession(MatchAnimations, 500); UpdatePlayerPositions(); NotifyOfPropertyChange(() => Score); NotifyOfPropertyChange(() => Minutes); NotifyOfPropertyChange(() => PlayingPeriod); UpdatePlayerShirts(); UpdateComputerShirts(); SubstitutesUsed = 0; SubstitutedPlayers.Clear(); NotifyOfPropertyChange(() => PlayerSubstitutes); NotifyOfPropertyChange(() => PlayerNumbers); PrimaryColour = Team.PrimaryColour; SecondaryColour = Team.SecondaryColour; PrimaryComputerColour = computerTeam.PrimaryColour; SecondaryComputerColour = computerTeam.SecondaryColour; PlayerShirtType = Team.ShirtType; ComputerPlayerShirtType = computerTeam.ShirtType; }
public MatchViewModel(IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; this.ModuleType = ModuleType.Match; this.UiScheduler = TaskScheduler.FromCurrentSynchronizationContext(); this.IsAnimated = Visibility.Collapsed; this.IsPlayerControlled = Visibility.Visible; MatchAnimations = new MatchAnimations(); MatchAnimations.SetPitchHeight(MatchAnimations, 400); MatchAnimations.SetPitchWidth(MatchAnimations, 300); CreateHeatMapModel(); this.SubstitutedPlayers = new List <Player>(); this.eventAggregator.Subscribe(this); }
private void Halftime() { MatchAnimations.UpdatePlayerTeamFormation(TeamFormation); InvertFormation(ComputerTeamFormation.Values); InvertFormation(TeamFormation.Values); IsPlayerControlled = Visibility.Collapsed; IsAnimated = Visibility.Visible; AnimateComputerTeam(); AnimatePlayerTeam(); Task.Delay(TimeSpan.FromSeconds(AnimationDuration * 1.1d)) .ContinueWith(t => { UpdatePlayerPositions(); IsAnimated = Visibility.Collapsed; IsPlayerControlled = Visibility.Visible; }, CancellationToken.None, TaskContinuationOptions.None, UiScheduler); }