Changeset 248
- Timestamp:
- Sep 22, 2018, 2:35:46 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormClient.pas
r246 r248 12 12 const 13 13 ZoomFactor = 1.5; 14 MinZoom = 0. 05;14 MinZoom = 0.1; 15 15 MaxZoom = 10; 16 16 MouseMinDiff = 0.1; -
trunk/UClientGUI.pas
r241 r248 507 507 end; 508 508 if Assigned(NewSelectedCell) then begin 509 if (NewSelectedCell <> SelectedCell) and (NewSelectedCell.MapCell.Player = Player) then begin 510 SelectedCell := NewSelectedCell 511 end else 512 if (NewSelectedCell = SelectedCell) and (NewSelectedCell.MapCell.Player = Player) then begin 513 SelectedCell := nil; 514 end else 509 515 if Assigned(SelectedCell) and TGame(Game).Map.IsCellsNeighbor(NewSelectedCell.MapCell, SelectedCell.MapCell) then begin 510 516 if ssShift in ShiftState then begin … … 530 536 SelectedCell := nil; 531 537 end; 532 end else 533 if (NewSelectedCell <> SelectedCell) and (NewSelectedCell.MapCell.Player = Player) then 534 SelectedCell := NewSelectedCell 535 else 536 if (NewSelectedCell = SelectedCell) and (NewSelectedCell.MapCell.Player = Player) then 537 SelectedCell := nil; 538 end; 538 539 end; 539 540 end; -
trunk/UGeometry.pas
r236 r248 98 98 constructor Create(const Points: TPointArray); overload; 99 99 constructor Create(const Rect: TGRect<T>); overload; 100 procedure Move(P: T); 100 101 function GetRect: TGRect<T>; 101 102 function EdgeDistance(Polygon: TGPolygon<T>): Double; … … 331 332 end; 332 333 334 procedure TGPolygon<T>.Move(P: T); 335 var 336 I: Integer; 337 begin 338 for I := 0 to Length(Points) - 1 do 339 Points[I] := Points[I] + P; 340 end; 341 333 342 { TGLine } 334 343 -
trunk/UMap.pas
r247 r248 1190 1190 end; 1191 1191 1192 1193 1194 1192 end. 1195 1193 -
trunk/UMapType.pas
r247 r248 421 421 MP: TPoint; 422 422 LinkLine: TLine; 423 P: TPolygon; 424 AreaSize: TPoint; 423 425 const 424 426 CellGapWidth = 4; … … 441 443 end; 442 444 443 // Compute polygon by catting out map area by all other cells 444 for Cell in Cells do begin 445 Cell.Polygon := TPolygon.Create(TRect.Create(TPoint.Create(0, 0), 446 TPoint.Create(Size.X * DefaultCellSize.X, Size.Y * DefaultCellSize.Y))); 447 for Cell2 in Cells do 448 if Cell2 <> Cell then begin 449 LinkLine := TLine.Create(Cell.PosPx, Cell2.PosPx); 450 LinkLine.Distance := LinkLine.Distance - CellGapWidth; 451 MP := LinkLine.GetMiddle; 452 // Create half plane vector 453 L1 := TLine.Create(MP, TPoint.Create(MP.X + LinkLine.GetSize.X, 454 MP.Y + LinkLine.GetSize.Y)); 455 456 Cell.Polygon.CutLine(L1, Cell.PosPx); 445 AreaSize := TPoint.Create(Size.X * DefaultCellSize.X, Size.Y * DefaultCellSize.Y); 446 447 // Compute polygon by cutting out map area by all other cells 448 if Cyclic then begin 449 for Cell in Cells do begin 450 Cell.Polygon := TPolygon.Create(TRect.Create( 451 TPoint.Create(-AreaSize.X, -AreaSize.Y), 452 TPoint.Create(2 * AreaSize.X, 2 * AreaSize.Y))); 453 for Y := -1 to 1 do 454 for X := -1 to 1 do 455 for Cell2 in Cells do 456 if Cell2 <> Cell then begin 457 LinkLine := TLine.Create(Cell.PosPx, Cell2.PosPx + 458 TPoint.Create(X * AreaSize.X, Y * AreaSize.Y)); 459 LinkLine.Distance := LinkLine.Distance - CellGapWidth; 460 MP := LinkLine.GetMiddle; 461 // Create half plane vector 462 L1 := TLine.Create(MP, TPoint.Create(MP.X + LinkLine.GetSize.X, 463 MP.Y + LinkLine.GetSize.Y)); 464 465 Cell.Polygon.CutLine(L1, Cell.PosPx); 466 end; 467 end; 468 end else begin 469 for Cell in Cells do begin 470 Cell.Polygon := TPolygon.Create(TRect.Create(TPoint.Create(0, 0), 471 AreaSize)); 472 for Cell2 in Cells do 473 if Cell2 <> Cell then begin 474 LinkLine := TLine.Create(Cell.PosPx, Cell2.PosPx); 475 LinkLine.Distance := LinkLine.Distance - CellGapWidth; 476 MP := LinkLine.GetMiddle; 477 // Create half plane vector 478 L1 := TLine.Create(MP, TPoint.Create(MP.X + LinkLine.GetSize.X, 479 MP.Y + LinkLine.GetSize.Y)); 480 481 Cell.Polygon.CutLine(L1, Cell.PosPx); 482 end; 457 483 end; 458 484 end; 459 485 460 486 // Link all cells with neighboring polygon edges 461 for I := 0 to Cells.Count - 1 do begin 462 for J := I + 1 to Cells.Count - 1 do begin 463 if Cells[I].Polygon.EdgeDistance(Cells[J].Polygon) < 2 * CellGapWidth then 464 Cells[I].ConnectTo(Cells[J]); 487 if Cyclic then begin 488 for I := 0 to Cells.Count - 1 do begin 489 for Y := -1 to 1 do 490 for X := -1 to 1 do 491 for J := 0 to Cells.Count - 1 do begin 492 P := Cells[J].Polygon; 493 P.Move(TPoint.Create(X * AreaSize.X, Y * AreaSize.Y)); 494 if Cells[I].Polygon.EdgeDistance(P) < 2 * CellGapWidth then 495 Cells[I].ConnectTo(Cells[J]); 496 end; 497 end; 498 end else begin 499 for I := 0 to Cells.Count - 1 do begin 500 for J := I + 1 to Cells.Count - 1 do begin 501 if Cells[I].Polygon.EdgeDistance(Cells[J].Polygon) < 2 * CellGapWidth then 502 Cells[I].ConnectTo(Cells[J]); 503 end; 465 504 end; 466 505 end; … … 476 515 function TVoronoiMap.CalculatePixelRect: TRect; 477 516 begin 478 Result := inherited CalculatePixelRect; 479 Result.P2 := Result.P2 + TPoint.Create( 480 Trunc(0.02 * DefaultCellSize.X), 481 Trunc(0.02 * DefaultCellSize.Y) 482 ); 517 Result.P1 := TPoint.Create(0, 0); 518 Result.P2 := TPoint.Create(Size.X * DefaultCellSize.X, Size.Y * DefaultCellSize.Y); 483 519 end; 484 520 -
trunk/UPlayer.pas
r235 r248 55 55 procedure SaveToNode(Node: TDOMNode); 56 56 procedure Update; 57 procedure Clear; 57 58 constructor Create; 58 59 destructor Destroy; override; … … 422 423 end; 423 424 425 procedure TPlayerMap.Clear; 426 begin 427 Cells.Clear; 428 end; 429 424 430 constructor TPlayerMap.Create; 425 431 begin … … 730 736 TurnStats.Clear; 731 737 Moves.Clear; 738 PlayerMap.Clear; 732 739 end; 733 740
Note:
See TracChangeset
for help on using the changeset viewer.