diff --git a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml index 26ec9752..986497e0 100644 --- a/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml +++ b/EndlessVendetta/.idea/.idea.EndlessVendetta/.idea/workspace.xml @@ -9,12 +9,12 @@ - - + - + + diff --git a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset index c330a926..4f45626b 100644 --- a/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset +++ b/EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:22cfe5fb6fc5e12348a76a250e903d182d8950b6cb54aba5a557ed0a643791e5 -size 68896 +oid sha256:84374622c6dc77769d398e52fdd2dcacc7eab0bc4c651ac6ec3b77a019ed52f7 +size 68984 diff --git a/EndlessVendetta/Content/Levels/ControlTutorialLevel.umap b/EndlessVendetta/Content/Levels/ControlTutorialLevel.umap index 3862df88..359490de 100644 --- a/EndlessVendetta/Content/Levels/ControlTutorialLevel.umap +++ b/EndlessVendetta/Content/Levels/ControlTutorialLevel.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1ee3f51a8d0ecfc39ba48c02249d224bdc21f8f9b52d06a2aaa4413ba55a6774 -size 3231094 +oid sha256:40716dd78ee18731e93233dd0ed13c534868e5e9521a172e8a033011af33363d +size 3336963 diff --git a/EndlessVendetta/Content/Ships/BP_SpaceShip.uasset b/EndlessVendetta/Content/Ships/BP_SpaceShip.uasset new file mode 100644 index 00000000..ee98ed7e --- /dev/null +++ b/EndlessVendetta/Content/Ships/BP_SpaceShip.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1886d755131470b6eac1e0d6c44cbf4295254703c8f65eb5e2b71b380fd3de6d +size 37174 diff --git a/EndlessVendetta/Content/Ships/LandingZone.uasset b/EndlessVendetta/Content/Ships/LandingZone.uasset new file mode 100644 index 00000000..b757b91a --- /dev/null +++ b/EndlessVendetta/Content/Ships/LandingZone.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db9d0fc8ce80a02b1e98bac5b9cde0ccfe6a8af33090148f6179911d95b82519 +size 95888 diff --git a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset index 697d1706..5e3ff30e 100644 --- a/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset +++ b/EndlessVendetta/Content/StarterContent/Audio/Collapse01.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5c4e5e6a2bbbcd4c8e63f770bb9bff4a91a850382515bcb53bf41117339d495d -size 353648 +oid sha256:85c827023ee4b466228ec65e92b4b4a0415a106de041ac1c2cab481a2a5dfa8d +size 348532 diff --git a/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset b/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset index bf2e4391..01a79a1d 100644 --- a/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset +++ b/EndlessVendetta/Content/StarterContent/Particles/P_Ambient_Dust.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:01ef616c7a8bd90cd1b7a13efb18a56f33346efbae51efa31f09804478b7621d -size 43456 +oid sha256:5f0f656076ea54ab67b8dfbc812f47028550c19f3b4db815d1937d0edbb5d02a +size 53268 diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 00b74640..5b4f0f94 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -550,6 +550,12 @@ void AEndlessVendettaCharacter::Move(const FInputActionValue& Value) // input is a Vector2D FVector2D MovementVector = Value.Get(); + if (PlayerOnShip) + { + SpaceShip->MoveShip(MovementVector); + return; + } + if (Controller != nullptr) { // add movement @@ -611,6 +617,12 @@ void AEndlessVendettaCharacter::Look(const FInputActionValue& Value) // input is a Vector2D FVector2D LookAxisVector = Value.Get(); + if (PlayerOnShip) + { + SpaceShip->RotateShip(LookAxisVector); + return; + } + if (Controller != nullptr) { // add yaw and pitch input to controller @@ -654,4 +666,16 @@ void AEndlessVendettaCharacter::UpdateInventorySize(int Cols, int Rows) { UE_LOG(LogTemp, Warning, TEXT("No Vaild Inventory")); } -} \ No newline at end of file +} + +void AEndlessVendettaCharacter::EnterShip(FTransform TakeoffLoc) +{ + SpaceShip = GetWorld()->SpawnActor(SpaceShipClass, TakeoffLoc.GetLocation(), TakeoffLoc.Rotator()); + PlayerOnShip = true; +} + +void AEndlessVendettaCharacter::ExitShip(FTransform ExitLoc) +{ + UE_LOG(LogTemp, Warning, TEXT("Exitting Ship!!!")); +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h index bcebe73d..07d8cf43 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.h @@ -10,6 +10,7 @@ #include "GadgetSystem/GadgetManager.h" #include "Inventory/InventoryComponent.h" #include "Pawn/VICharacter.h" +#include "SpaceShip/SpaceShip.h" #include "EndlessVendettaCharacter.generated.h" @@ -245,4 +246,14 @@ public: UInventoryComponent* InventoryComponent; UFUNCTION(Exec) void UpdateInventorySize(int Cols, int Rows); + + // Space Ship +private: + bool PlayerOnShip = false; + UPROPERTY(EditDefaultsOnly, Category = "Space Ship") + TSubclassOf SpaceShipClass; + ASpaceShip* SpaceShip; +public: + void ExitShip(FTransform ExitLoc); + void EnterShip(FTransform TakeoffLoc); }; diff --git a/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.cpp b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.cpp new file mode 100644 index 00000000..c8cfc038 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.cpp @@ -0,0 +1,53 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "LandingZone.h" + +#include "EndlessVendetta/EndlessVendettaCharacter.h" +#include "Kismet/GameplayStatics.h" + +// Sets default values +ALandingZone::ALandingZone() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + +void ALandingZone::UpdateAllLandingZones(bool Landing) +{ + TArray AllLandingZones; + UGameplayStatics::GetAllActorsOfClass(GetWorld(), ALandingZone::StaticClass(), AllLandingZones); + for (auto LZ_Actor : AllLandingZones) + { + ALandingZone* LZ = Cast(LZ_Actor); + Landing ? LZ->HideWaypoint() : LZ->ShowWaypoint(); + } +} + +void ALandingZone::Interact() +{ + Takeoff(); +} + +void ALandingZone::InteractPrompt() +{ + +} + +void ALandingZone::Land() +{ + AEndlessVendettaCharacter* PlayerChar = Cast(GetWorld()->GetFirstPlayerController()->GetPawn()); + if (!IsValid(PlayerChar)) return; + UpdateAllLandingZones(true); + PlayerChar->ExitShip(LZ_ExitTransform); +} + +void ALandingZone::Takeoff() +{ + AEndlessVendettaCharacter* PlayerChar = Cast(GetWorld()->GetFirstPlayerController()->GetPawn()); + if (!IsValid(PlayerChar)) return; + UpdateAllLandingZones(false); + PlayerChar->EnterShip(LZ_TakeoffTransform); +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h new file mode 100644 index 00000000..e273fff0 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/LandingZone.h @@ -0,0 +1,46 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "EndlessVendetta/InteractionInterface.h" +#include "GameFramework/Actor.h" +#include "LandingZone.generated.h" + +UCLASS() +class ENDLESSVENDETTA_API ALandingZone : public AActor, public IInteractionInterface +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, Category = "Landing Zone") + FTransform LZ_ExitTransform; + UPROPERTY(EditAnywhere, Category = "Landing Zone") + FTransform LZ_TakeoffTransform; + + // Hides or shows key aesthetic features of LZ's based on if the player is landing or not + void UpdateAllLandingZones(bool Landing); + +protected: + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Landing Zone") + bool IsHomeBase_LZ = false; + + // Allows player to enter their ship through a LZ + void Interact() override; + void InteractPrompt() override; + +public: + // Sets default values for this actor's properties + ALandingZone(); + + // Ran when a player takes off from any LZ in the world + UFUNCTION(BlueprintImplementableEvent) + void ShowWaypoint(); + // Ran when player lands at any LZ in the world + UFUNCTION(BlueprintImplementableEvent) + void HideWaypoint(); + + // Updates all LZ's, then runs exit ship func on player and passes the exit transform + void Land(); + // Updates all LZ's, then runs enter ship func on player passing the correct takeoff transform + void Takeoff(); +}; diff --git a/EndlessVendetta/Source/EndlessVendetta/SpaceShip/SpaceShip.cpp b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/SpaceShip.cpp new file mode 100644 index 00000000..1bfe5124 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/SpaceShip.cpp @@ -0,0 +1,64 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "SpaceShip.h" + +#include "Components/ArrowComponent.h" + +// Sets default values +ASpaceShip::ASpaceShip() +{ + // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; +} + +// Called when the game starts or when spawned +void ASpaceShip::BeginPlay() +{ + Super::BeginPlay(); + + PlayersCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); + PlayersController = PlayersCharacter->GetController(); + TArray SeatComps = GetComponentsByTag(UArrowComponent::StaticClass(), FName("Seat")); + SeatComponent = Cast(SeatComps[0]); +} + +// Called every frame +void ASpaceShip::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + + PlayersCharacter->SetActorLocation(SeatComponent->GetComponentLocation()); + PlayersController->SetControlRotation(GetActorRotation()); +} + +// Called to bind functionality to input +void ASpaceShip::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); + +} + +void ASpaceShip::MoveShip(FVector2D MovementVector) +{ + // Get ships direction vectors, and ignore their pitch + FVector ForwardVector = GetActorForwardVector(); + ForwardVector.Z = 0; + FVector RightVector = GetActorRightVector(); + RightVector.Y += RightVector.Z; + RightVector.Z = 0; + UE_LOG(LogTemp, Warning, TEXT("Forward:%f, Sideways:%f"), MovementVector.Y, MovementVector.X); + AddMovementInput(ForwardVector, MovementVector.Y, true); + AddMovementInput(RightVector, MovementVector.X, true); +} + +void ASpaceShip::RotateShip(FVector2D LookAxisVector) +{ + FRotator shipRotator = GetActorRotation(); + shipRotator.Yaw += LookAxisVector.X; + shipRotator.Pitch -= LookAxisVector.Y; + shipRotator.Pitch = shipRotator.Pitch < -30 ? -30 : shipRotator.Pitch; + shipRotator.Pitch = shipRotator.Pitch > 30 ? 30 : shipRotator.Pitch; + SetActorRotation(shipRotator); +} + diff --git a/EndlessVendetta/Source/EndlessVendetta/SpaceShip/SpaceShip.h b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/SpaceShip.h new file mode 100644 index 00000000..f73ddf23 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/SpaceShip/SpaceShip.h @@ -0,0 +1,37 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Character.h" + +#include "SpaceShip.generated.h" + +UCLASS() +class ENDLESSVENDETTA_API ASpaceShip : public ACharacter +{ + GENERATED_BODY() + + ACharacter* PlayersCharacter; + AController* PlayersController; + UArrowComponent* SeatComponent; + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + // Sets default values for this pawn's properties + ASpaceShip(); + + // Called every frame + virtual void Tick(float DeltaTime) override; + + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + + void MoveShip(FVector2D MovementVector); + + void RotateShip(FVector2D LookAxisVector); + +};