private void DrawTournamentLines(BotUserControl bot1, BotUserControl bot2) { var line = new Polyline { Stroke = Brushes.Tomato, StrokeThickness = 8 }; TournamentLadderCanvas.Children.Add(line); line.Points.Add(bot1.BotHeadPoint); var point = new Point { X = bot1.BotHeadPoint.X + 25, Y = bot1.BotHeadPoint.Y }; line.Points.Add(point); point = new Point { X = bot1.BotHeadPoint.X + 25, Y = bot2.BotHeadPoint.Y }; line.Points.Add(point); point = new Point { X = bot2.BotHeadPoint.X, Y = bot2.BotHeadPoint.Y }; line.Points.Add(point); line = new Polyline { Stroke = Brushes.Tomato, StrokeThickness = 8 }; TournamentLadderCanvas.Children.Add(line); point = new Point { X = bot1.BotHeadPoint.X + 25, Y = (Math.Abs(bot2.BotHeadPoint.Y - bot1.BotHeadPoint.Y) / 2) + Math.Min(bot2.BotHeadPoint.Y, bot1.BotHeadPoint.Y) }; line.Points.Add(point); point = new Point { X = bot1.BotHeadPoint.X + 50, Y = (Math.Abs(bot2.BotHeadPoint.Y - bot1.BotHeadPoint.Y) / 2) + Math.Min(bot2.BotHeadPoint.Y, bot1.BotHeadPoint.Y) }; line.Points.Add(point); }
private BotUserControl AddEmptyBotToStage(int stageNumber, int orderInRow, int numberOfBots) { var botView = new BotUserControl(new BotViewModel()) { BotHeadPoint = new Point { X = ((stageNumber - 1)*(160 + 50)) + 160, Y = ((_startingNumberOfBots/numberOfBots)*60*orderInRow + (Math.Pow(2, (stageNumber - 1)) - 1)*60/2) + 60.0/2, }, BotTailPoint = new Point { X = ((stageNumber - 1)*(160 + 50)), Y = ((_startingNumberOfBots/numberOfBots)*60*orderInRow + (Math.Pow(2, (stageNumber - 1)) - 1)*60/2) + 60.0/2, } }; Canvas.SetTop(botView, (_startingNumberOfBots / numberOfBots) * 60 * orderInRow + (Math.Pow(2, (stageNumber - 1)) - 1) * 60 / 2); Canvas.SetLeft(botView, (stageNumber - 1) * (160 + 50)); TournamentLadderCanvas.Children.Add(botView); return botView; }
private BotUserControl AddEmptyBotToStage(int stageNumber, int orderInRow, int numberOfBots) { var botView = new BotUserControl(new BotViewModel()) { BotHeadPoint = new Point { X = ((stageNumber - 1) * (160 + 50)) + 160, Y = ((_startingNumberOfBots / numberOfBots) * 60 * orderInRow + (Math.Pow(2, (stageNumber - 1)) - 1) * 60 / 2) + 60 / 2, }, BotTailPoint = new Point { X = ((stageNumber - 1) * (160 + 50)), Y = ((_startingNumberOfBots / numberOfBots) * 60 * orderInRow + (Math.Pow(2, (stageNumber - 1)) - 1) * 60 / 2) + 60 / 2, } }; Canvas.SetTop(botView, (_startingNumberOfBots / numberOfBots) * 60 * orderInRow + (Math.Pow(2, (stageNumber - 1)) - 1) * 60 / 2); Canvas.SetLeft(botView, (stageNumber - 1) * (160 + 50)); TournamentLadderCanvas.Children.Add(botView); return(botView); }
private void UpdateTournamentLadder(BotUserControl botControl, double score) { if ((int)score == 1) { if (_tournamentLadderViewModel.StageLists[botControl.ViewModel.CurrentStage].Count > 1) { var nextStageControl = _tournamentLadderViewModel.StageLists[botControl.ViewModel.CurrentStage + 1].First(f => f.Id == botControl.NextStageTargetId); botControl.ViewModel.CurrentStage++; nextStageControl.ViewModel = botControl.ViewModel; } } if ((int)score == 0) { botControl.ViewModel.StilInGame = false; } }