Skip to content

Commit

Permalink
Ships now correctly work :)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrisonv789 committed Apr 22, 2022
1 parent 5860f8d commit 13e52bd
Show file tree
Hide file tree
Showing 25 changed files with 349 additions and 66 deletions.
Binary file modified A2_Goals/Content/Blueprints/BP_Gold.uasset
Binary file not shown.
Binary file modified A2_Goals/Content/Blueprints/BP_Ship.uasset
Binary file not shown.
Binary file modified A2_Goals/Content/Levels/MainLevel.umap
Binary file not shown.
Binary file modified A2_Goals/Content/Materials/Mat_Ship.uasset
Binary file not shown.
Binary file added A2_Goals/Content/Textures/action.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added A2_Goals/Content/Textures/action.uasset
Binary file not shown.
Binary file added A2_Goals/Content/Textures/idle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added A2_Goals/Content/Textures/idle.uasset
Binary file not shown.
Binary file added A2_Goals/Content/Textures/movement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added A2_Goals/Content/Textures/movement.uasset
Binary file not shown.
Binary file added A2_Goals/Content/Textures/view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added A2_Goals/Content/Textures/view.uasset
Binary file not shown.
Binary file modified A2_Goals/Content/UI/MainInterface.uasset
Binary file not shown.
Binary file modified A2_Goals/Content/UI/ShipInformation.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ void CollectResourceAction::Reset()
// Ensure the in range is false
SetInRange(false);
Target = nullptr;
TargetNode = nullptr;
ResourceGathered = 0;
ActionTime = 0.0;
}
Expand All @@ -49,14 +50,15 @@ bool CollectResourceAction::CheckProceduralPreconditions(AShip* ship)
return false;

// Calculate the nearest resource
GridNode* goalNode = ship->Level->CalculateNearestGoal(ship->XPos, ship->YPos, ResourceType);
GridNode* goalNode = ship->Level->CalculateNearestGoal(ship->XPos, ship->YPos, ResourceType, true);

// Check if the resource exists
if (!goalNode || !goalNode->ResourceAtLocation)
return false;

// Get the target
Target = goalNode->ResourceAtLocation;
TargetNode = goalNode;

// Get the distance to the target
const FVector distance = ship->GetActorLocation() - Target->GetActorLocation();
Expand Down Expand Up @@ -114,6 +116,7 @@ bool CollectResourceAction::PerformAction(AShip* ship, float deltaTime)
{
// Remove the target
Target = nullptr;
TargetNode = nullptr;

// Decrease the morale
ship->Morale--;
Expand Down
16 changes: 6 additions & 10 deletions A2_Goals/Source/A2_Goals/Private/Actions/CollectTreasureAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void CollectTreasureAction::Reset()
// Ensure the in range is false
SetInRange(false);
Target = nullptr;
TargetNode = nullptr;
TreasureGathered = 0;
ActionTime = 0.0;
}
Expand Down Expand Up @@ -55,13 +56,7 @@ bool CollectTreasureAction::CheckProceduralPreconditions(AShip* ship)

// Get the target
Target = goalNode->ResourceAtLocation;

// Get the distance to the target
const FVector distance = ship->GetActorLocation() - Target->GetActorLocation();

// Check if the distance is less than some amount
// TODO update with some actual collision system
SetInRange(distance.Size() <= 5);
TargetNode = goalNode;

// Return a success
return true;
Expand All @@ -85,12 +80,13 @@ bool CollectTreasureAction::PerformAction(AShip* ship, float deltaTime)
{
// Increase the morale and gold
TreasureGathered++;
ship->Morale = 200;
ship->NumGold++;
ship->Level->CollectGold(goldResource);

// Call the collect gold action
ship->CollectGold(goldResource);

// Remove the target
Target = nullptr;
TargetNode = nullptr;
}

// Return a success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void DepositResourceAction::Reset()
// Ensure the in range is false
SetInRange(false);
Target = nullptr;
TargetNode = nullptr;
ResourcesDeposited = 0;
ActionTime = 0.0;
}
Expand All @@ -52,14 +53,15 @@ bool DepositResourceAction::CheckProceduralPreconditions(AShip* ship)
return false;

// Calculate the nearest resource
GridNode* goalNode = ship->Level->CalculateNearestGoal(ship->XPos, ship->YPos, HOME);
GridNode* goalNode = ship->Level->CalculateNearestGoal(ship->XPos, ship->YPos, HOME, true);

// Check if the resource exists
if (!goalNode || !goalNode->ResourceAtLocation)
return false;

// Get the target
Target = goalNode->ResourceAtLocation;
TargetNode = goalNode;

// Get the distance to the target
const FVector distance = ship->GetActorLocation() - Target->GetActorLocation();
Expand Down Expand Up @@ -117,6 +119,7 @@ bool DepositResourceAction::PerformAction(AShip* ship, float deltaTime)
{
// Remove the target
Target = nullptr;
TargetNode = nullptr;

// Decrease the morale
ship->Morale--;
Expand Down
Loading

0 comments on commit 13e52bd

Please sign in to comment.