Changeset 268 for trunk/UMapType.pas
- Timestamp:
- Jan 20, 2019, 9:32:16 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UMapType.pas
r258 r268 20 20 private 21 21 const 22 CellMulX = 1.12 ;23 CellMulY = 1.292 ;22 CellMulX = 1.12 * 1.028; 23 CellMulY = 1.292 * 1.03; 24 24 function IsCellsPosNeighbor(CellPos1, CellPos2: TPoint): Boolean; 25 25 procedure GetCellPosNeighbors(CellPos: TPoint; Cell: TCell); … … 38 38 TSquareMap = class(TMap) 39 39 private 40 const41 CellMulX = 1.05;42 CellMulY = 1.05;43 40 function GetSquarePolygon(Pos: TPoint; Size: TPoint): TPolygon; 44 41 public 45 42 procedure Generate; override; 46 function CalculatePixelRect: TRect; override;47 43 end; 48 44 … … 52 48 private 53 49 const 54 CellMulX = 0.5 5;55 CellMulY = 1 .05;50 CellMulX = 0.5; 51 CellMulY = 1; 56 52 function GetTrianglePolygon(Pos: TPoint; Size: TPoint; Reverse: Boolean): TPolygon; 57 53 protected … … 76 72 private 77 73 const 78 CellMulX = 0.95;79 CellMulY = 3. 35;74 CellMulX = 1; 75 CellMulY = 3.5; 80 76 function GetTilePolygon(Pos: TPoint; Size: TPoint): TPolygon; 81 77 protected … … 173 169 Result := inherited CalculatePixelRect; 174 170 Result.P2 := Result.P2 - TPoint.Create( 175 Trunc(0. 45 * DefaultCellSize.X / CellMulX),176 Trunc( 0.90 *DefaultCellSize.Y / CellMulY)171 Trunc(0.5 * DefaultCellSize.X / CellMulX), 172 Trunc(DefaultCellSize.Y / CellMulY) 177 173 ); 178 174 end; … … 212 208 Shift := TPointF.Create(0.5, 0.5) * TPointF.Create(Cos(Angle), Sin(Angle)); 213 209 Result.P2 := Result.P2 - TPoint.Create( 214 Trunc(0. 47* DefaultCellSize.X / CellMulX),215 Trunc(1. 2* Shift.Y * DefaultCellSize.Y / CellMulY)210 Trunc(0.5 * DefaultCellSize.X / CellMulX), 211 Trunc(1.35 * Shift.Y * DefaultCellSize.Y / CellMulY) 216 212 ); 217 213 end; … … 344 340 NewCell := TCell.Create; 345 341 NewCell.Map := Self; 346 NewCell.PosPx := TPoint.Create(Trunc(X * DefaultCellSize.X * CellMulX),347 Trunc(Y * DefaultCellSize.Y * CellMulY));342 NewCell.PosPx := TPoint.Create(Trunc(X * DefaultCellSize.X), 343 Trunc(Y * DefaultCellSize.Y)); 348 344 NewCell.Polygon := GetSquarePolygon(NewCell.PosPx, DefaultCellSize); 349 345 NewCell.Id := GetNewCellId; … … 382 378 383 379 FPixelRect := CalculatePixelRect; 384 end;385 386 function TSquareMap.CalculatePixelRect: TRect;387 begin388 Result := inherited CalculatePixelRect;389 Result.P2 := Result.P2 + TPoint.Create(390 Trunc(0.05 * DefaultCellSize.X / CellMulX),391 Trunc(0.05 * DefaultCellSize.Y / CellMulY)392 );393 380 end; 394 381 … … 424 411 AreaSize: TPoint; 425 412 const 426 CellGapWidth = 4;413 LinkTolerance = 8; 427 414 begin 428 415 Clear; … … 457 444 LinkLine := TLine.Create(Cell.PosPx, Cell2.PosPx + 458 445 TPoint.Create(X * AreaSize.X, Y * AreaSize.Y)); 459 LinkLine.Distance := LinkLine.Distance - CellGapWidth;446 LinkLine.Distance := LinkLine.Distance; 460 447 MP := LinkLine.GetMiddle; 461 448 // Create half plane vector … … 473 460 if Cell2 <> Cell then begin 474 461 LinkLine := TLine.Create(Cell.PosPx, Cell2.PosPx); 475 LinkLine.Distance := LinkLine.Distance - CellGapWidth;462 LinkLine.Distance := LinkLine.Distance; 476 463 MP := LinkLine.GetMiddle; 477 464 // Create half plane vector … … 493 480 P := Cells[J].Polygon; 494 481 P.Move(TPoint.Create(X * AreaSize.X, Y * AreaSize.Y)); 495 if Cells[I].Polygon.EdgeDistance(P) < 2 * CellGapWidththen482 if Cells[I].Polygon.EdgeDistance(P) < LinkTolerance then 496 483 Cells[I].ConnectTo(Cells[J]); 497 484 end; … … 500 487 for I := 0 to Cells.Count - 1 do begin 501 488 for J := I + 1 to Cells.Count - 1 do begin 502 if Cells[I].Polygon.EdgeDistance(Cells[J].Polygon) < 2 * CellGapWidththen489 if Cells[I].Polygon.EdgeDistance(Cells[J].Polygon) < LinkTolerance then 503 490 Cells[I].ConnectTo(Cells[J]); 504 491 end; … … 603 590 Result := inherited CalculatePixelRect; 604 591 Result.P2 := Result.P2 + TPoint.Create( 605 Trunc( 0.05 * DefaultCellSize.X / CellMulX - 0.30* DefaultCellSize.X / CellMulX),606 Trunc(0.05 * DefaultCellSize.Y / CellMulY)592 Trunc(- 0.25 * DefaultCellSize.X / CellMulX), 593 0 607 594 ); 608 595 end;
Note:
See TracChangeset
for help on using the changeset viewer.