51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "UI/GameUserWidget.h"
|
|
#include "Core/LuckyRobotsGameInstance.h"
|
|
|
|
void UGameUserWidget::NativeConstruct()
|
|
{
|
|
Super::NativeConstruct();
|
|
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
if (GameInstance)
|
|
{
|
|
GameInstance->GameUserWidget = this;
|
|
}
|
|
}
|
|
|
|
void UGameUserWidget::DoWaitSecond()
|
|
{
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
if (GameInstance)
|
|
{
|
|
if (GameInstance->bIsFirstOpenGame)
|
|
{
|
|
DownCount = 3;
|
|
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
|
GetWorld()->GetTimerManager().SetTimer(UpdateDownCountTimerHandle, this, &UGameUserWidget::UpdateDownCount, 1.0f, true);
|
|
|
|
UpdateDownCount();
|
|
}
|
|
}
|
|
}
|
|
|
|
void UGameUserWidget::UpdateDownCount()
|
|
{
|
|
if (DownCount > 0)
|
|
{
|
|
DownCountStr = FString::FromInt(DownCount);
|
|
DownCount--;
|
|
}
|
|
else
|
|
{
|
|
DownCountStr = "";
|
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
|
if (GameInstance)
|
|
{
|
|
GameInstance->DoQualitySettings(0, true);
|
|
}
|
|
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
|
|
}
|
|
} |