Changeset 55 for trunk/UGame.pas
- Timestamp:
- Aug 18, 2014, 9:34:15 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UGame.pas
r54 r55 92 92 procedure PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView; 93 93 Cell: TCell); 94 procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double; 95 Text: string); 94 96 procedure SetSize(AValue: TPoint); virtual; 95 97 public … … 98 100 DefaultCellSize: TPoint; 99 101 Cells: TObjectList; // TList<TCell> 100 procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double;101 Text: string);102 102 function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; virtual; 103 103 function IsValidIndex(Index: TPoint): Boolean; virtual; … … 151 151 public 152 152 function IsValidIndex(Index: TPoint): Boolean; override; 153 procedure Generate; override; 154 end; 155 156 { TVoronoiMap } 157 158 TVoronoiMap = class(TMap) 159 private 160 function GetTrianglePolygon(Pos: TPoint; Size: TPoint; Reverse: Boolean): TPointArray; 161 public 153 162 procedure Generate; override; 154 163 end; … … 210 219 TGrowAmount = (gaByOne, gaBySquareRoot); 211 220 TGrowCells = (gcNone, gcPlayerCities, gcPlayerAll); 212 TMapType = (mtNone, mtHexagon, mtSquare, mtTriangle );221 TMapType = (mtNone, mtHexagon, mtSquare, mtTriangle, mtVoronoi); 213 222 TWinObjective = (woDefeatAllOponents, woDefeatAllOponentsCities, 214 223 woSpecialCaptureCell, woStayAliveForDefinedTurns); … … 345 354 end; 346 355 356 { TVoronoiMap } 357 358 function TVoronoiMap.GetTrianglePolygon(Pos: TPoint; Size: TPoint; 359 Reverse: Boolean): TPointArray; 360 begin 361 362 end; 363 364 procedure TVoronoiMap.Generate; 365 var 366 X, Y: Integer; 367 I, J, PI: Integer; 368 V, VN: Integer; 369 NewCell: TCell; 370 Pos: TPoint; 371 begin 372 inherited; 373 // Free previous 374 Cells.Count := 0; 375 // Allocate and init new 376 Cells.Count := FSize.Y * FSize.X; 377 for Y := 0 to FSize.Y - 1 do 378 for X := 0 to FSize.X - 1 do begin 379 NewCell := TCell.Create; 380 NewCell.PosPx := Point(Trunc(Random * FSize.X * DefaultCellSize.X), Trunc(Random * FSize.Y * DefaultCellSize.Y)); 381 SetLength(NewCell.Polygon, 1); 382 NewCell.Polygon[0] := NewCell.PosPx; 383 Cells[Y * FSize.X + X] := NewCell; 384 end; 385 end; 386 347 387 { TTriangleMap } 348 388 … … 503 543 Brush.Style := bsClear; 504 544 Font.Color := clBlack; 505 Font.Size := Trunc( 4* View.Zoom);545 Font.Size := Trunc(16 * View.Zoom); 506 546 TextOut(Pos.X - TextWidth(Text) div 2, 507 547 Pos.Y - TextHeight(Text) div 2, Text); … … 624 664 Pen.Style := psSolid; 625 665 Font.Color := clWhite; 626 Font.Size := Trunc( 12 * View.Zoom);666 Font.Size := Trunc(42 * View.Zoom); 627 667 TextPos := View.CellToCanvasPos(Pos); 628 668 TextOut(Round(TextPos.X) - TextWidth(Text) div 2, Round(TextPos.Y) - TextHeight(Text) div 2, Text); … … 668 708 begin 669 709 MaxPower := 99; 670 DefaultCellSize := Point( 62, 62);710 DefaultCellSize := Point(220, 220); 671 711 Cells := TObjectList.create; 672 712 Size := Point(0, 0); … … 1128 1168 mtSquare: Map := TSquareMap.Create; 1129 1169 mtTriangle: Map := TTriangleMap.Create; 1170 mtVoronoi: Map := TVoronoiMap.Create; 1130 1171 else Map := TMap.Create; 1131 1172 end; … … 1432 1473 Shift := FloatPoint(0.5 * cos(30 / 180 * Pi), 0.5 * sin(30 / 180 * Pi)); 1433 1474 SetLength(Result, 6); 1434 Result[0] := Point( Round(Pos.X + 0 * Size.X), Round(Pos.Y - 0.5 * Size.Y));1435 Result[1] := Point( Round(Pos.X + Shift.X * Size.X), Round(Pos.Y - Shift.Y * Size.Y));1436 Result[2] := Point( Round(Pos.X + Shift.X * Size.X), Round(Pos.Y + Shift.Y * Size.Y));1437 Result[3] := Point( Round(Pos.X + 0 * Size.X), Round(Pos.Y + 0.5 * Size.Y));1438 Result[4] := Point( Round(Pos.X - Shift.X * Size.X), Round(Pos.Y + Shift.Y * Size.Y));1439 Result[5] := Point( Round(Pos.X - Shift.X * Size.X), Round(Pos.Y - Shift.Y * Size.Y));1475 Result[0] := Point(Trunc(Pos.X + 0 * Size.X), Trunc(Pos.Y - 0.5 * Size.Y)); 1476 Result[1] := Point(Trunc(Pos.X + Shift.X * Size.X), Trunc(Pos.Y - Shift.Y * Size.Y)); 1477 Result[2] := Point(Trunc(Pos.X + Shift.X * Size.X), Trunc(Pos.Y + Shift.Y * Size.Y)); 1478 Result[3] := Point(Trunc(Pos.X + 0 * Size.X), Trunc(Pos.Y + 0.5 * Size.Y)); 1479 Result[4] := Point(Trunc(Pos.X - Shift.X * Size.X), Trunc(Pos.Y + Shift.Y * Size.Y)); 1480 Result[5] := Point(Trunc(Pos.X - Shift.X * Size.X), Trunc(Pos.Y - Shift.Y * Size.Y)); 1440 1481 end; 1441 1482
Note:
See TracChangeset
for help on using the changeset viewer.