small changes

This commit is contained in:
Maximilian Fajnberg 2022-01-13 17:07:28 +01:00
parent 33de4f2fa6
commit fc10cbfc3e

View File

@ -85,11 +85,11 @@ int32 AAdventureMap::GridIndex(int32 qAxial, int32 rAxial)
AHexTile* AAdventureMap::RandomHex()
{
int32 RandHex = GridIndex(FMath::RandRange(0, GridSize), FMath::RandRange(0, GridSize));
while (RandHex > Grid.Num())
{
RandHex = GridIndex(FMath::RandRange(0, GridSize), FMath::RandRange(0, GridSize));
}
int32 RandHex = GridIndex(FMath::RandRange(0, GridSize-1), FMath::RandRange(0, GridSize-1));
//while (RandHex > Grid.Num())
//{
// RandHex = GridIndex(FMath::RandRange(0, GridSize), FMath::RandRange(0, GridSize));
//}
return Grid[RandHex];
}
@ -99,40 +99,22 @@ TArray<AHexTile*> AAdventureMap::Neighbors(AHexTile* OfHex)
int32 Index;
Index = GridIndex(OfHex->Q + 1 , OfHex->R + 0 );
if ( Index >= 0&& Index < Grid.Num() )
{
if (OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
}
if (Index >= 0 && Index < Grid.Num() && OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
Index = GridIndex(OfHex->Q + 1 , OfHex->R - 1 );
if (Index >= 0 && Index < Grid.Num())
{
if (OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
}
if (Index >= 0 && Index < Grid.Num() && OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
Index = GridIndex(OfHex->Q + 0 , OfHex->R - 1 );
if (Index >= 0 && Index < Grid.Num())
{
if (OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
}
if (Index >= 0 && Index < Grid.Num() && OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
Index = GridIndex(OfHex->Q - 1 , OfHex->R + 0 );
if (Index >= 0 && Index < Grid.Num())
{
if (OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
}
if (Index >= 0 && Index < Grid.Num() && OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
Index = GridIndex(OfHex->Q - 1 , OfHex->R + 1 );
if (Index >= 0 && Index < Grid.Num())
{
if (OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
}
if (Index >= 0 && Index < Grid.Num() && OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
Index = GridIndex(OfHex->Q + 0 , OfHex->R + 1 );
if (Index >= 0 && Index < Grid.Num())
{
if (OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
}
if (Index >= 0 && Index < Grid.Num() && OfHex->Distance(Grid[Index]) == 1) { Neighbors.Add(Grid[Index]); }
return Neighbors;
}