protected override void DrawBoard(SKCanvas canvas) { canvas.Clear(); if (_gameContainer.SingleInfo !.Gender == EnumGender.None) { throw new BasicBlankException("The gender cannot be none for current turn. Rethink"); } var cropRect = GetBounds(); var(locationX, LocationY) = CalculateView(); _currentPoint = new SKPoint(locationX, LocationY); var testRect = SKRect.Create(locationX, LocationY, _ourWidth, _ourHeight); canvas.DrawBitmap(_thisBit, testRect, cropRect, _bitPaint); var thisSize = GetActualSize(51, 93); int index = 400 + (int)_gameContainer.CurrentView; var thisPos = TempData !.PositionList.Where(items => items.SpaceNumber == index).Single(); var thisPoint = GetActualPoint(thisPos.SpacePoint); CarPieceCP thisPiece = GetGamePiece(_gameContainer.SingleInfo !.Color.ToColor(), thisPoint); thisPiece.ActualHeight = thisSize.Height; thisPiece.ActualWidth = thisSize.Width; thisPiece.AddPegs(_gameContainer.SingleInfo); thisPiece.DrawImage(canvas); //to show whose turn it is. thisSize = GetActualSize(34, 62); _gameContainer.PlayerList !.ForEach(thisPlayer => { if (thisPlayer.LastMove == EnumFinal.None && thisPlayer.OptionChosen != EnumStart.None && thisPlayer.Position > 0) { thisPos = TempData.PositionList.SingleOrDefault(items => items.PointView == _currentPoint && items.SpaceNumber == thisPlayer.Position); } else if (thisPlayer.OptionChosen == EnumStart.Career && thisPlayer.LastMove == EnumFinal.None) { thisPos = TempData.PositionList.Single(items => items.SpaceNumber == 201); } else if (thisPlayer.OptionChosen == EnumStart.College && thisPlayer.LastMove == EnumFinal.None) { thisPos = TempData.PositionList.Single(items => items.SpaceNumber == 202); } else { thisPos = null !; } if (thisPos != null && thisPos.SpaceNumber > 0) { thisPoint = GetActualPoint(thisPos.SpacePoint); thisPiece = GetGamePiece(thisPlayer.Color.ToColor(), thisPoint); thisPiece.ActualHeight = thisSize.Height; thisPiece.ActualWidth = thisSize.Width; thisPiece.AddPegs(thisPlayer); // i think thisPiece.DrawImage(canvas); } }); if (_gameContainer.SingleInfo.PlayerCategory == EnumPlayerCategory.Self) { _gameContainer.ExtraSpace !.Area = GetExtraRectangle(); _gameContainer.ExtraSpace.PieceList.Clear(); ButtonCP thisBut; SKPoint newPos; if (_options.CanPurchaseCarInsurance) { thisBut = GetButton("Insure Car", _options.PurchaseCarInsuranceAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_options.CanPurchaseHouseInsurance) { thisBut = GetButton("Insure House", _options.PurchaseHouseInsuranceAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_options.CanPurchaseStock) { thisBut = GetButton("Buy Stock", _options.PurchaseStockAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_options.CanSellHouse) { thisBut = GetButton("Sell House", _options.SellHouseAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_options.CanAttendNightSchool) { thisBut = GetButton("Night School", _options.AttendNightSchoolAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_options.CanTrade4Tiles) { thisBut = GetButton("Trade 4 Tiles", _options.Trade4TilesAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_gameContainer.GameStatus == EnumWhatStatus.NeedToChooseSpace) { thisBut = GetButton("Submit Space", _options.HumanChoseSpaceAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } if (_options.CanEndTurn) { thisBut = GetButton("End Turn", _gameContainer.UIEndTurnAsync); _gameContainer.ExtraSpace.PieceList.Add(thisBut); newPos = _gameContainer.Pos !.GetPosition(_gameContainer.ExtraSpace, (float)thisBut.ActualWidth, (float)thisBut.ActualHeight); thisBut.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.ExtraSpace, thisBut); } _gameContainer.ExtraSpace.PieceList.ForEach(EndBut => { EndBut.DrawImage(canvas); }); } if (_gameContainer.CurrentView == EnumViewCategory.EndGame) { _gameContainer.Pos !.ClearArea(_gameContainer.CountrySpace !); _gameContainer.Pos.ClearArea(_gameContainer.MillionSpace !); _gameContainer.CountrySpace !.PieceList.Clear(); _gameContainer.MillionSpace !.PieceList.Clear(); var tempList = (from items in _gameContainer.PlayerList where items.LastMove == EnumFinal.CountrySideAcres select items).ToCustomBasicList(); foreach (var thisPlayer in tempList) { thisPiece = new CarPieceCP(); thisPiece.ActualHeight = _gameContainer.CountrySpace.Area.Height; thisPiece.ActualWidth = thisSize.Width; thisPiece.NeedsToClear = false; thisPiece.MainColor = thisPlayer.Color.ToColor(); thisPiece.AddPegs(thisPlayer); _gameContainer.CountrySpace.PieceList.Add(thisPiece); var newPos = _gameContainer.Pos.GetPosition(_gameContainer.CountrySpace, (float)thisPiece.ActualWidth, (float)thisPiece.ActualHeight); thisPiece.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.CountrySpace, thisPiece); } tempList = (from Items in _gameContainer.PlayerList where Items.LastMove == EnumFinal.MillionaireEstates select Items).ToCustomBasicList(); foreach (var thisPlayer in tempList) { thisPiece = new CarPieceCP(); thisPiece.ActualHeight = _gameContainer.MillionSpace.Area.Height; // try this way. even though the proportions won't quite be right. thisPiece.ActualWidth = thisSize.Width; thisPiece.NeedsToClear = false; thisPiece.MainColor = thisPlayer.Color.ToColor(); thisPiece.AddPegs(thisPlayer); _gameContainer.MillionSpace.PieceList.Add(thisPiece); var newPos = _gameContainer.Pos.GetPosition(_gameContainer.MillionSpace, (float)thisPiece.ActualWidth, (float)thisPiece.ActualHeight); thisPiece.Location = newPos; _gameContainer.Pos.AddPieceToArea(_gameContainer.MillionSpace, thisPiece); } _gameContainer.CountrySpace.PieceList.ForEach(EndPiece => { EndPiece.DrawImage(canvas); }); _gameContainer.MillionSpace.PieceList.ForEach(EndPiece => { EndPiece.DrawImage(canvas); }); } if (_gameContainer.GameStatus == EnumWhatStatus.NeedToChooseSpace) { var firstPos = _spacePos.FirstPossiblePosition; var secondPos = _spacePos.SecondPossiblePosition; if (_gameContainer.CurrentSelected > 0 && _gameContainer.CurrentSelected != firstPos && _gameContainer.CurrentSelected != secondPos) { throw new BasicBlankException("The current selected must be 0, " + firstPos + " or " + secondPos + ", not " + _gameContainer.CurrentSelected); } SKPaint thisPaint; if (firstPos == _gameContainer.CurrentSelected) { thisPaint = _aquaBorder !; } else { thisPaint = _blackBorder !; } thisPos = (from Items in TempData.PositionList where Items.PointView == _currentPoint && Items.SpaceNumber == firstPos select Items).Single(); var thisRect = GetClickableRectangle(thisPos, false); canvas.DrawRect(thisRect, thisPaint); if (secondPos == _gameContainer.CurrentSelected) { thisPaint = _aquaBorder !; } else { thisPaint = _blackBorder !; } thisPos = (from Items in TempData.PositionList where Items.PointView == _currentPoint && Items.SpaceNumber == secondPos select Items).Single(); thisRect = GetClickableRectangle(thisPos, false); canvas.DrawRect(thisRect, thisPaint); } if (GoingTo > 0) { thisPos = (from Items in TempData.PositionList where Items.PointView == _currentPoint && Items.SpaceNumber == GoingTo select Items).SingleOrDefault(); if (thisPos == null == false) { var ThisRect = GetClickableRectangle(thisPos !, false); canvas.DrawRect(ThisRect, _limeBorder); // may later show another screen. } } if (_gameContainer.GameStatus == EnumWhatStatus.NeedChooseFirstOption) { var firstRect = GetCareerRectangle(); var secondRect = GetCollegeRectangle(); if (_gameContainer.CurrentView != EnumViewCategory.StartGame) { throw new BasicBlankException("If you need to choose between college and career, the current view must be start game"); } canvas.DrawRect(firstRect, _blackBorder); canvas.DrawRect(secondRect, _blackBorder); } if (_gameContainer.GameStatus == EnumWhatStatus.NeedChooseRetirement) { var firstRect = GetCountrySideRect(); var secondRect = GetMillionRect(); canvas.DrawRect(firstRect, _blackBorder); canvas.DrawRect(secondRect, _blackBorder); } }