/// <summary> /// Coords the painting of the portion of the map between the two Coords parameters. /// </summary> public void Paint(Graphics g, Coords topLeft, Coords bottomRight) { // The algorithm is as follows: // 1) AT INIT: Imports and resizes the bitmaps. // 2) AT ZOOM: Resizes bitmaps. // 3) AT PAINT: The Form determines what portion of the map should be painted and calls Painter. // Painter goes through the Tiles and draws them, row by row, from left-to-right from // top-to-bottom. #region Tiles Int32 pixelsX = 0; // We assume the validity check for the two coords has been done in the caller class. for (Int32 i = 0; i < Constants.MapSizeX; ++i) { if (i > 0) { pixelsX += Constants.TileSizesX[i - 1]; } Int32 pixelsY = 0; for (Int32 j = 0; j < Constants.MapSizeY; ++j) { Coords currentCoords = new Coords(i, j); Tile currentTile = this._currentMap.GetTile(i, j); if (j > 0) { pixelsY += Constants.TileSizesY[j - 1]; } this.TileDrawBitmap(g, new Coords(pixelsX, pixelsY), this.Tiles[(sbyte)currentTile.MyBitmap]); foreach (Footballer critter in _currentMap.Roster.Values) { this.AddForPaintingFootballer(critter); } } } #endregion #region Props and Footballers // The tiles have informed the painter about the Footballers he's supposed to draw. foreach (Footballer critter in this._FootballersToDraw) { this.FillPlayerEllipse(g, critter.PositionDouble, 10, 8, critter.Team.TeamColor); this.DrawBitmapAtPixel(g, new Coords((Int32)critter.PositionDouble.X, (Int32)critter.PositionDouble.Y), this.Footballers[(sbyte)critter.MyBitmap]); Vector2d delta = critter.FacingDirection; delta.ScaleToLength(50); this.DrawLine(g, critter.PositionDouble, critter.PositionDouble + delta); } // Draw the labels foreach (Footballer critter in this._FootballersToDraw) { //FIX // draw labels if ((critter.LabelUpper != null) && (critter.LabelUpper.Length > 0)) { this.DrawLabel(g, critter.PositionDouble + new Vector2d(0, -200), critter.LabelUpper); } if ((critter.LabelLower != null) && (critter.LabelLower.Length > 0)) { //this.DrawLabel(g, new Coords(CoordsType.Pixel, critter.PositionPixel.X, critter.PositionPixel.Y + critter.RadiusY), critter.LabelLower); } } for (int i = 0; i < Props.Length; ++i) { DrawProp(g, Constants.PropLocations[i], Props[i]); } #endregion #region Nets, Ball, and Info // DrawGhostBall if option is enabled if (this._ghost != null) { //BallGhost ghost = new BallGhost(this._currentMap.BallReference); for (int i = 0; i < Constants.GhostBallTimeLength; ++i) { for (int j = 0; j < Constants.GhostBallDrawInterval; ++j) { _ghost.UpdateMotion3D(); } this.DrawGhostBall(g, _ghost); } } if (Constants.ShowTrajectory) { if (this._currentMap.BallReference.Projection.Count > 0) { foreach (Vector3d v in this._currentMap.BallReference.Projection) { BallGhost ghost = new BallGhost(this._currentMap.BallReference); //ghost.SpawnAt(v.ProjectionXY()); ghost.Stop(); ghost.Position3d = v; this.DrawGhostBall(g, ghost); } } } BallPosition ballPos = DetermineBallPosition(_currentMap.BallReference); // Nets if (ballPos == BallPosition.BehindGoal) { this.DrawSomeBall(g, _currentMap.BallReference, this.Balls[(sbyte)SpriteBall.Standard]); } DrawNetYAxis(g, Constants.NetsBackLeft); DrawNetYAxis(g, Constants.NetsBackRight); DrawNetXAxis(g, Constants.NetsBackLeft, Constants.GoalTop); DrawNetXAxis(g, Constants.GoalRight, Constants.GoalTop); if (ballPos == BallPosition.InsideGoal) { this.DrawSomeBall(g, _currentMap.BallReference, this.Balls[(sbyte)SpriteBall.Standard]); } DrawNetXAxis(g, Constants.NetsBackLeft, Constants.GoalBottom); DrawNetXAxis(g, Constants.GoalRight, Constants.GoalBottom); DrawNetZAxis(g, Constants.NetsBackLeft); DrawNetZAxis(g, Constants.GoalRight); DrawGoals(g); if (ballPos == BallPosition.Visible) { this.DrawSomeBall(g, _currentMap.BallReference, this.Balls[(sbyte)SpriteBall.Standard]); } DrawBallParameters(g, topLeft); DrawShotParameters(g, topLeft); this.DrawInfluenceMap(g, _currentMap.MatchOnMap.TeamLeft.TeamInfluenceMap, topLeft, _currentMap.MatchOnMap.TeamLeft.TeamColor, true); this.DrawInfluenceMap(g, _currentMap.MatchOnMap.TeamRight.TeamInfluenceMap, topLeft, _currentMap.MatchOnMap.TeamRight.TeamColor, false); #endregion // Clean up the ID list. this._FootballersToDraw.Clear(); }