Don't write clever code
This commit is contained in:
parent
aa02fb8093
commit
28a226e35d
@ -54,16 +54,11 @@ void AAdventureCameraPawn::GetTheDamnViewport()
|
|||||||
void AAdventureCameraPawn::Tick(float DeltaTime)
|
void AAdventureCameraPawn::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
if (IsValid(FollowPawn)) {
|
||||||
// quick fix for edgescrolling after viewport resizing.
|
if (FollowPawn->bIsMoving) {
|
||||||
//
|
FollowAdvPawn(DeltaTime);
|
||||||
//TickIncrement++;
|
}
|
||||||
//if (TickIncrement >= 60) {
|
}
|
||||||
// TickIncrement = 0;
|
|
||||||
// ViewSize = Viewport->Viewport->GetSizeXY();
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (IsValid(FollowPawn)) { if (FollowPawn->bIsMoving) { FollowAdvPawn(DeltaTime); } }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called to bind functionality to input
|
// Called to bind functionality to input
|
||||||
@ -101,18 +96,18 @@ void AAdventureCameraPawn::EdgeScrollSide(float AxisValue)
|
|||||||
float mousePosY = mouseY / ViewSize.Y;
|
float mousePosY = mouseY / ViewSize.Y;
|
||||||
float VertAccelleration = GetInputAxisValue("Mouse Y") * (ScrollAccelleration * .75);
|
float VertAccelleration = GetInputAxisValue("Mouse Y") * (ScrollAccelleration * .75);
|
||||||
|
|
||||||
if (mousePosX <= ESASize) // if in LEFT area
|
if (mousePosX <= ESASize) // in LEFT area
|
||||||
{
|
{
|
||||||
////// Scroll LEFT
|
////// Scroll LEFT
|
||||||
float SpeedX = (mousePosX * ESAMinBoundSlope + ESAMinBoundIntercept) * BaseScrollSpeed;
|
float SpeedX = (mousePosX * ESAMinBoundSlope + ESAMinBoundIntercept) * BaseScrollSpeed;
|
||||||
AddActorLocalOffset(FVector(-SpeedX, 0, 0));
|
AddActorLocalOffset(FVector(-SpeedX, 0, 0));
|
||||||
|
|
||||||
if (mousePosY > .005) // if not touching TOP EDGE
|
if (mousePosY > .005) // not touching TOP EDGE
|
||||||
{
|
{
|
||||||
AddActorLocalOffset(FVector(0, -VertAccelleration, 0));
|
AddActorLocalOffset(FVector(0, -VertAccelleration, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AxisValue < .0 && mousePosX <= .005) // if mouse moving LEFT and touching EDGE
|
if (AxisValue < .0 && mousePosX <= .005) // mouse moving LEFT && touching EDGE
|
||||||
{
|
{
|
||||||
////// Add LEFT accelleration
|
////// Add LEFT accelleration
|
||||||
SpeedX = AxisValue * ScrollAccelleration;
|
SpeedX = AxisValue * ScrollAccelleration;
|
||||||
@ -120,18 +115,18 @@ void AAdventureCameraPawn::EdgeScrollSide(float AxisValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mousePosX >= 1-ESASize) // if in RIGHT area
|
if (mousePosX >= 1-ESASize) // in RIGHT area
|
||||||
{
|
{
|
||||||
////// Scroll RIGHT
|
////// Scroll RIGHT
|
||||||
float SpeedX = (mousePosX * ESAMaxBoundSlope + ESAMaxBoundIntercept) * BaseScrollSpeed;
|
float SpeedX = (mousePosX * ESAMaxBoundSlope + ESAMaxBoundIntercept) * BaseScrollSpeed;
|
||||||
AddActorLocalOffset(FVector(SpeedX, 0, 0));
|
AddActorLocalOffset(FVector(SpeedX, 0, 0));
|
||||||
|
|
||||||
if (mousePosY < .995) // if not touching BOT EDGE
|
if (mousePosY < .995) // not touching BOT EDGE
|
||||||
{
|
{
|
||||||
AddActorLocalOffset(FVector(0, -VertAccelleration, 0));
|
AddActorLocalOffset(FVector(0, -VertAccelleration, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AxisValue > .0 && mousePosX >= .995) // if mouse moving RIGHT and touching EDGE
|
if (AxisValue > .0 && mousePosX >= .995) // mouse moving RIGHT && touching EDGE
|
||||||
{
|
{
|
||||||
////// Add RIGHT accelleration
|
////// Add RIGHT accelleration
|
||||||
SpeedX = AxisValue * ScrollAccelleration;
|
SpeedX = AxisValue * ScrollAccelleration;
|
||||||
@ -149,18 +144,18 @@ void AAdventureCameraPawn::EdgeScrollVert(float AxisValue)
|
|||||||
float mousePosX = mouseX / ViewSize.X;
|
float mousePosX = mouseX / ViewSize.X;
|
||||||
float SideAccelleration = GetInputAxisValue("Mouse X") * (ScrollAccelleration * .75);
|
float SideAccelleration = GetInputAxisValue("Mouse X") * (ScrollAccelleration * .75);
|
||||||
|
|
||||||
if (mousePosY <= ESASize) // if in TOP area
|
if (mousePosY <= ESASize) // in TOP area
|
||||||
{
|
{
|
||||||
////// Scroll TOP
|
////// Scroll TOP
|
||||||
float SpeedY = (mousePosY * ESAMinBoundSlope + ESAMinBoundIntercept) * BaseScrollSpeed;
|
float SpeedY = (mousePosY * ESAMinBoundSlope + ESAMinBoundIntercept) * BaseScrollSpeed;
|
||||||
AddActorLocalOffset(FVector(0, -SpeedY, 0));
|
AddActorLocalOffset(FVector(0, -SpeedY, 0));
|
||||||
|
|
||||||
if (mousePosX > .005) // if not touching EDGE
|
if (mousePosX > .005) // not touching EDGE
|
||||||
{
|
{
|
||||||
AddActorLocalOffset(FVector(SideAccelleration, 0, 0));
|
AddActorLocalOffset(FVector(SideAccelleration, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AxisValue > .0 && mousePosY <= .005) // if mouse moving TOP and touching EDGE
|
if (AxisValue > .0 && mousePosY <= .005) // mouse moving TOP && touching EDGE
|
||||||
{
|
{
|
||||||
////// Add TOP accelleration
|
////// Add TOP accelleration
|
||||||
SpeedY = AxisValue * ScrollAccelleration;
|
SpeedY = AxisValue * ScrollAccelleration;
|
||||||
@ -168,18 +163,18 @@ void AAdventureCameraPawn::EdgeScrollVert(float AxisValue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mousePosY >= 1-ESASize) // if in BOTTOM area
|
if (mousePosY >= 1-ESASize) // in BOTTOM area
|
||||||
{
|
{
|
||||||
////// Scroll BOTTOM
|
////// Scroll BOTTOM
|
||||||
float SpeedY = (mousePosY * ESAMaxBoundSlope + ESAMaxBoundIntercept) * BaseScrollSpeed;
|
float SpeedY = (mousePosY * ESAMaxBoundSlope + ESAMaxBoundIntercept) * BaseScrollSpeed;
|
||||||
AddActorLocalOffset(FVector(0, SpeedY, 0));
|
AddActorLocalOffset(FVector(0, SpeedY, 0));
|
||||||
|
|
||||||
if (mousePosX < .995) // if not touching BOT EDGE
|
if (mousePosX < .995) // not touching BOT EDGE
|
||||||
{
|
{
|
||||||
AddActorLocalOffset(FVector(SideAccelleration, 0, 0));
|
AddActorLocalOffset(FVector(SideAccelleration, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AxisValue < .0 && mousePosY >= .995) // if mouse moving BOTTOM and touching EDGE
|
if (AxisValue < .0 && mousePosY >= .995) // mouse moving BOTTOM && touching EDGE
|
||||||
{
|
{
|
||||||
////// add BOTTOM accelleration
|
////// add BOTTOM accelleration
|
||||||
SpeedY = AxisValue * ScrollAccelleration;
|
SpeedY = AxisValue * ScrollAccelleration;
|
||||||
|
@ -25,28 +25,62 @@ AMovementArrow::AMovementArrow()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AMovementArrow::SetVariant(FHexVector InVector, FHexVector OutVector) {
|
||||||
|
|
||||||
void AMovementArrow::SetVariant(FHexVector InVec, FHexVector OutVec) {
|
int32 InVectorIndex = MapRef->UnitVectors.Find(InVector);
|
||||||
|
int32 OutVectorIndex = MapRef->UnitVectors.Find(OutVector);
|
||||||
|
int32 VariantIndex;
|
||||||
|
|
||||||
int32 InVecIndex = MapRef->UnitVectors.Find(InVec);
|
if (InVectorIndex == 0)
|
||||||
|
{
|
||||||
SceneComponent->SetRelativeRotation(FRotator(0, InVecIndex * 60.f, 0));
|
if (OutVectorIndex == 0) { VariantIndex = 0; }
|
||||||
|
if (OutVectorIndex == 1) { VariantIndex = 1; }
|
||||||
int32 OutVecIndex = MapRef->UnitVectors.Find(OutVec);
|
if (OutVectorIndex == 2) { VariantIndex = 2; }
|
||||||
|
if (OutVectorIndex == 4) { VariantIndex = 3; }
|
||||||
|
if (OutVectorIndex == 5) { VariantIndex = 4; }
|
||||||
int32 BackMotion = (InVecIndex + 3) % 6;
|
}
|
||||||
if (BackMotion < 0) { BackMotion = (((InVecIndex + 3) % 6) + 6) % 6; } // c++ modulus weirdness
|
if (InVectorIndex == 1)
|
||||||
|
{
|
||||||
if (InVecIndex < BackMotion && OutVecIndex > BackMotion) {
|
if (OutVectorIndex == 0) { VariantIndex = 4; }
|
||||||
OutVecIndex--; }
|
if (OutVectorIndex == 1) { VariantIndex = 0; }
|
||||||
if (InVecIndex > BackMotion && OutVecIndex < BackMotion) {
|
if (OutVectorIndex == 2) { VariantIndex = 1; }
|
||||||
InVecIndex--; }
|
if (OutVectorIndex == 3) { VariantIndex = 2; }
|
||||||
|
if (OutVectorIndex == 5) { VariantIndex = 3; }
|
||||||
|
}
|
||||||
int32 VariantIndex = (OutVecIndex - InVecIndex) % 5;
|
if (InVectorIndex == 2)
|
||||||
if (VariantIndex < 0) { VariantIndex = ((OutVecIndex - InVecIndex) % 5 + 5) % 5; } // c++ modulus weirdness
|
{
|
||||||
|
if (OutVectorIndex == 0) { VariantIndex = 3; }
|
||||||
|
if (OutVectorIndex == 1) { VariantIndex = 4; }
|
||||||
|
if (OutVectorIndex == 2) { VariantIndex = 0; }
|
||||||
|
if (OutVectorIndex == 3) { VariantIndex = 1; }
|
||||||
|
if (OutVectorIndex == 4) { VariantIndex = 2; }
|
||||||
|
}
|
||||||
|
if (InVectorIndex == 3)
|
||||||
|
{
|
||||||
|
if (OutVectorIndex == 1) { VariantIndex = 3; }
|
||||||
|
if (OutVectorIndex == 2) { VariantIndex = 4; }
|
||||||
|
if (OutVectorIndex == 3) { VariantIndex = 0; }
|
||||||
|
if (OutVectorIndex == 4) { VariantIndex = 1; }
|
||||||
|
if (OutVectorIndex == 5) { VariantIndex = 2; }
|
||||||
|
}
|
||||||
|
if (InVectorIndex == 4)
|
||||||
|
{
|
||||||
|
if (OutVectorIndex == 0) { VariantIndex = 2; }
|
||||||
|
if (OutVectorIndex == 2) { VariantIndex = 3; }
|
||||||
|
if (OutVectorIndex == 3) { VariantIndex = 4; }
|
||||||
|
if (OutVectorIndex == 4) { VariantIndex = 0; }
|
||||||
|
if (OutVectorIndex == 5) { VariantIndex = 1; }
|
||||||
|
}
|
||||||
|
if (InVectorIndex == 5)
|
||||||
|
{
|
||||||
|
if (OutVectorIndex == 0) { VariantIndex = 1; }
|
||||||
|
if (OutVectorIndex == 1) { VariantIndex = 2; }
|
||||||
|
if (OutVectorIndex == 3) { VariantIndex = 3; }
|
||||||
|
if (OutVectorIndex == 4) { VariantIndex = 4; }
|
||||||
|
if (OutVectorIndex == 5) { VariantIndex = 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
SceneComponent->SetRelativeRotation(FRotator(0, InVectorIndex * 60.f, 0));
|
||||||
MeshVariants[VariantIndex]->ToggleVisibility();
|
MeshVariants[VariantIndex]->ToggleVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Variant")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Variant")
|
||||||
TArray<UStaticMeshComponent*> MeshVariants;
|
TArray<UStaticMeshComponent*> MeshVariants;
|
||||||
UFUNCTION(BlueprintCallable, Category = "Variant")
|
UFUNCTION(BlueprintCallable, Category = "Variant")
|
||||||
void SetVariant(FHexVector InVec, FHexVector OutVec);
|
void SetVariant(FHexVector InVector, FHexVector OutVector);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Called when the game starts or when spawned
|
// Called when the game starts or when spawned
|
||||||
|
Loading…
Reference in New Issue
Block a user