|
@@ -9,6 +9,8 @@
|
|
|
#include "Components/CapsuleComponent.h"
|
|
|
|
|
|
#include "VRHUDBase.h"
|
|
|
+#include "VRGroupBase.h"
|
|
|
+
|
|
|
|
|
|
static FName FirstPersonCameraName(TEXT("FirstPersonCamera"));
|
|
|
|
|
@@ -30,21 +32,21 @@ AVRCharacterBase::AVRCharacterBase(const FObjectInitializer& ObjectInitializer):
|
|
|
FirstPersonCamera->SetupAttachment(GetCapsuleComponent());
|
|
|
}
|
|
|
|
|
|
- MyTimeline.SetTimelineLength(2);
|
|
|
+ BeginWaitConnected_Timeline.SetTimelineLength(2);
|
|
|
|
|
|
- MyCurveFloat = CreateDefaultSubobject<UCurveFloat>(FName("MyCurveFloat"));
|
|
|
- if (MyCurveFloat) {
|
|
|
- MyCurveFloat->FloatCurve.AddKey(0, 0);
|
|
|
- MyCurveFloat->FloatCurve.AddKey(2, 100);
|
|
|
+ CurveFloat = CreateDefaultSubobject<UCurveFloat>(FName("CurveFloat"));
|
|
|
+ if (CurveFloat) {
|
|
|
+ CurveFloat->FloatCurve.AddKey(0, 0);
|
|
|
+ CurveFloat->FloatCurve.AddKey(2, 100);
|
|
|
}
|
|
|
|
|
|
FOnTimelineFloatStatic onTimelineUpdate;
|
|
|
- onTimelineUpdate.BindUFunction(this, FName("OnTimelineUpdate"));
|
|
|
- MyTimeline.AddInterpFloat(MyCurveFloat, onTimelineUpdate);
|
|
|
+ onTimelineUpdate.BindUFunction(this, FName("OnBeginWaitConnected_TimelineUpdate"));
|
|
|
+ BeginWaitConnected_Timeline.AddInterpFloat(CurveFloat, onTimelineUpdate);
|
|
|
|
|
|
FOnTimelineEventStatic onTimelineFinished;
|
|
|
- onTimelineFinished.BindUFunction(this, FName("OnTimelineFinished"));
|
|
|
- MyTimeline.SetTimelineFinishedFunc(onTimelineFinished);
|
|
|
+ onTimelineFinished.BindUFunction(this, FName("OnBeginWaitConnected_TimelineFinished"));
|
|
|
+ BeginWaitConnected_Timeline.SetTimelineFinishedFunc(onTimelineFinished);
|
|
|
}
|
|
|
|
|
|
// Called when the game starts or when spawned
|
|
@@ -59,7 +61,7 @@ void AVRCharacterBase::Tick(float DeltaTime)
|
|
|
{
|
|
|
Super::Tick(DeltaTime);
|
|
|
|
|
|
- MyTimeline.TickTimeline(DeltaTime);
|
|
|
+ BeginWaitConnected_Timeline.TickTimeline(DeltaTime);
|
|
|
}
|
|
|
|
|
|
// Called to bind functionality to input
|
|
@@ -98,23 +100,48 @@ void AVRCharacterBase::LookUp(float value) {
|
|
|
void AVRCharacterBase::BeginWaitConnected() {
|
|
|
UE_LOG(LogTemp, Warning, TEXT("AVRCharacterBase::BeginWaitConnected"));
|
|
|
|
|
|
- MyTimeline.PlayFromStart();
|
|
|
+ BeginWaitConnected_Timeline.PlayFromStart();
|
|
|
+}
|
|
|
+
|
|
|
+void AVRCharacterBase::CreateGroup() {
|
|
|
+ if (IsInGroup()) {
|
|
|
+ UE_LOG(LogTemp, Warning, TEXT("已在阵列中"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ GetCapsuleComponent()->SetCollisionResponseToChannel(ECollisionChannel::ECC_Pawn, ECollisionResponse::ECR_Overlap);
|
|
|
+
|
|
|
+ AVRGroupBase* group = GetWorld()->SpawnActor<AVRGroupBase>();
|
|
|
+ group->SetActorTransform(GetActorTransform());
|
|
|
+
|
|
|
+ AttachToActor(group, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, EAttachmentRule::SnapToTarget, true), NAME_None);
|
|
|
+ AddActorLocalOffset(FVector(0, 0, 0));
|
|
|
+ SetActorRotation(FRotator(0, 0, 0));
|
|
|
}
|
|
|
|
|
|
-void AVRCharacterBase::OnTimelineUpdate(float value) {
|
|
|
+bool AVRCharacterBase::IsInGroup() {
|
|
|
+ AActor* parent = GetAttachParentActor();
|
|
|
+ return parent != nullptr;
|
|
|
+}
|
|
|
+
|
|
|
+void AVRCharacterBase::OnBeginWaitConnected_TimelineUpdate(float value) {
|
|
|
UE_LOG(LogTemp, Warning, TEXT("AVRCharacterBase::OnTimelineUpdate: %f"), value);
|
|
|
|
|
|
+ AVRHUDBase* hud = Cast<AVRHUDBase>(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetHUD());
|
|
|
+ hud->UpdateProgress((int)value);
|
|
|
}
|
|
|
|
|
|
-void AVRCharacterBase::OnTimelineFinished() {
|
|
|
+void AVRCharacterBase::OnBeginWaitConnected_TimelineFinished() {
|
|
|
UE_LOG(LogTemp, Warning, TEXT("AVRCharacterBase::OnTimelineFinished"));
|
|
|
|
|
|
+ AVRHUDBase* hud = Cast<AVRHUDBase>(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetHUD());
|
|
|
+ hud->UpdateProgress(100);
|
|
|
+
|
|
|
+ CreateGroup();
|
|
|
}
|
|
|
|
|
|
void AVRCharacterBase::Test() {
|
|
|
UGameInstance *gameInstance = GetGameInstance();
|
|
|
-
|
|
|
- AVRHUDBase* hud = Cast<AVRHUDBase>(UGameplayStatics::GetPlayerController(GetWorld(), 0)->GetHUD());
|
|
|
- hud->Test();
|
|
|
+
|
|
|
|
|
|
}
|