diff --git a/Content/Audio/Voice/29.uasset b/Content/Audio/Voice/29.uasset new file mode 100644 index 0000000..0e4ff79 Binary files /dev/null and b/Content/Audio/Voice/29.uasset differ diff --git a/Content/Audio/Voice/29.wav b/Content/Audio/Voice/29.wav new file mode 100644 index 0000000..8c6acaf Binary files /dev/null and b/Content/Audio/Voice/29.wav differ diff --git a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/DoorButtonA_BP.uasset b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/DoorButtonA_BP.uasset index 587dba2..30246f0 100644 Binary files a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/DoorButtonA_BP.uasset and b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/DoorButtonA_BP.uasset differ diff --git a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor.uasset b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor.uasset index 5c37b77..54d676c 100644 Binary files a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor.uasset and b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/KeyPad_Actor.uasset differ diff --git a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset index 976a687..7a68b01 100644 Binary files a/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset and b/Content/EVERYTHINGPROGRAMMINGRELATED/Blueprints/SlideDoorButton_BP.uasset differ diff --git a/Content/Levels/NewWorld_BuiltData.uasset b/Content/Levels/NewWorld_BuiltData.uasset new file mode 100644 index 0000000..5148ffb Binary files /dev/null and b/Content/Levels/NewWorld_BuiltData.uasset differ diff --git a/Content/Levels/TestLevelForMechanics.umap b/Content/Levels/TestLevelForMechanics.umap index 77397b0..462345e 100644 Binary files a/Content/Levels/TestLevelForMechanics.umap and b/Content/Levels/TestLevelForMechanics.umap differ diff --git a/Content/Levels/VillaDesign.umap b/Content/Levels/VillaDesign.umap index b4832cf..8213b9f 100644 Binary files a/Content/Levels/VillaDesign.umap and b/Content/Levels/VillaDesign.umap differ diff --git a/Source/BuildingEscape/MovingActor.cpp b/Source/BuildingEscape/MovingActor.cpp new file mode 100644 index 0000000..e54120e --- /dev/null +++ b/Source/BuildingEscape/MovingActor.cpp @@ -0,0 +1,68 @@ +#include "MovingActor.h" + +#include "Components/AudioComponent.h" +#include "Kismet/GameplayStatics.h" + +UMovingActor::UMovingActor() +{ + PrimaryComponentTick.bCanEverTick = true; +} + +void UMovingActor::BeginPlay() +{ + Super::BeginPlay(); +} + +void UMovingActor::Move() +{ + targetLocation = GetOwner()->GetActorLocation(); + targetLocation.X += MovementTarget; + tempLocation = FVector(MovementSpeed, 0.0f, 0.0f); + if (Negative) + { + targetLocation.X -= MovementTarget; + targetLocation.Y += MovementTarget; + tempLocation = FVector(0.0f, MovementSpeed, 0.0f); + } + this->targetLocation = targetLocation; + this->moving = true; + + TArray Audios; + GetOwner()->GetComponents(Audios); + + if (Audios.Num() == 0) return; + if (soundHasBeenPlayed) return; + + for (auto Audio : Audios) + { + if (Audio->ComponentHasTag("location")) + { + UGameplayStatics::PlaySoundAtLocation(GetOwner(), Audio->Sound, GetOwner()->GetActorLocation(), + GetOwner()->GetActorRotation(), 1, 1, 0, + Audio->AttenuationSettings, nullptr, GetOwner()); + } + else + { + Audio->Play(); + } + } + + soundHasBeenPlayed = true; +} + + +void UMovingActor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +{ + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + if (moving) + { + FVector Location = GetOwner()->GetActorLocation(); + if (Location.Equals(targetLocation, 1.0f)) + { + moving = false; + } + else + GetOwner()->SetActorLocation(Location + tempLocation); + } +} diff --git a/Source/BuildingEscape/MovingActor.h b/Source/BuildingEscape/MovingActor.h new file mode 100644 index 0000000..0c3be18 --- /dev/null +++ b/Source/BuildingEscape/MovingActor.h @@ -0,0 +1,44 @@ +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework//Actor.h" +#include "Components/ActorComponent.h" +#include "MovingActor.generated.h" + + +UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +class BUILDINGESCAPE_API UMovingActor : public UActorComponent +{ + GENERATED_BODY() + +public: + // Sets default values for this component's properties + UMovingActor(); + +protected: + // Called when the game starts + virtual void BeginPlay() override; + + UFUNCTION(BlueprintCallable) + void Move(); + +public: + // Called every frame + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; + + UPROPERTY(EditAnywhere) + float MovementSpeed = 15.f; + + UPROPERTY(EditAnywhere) + float MovementTarget = 10.f; + + UPROPERTY(EditAnywhere) + bool Negative = false; + +private: + bool moving; + bool soundHasBeenPlayed; + FVector targetLocation; + FVector tempLocation; +}; diff --git a/Source/BuildingEscape/RotatingActor.cpp b/Source/BuildingEscape/RotatingActor.cpp index 4beda22..d013f8b 100644 --- a/Source/BuildingEscape/RotatingActor.cpp +++ b/Source/BuildingEscape/RotatingActor.cpp @@ -1,6 +1,7 @@ #include "RotatingActor.h" #include "Components/AudioComponent.h" +#include "Kismet/GameplayStatics.h" URotatingActor::URotatingActor() diff --git a/Source/BuildingEscape/RotatingActor.h b/Source/BuildingEscape/RotatingActor.h index 9022f0d..31f322e 100644 --- a/Source/BuildingEscape/RotatingActor.h +++ b/Source/BuildingEscape/RotatingActor.h @@ -3,8 +3,6 @@ #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Components/ActorComponent.h" -#include "Kismet//GameplayStatics.h" - #include "RotatingActor.generated.h" @@ -22,7 +20,7 @@ protected: void Rotate(FRotator TargetRotation); - UFUNCTION() + UFUNCTION(BlueprintCallable) void Rotate(); public: