new algorithm draft for diag moves; committed missing files
This commit is contained in:
+2
-16
@@ -10,40 +10,26 @@
|
||||
AHexTile::AHexTile()
|
||||
{
|
||||
TileSize = 100.f;
|
||||
|
||||
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
|
||||
|
||||
this->FillCornersArray();
|
||||
}
|
||||
|
||||
void AHexTile::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
}
|
||||
void AHexTile::BeginPlay() { Super::BeginPlay(); }
|
||||
|
||||
FVector AHexTile::Corner(int32 i)
|
||||
{
|
||||
FVector TileCenter = this->GetActorTransform().GetLocation();
|
||||
|
||||
int32 Angle_Deg = 60 * i - 30;
|
||||
float Angle_Rad = UKismetMathLibrary::GetPI()/180 * Angle_Deg;
|
||||
float X = TileCenter.X + TileSize * cos(Angle_Rad);
|
||||
float Y = TileCenter.Y + TileSize * sin(Angle_Rad);
|
||||
|
||||
return FVector(X, Y, 0.f);
|
||||
}
|
||||
void AHexTile::FillCornersArray()
|
||||
{
|
||||
for (int32 i = 0 ; i < 6; i++)
|
||||
{
|
||||
Corners.Emplace(Corner(i + 1));
|
||||
}
|
||||
}
|
||||
void AHexTile::FillCornersArray() { for (int32 i = 0 ; i < 6; i++) { Corners.Emplace(Corner(i + 1)); } }
|
||||
|
||||
int32 AHexTile::Distance(AHexTile* ToHex)
|
||||
{
|
||||
int32 CubeS1 = -this->Q - this->R;
|
||||
int32 CubeS2 = -ToHex->Q - ToHex->R;
|
||||
|
||||
return (abs(this->Q - ToHex->Q) + abs(this->R - ToHex->R) + abs(CubeS1 - CubeS2)) / 2;
|
||||
}
|
||||
Reference in New Issue
Block a user