feat: Dialogue
This commit is contained in:
parent
abc13be7d4
commit
2ee75d30c4
Binary file not shown.
|
|
@ -82,6 +82,8 @@ void AExoPlayerCharacter::BeginPlay()
|
||||||
PlayerHud->SetVisibilityAmmo(false);
|
PlayerHud->SetVisibilityAmmo(false);
|
||||||
PlayerHud->SetVisibilityViewFinder(false);
|
PlayerHud->SetVisibilityViewFinder(false);
|
||||||
PlayerHud->SetShootingViewFinder(false);
|
PlayerHud->SetShootingViewFinder(false);
|
||||||
|
PlayerHud->SetVisibilityDialogue(false);
|
||||||
|
PlayerHud->SetDialogueText(FText::FromString(TEXT("Przykładowy tekst")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,12 @@ void UWBP_PlayerUI::SetAmmoNumber(int ammo)
|
||||||
AmmoText->SetText(FText::AsNumber(ammo));
|
AmmoText->SetText(FText::AsNumber(ammo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UWBP_PlayerUI::SetDialogueText(FText text)
|
||||||
|
{
|
||||||
|
timerDialogue = 0.0f;
|
||||||
|
textDialogue = text;
|
||||||
|
}
|
||||||
|
|
||||||
UUWBP_Buf* UWBP_PlayerUI::AddBuf(UTexture2D* texture, float procent)
|
UUWBP_Buf* UWBP_PlayerUI::AddBuf(UTexture2D* texture, float procent)
|
||||||
{
|
{
|
||||||
if (!BufClass)
|
if (!BufClass)
|
||||||
|
|
@ -93,6 +99,11 @@ void UWBP_PlayerUI::SetShootingViewFinder(bool Shooting)
|
||||||
shootingViewFinder=Shooting;
|
shootingViewFinder=Shooting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UWBP_PlayerUI::SetVisibilityDialogue(bool visibility)
|
||||||
|
{
|
||||||
|
showDialogue=visibility;
|
||||||
|
}
|
||||||
|
|
||||||
void UWBP_PlayerUI::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
void UWBP_PlayerUI::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||||
{
|
{
|
||||||
Super::NativeTick(MyGeometry, InDeltaTime);
|
Super::NativeTick(MyGeometry, InDeltaTime);
|
||||||
|
|
@ -102,7 +113,17 @@ void UWBP_PlayerUI::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||||
opacityViewFinder = FMath::Clamp(opacityViewFinder + showSpeed * (showViewFinder?1:-1), 0.0f, 1.0f);
|
opacityViewFinder = FMath::Clamp(opacityViewFinder + showSpeed * (showViewFinder?1:-1), 0.0f, 1.0f);
|
||||||
opacityBuf = FMath::Clamp(opacityBuf + showSpeed * (showBuf?1:-1), 0.0f, 1.0f);
|
opacityBuf = FMath::Clamp(opacityBuf + showSpeed * (showBuf?1:-1), 0.0f, 1.0f);
|
||||||
opacityAmmo = FMath::Clamp(opacityAmmo + showSpeed * (showAmmo?1:-1), 0.0f, 1.0f);
|
opacityAmmo = FMath::Clamp(opacityAmmo + showSpeed * (showAmmo?1:-1), 0.0f, 1.0f);
|
||||||
|
opacityDialogue = FMath::Clamp(opacityDialogue + showSpeed * (showDialogue?1:-1), 0.0f, 1.0f);
|
||||||
shootingViewFinderPercent=FMath::Clamp(shootingViewFinderPercent + showSpeed * (shootingViewFinder?1:-1), 0.0f, 1.0f);
|
shootingViewFinderPercent=FMath::Clamp(shootingViewFinderPercent + showSpeed * (shootingViewFinder?1:-1), 0.0f, 1.0f);
|
||||||
|
timerDialogue += DialogueSpeed * InDeltaTime;
|
||||||
|
|
||||||
|
FString OriginalString = textDialogue.ToString();
|
||||||
|
int textDialogueSize = OriginalString.Len() * FMath::Clamp(timerDialogue / DialogueSpeed, 0.0f, 1.0f);
|
||||||
|
FString Substring = OriginalString.Left(textDialogueSize);
|
||||||
|
FText text = FText::FromString(Substring);
|
||||||
|
|
||||||
|
if (DialogueText)
|
||||||
|
DialogueText->SetText(text);
|
||||||
if (HPBar)
|
if (HPBar)
|
||||||
HPBar->SetRenderOpacity(opacityHp);
|
HPBar->SetRenderOpacity(opacityHp);
|
||||||
if (ViewFinder)
|
if (ViewFinder)
|
||||||
|
|
@ -111,6 +132,8 @@ void UWBP_PlayerUI::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||||
BufPanel->SetRenderOpacity(opacityBuf);
|
BufPanel->SetRenderOpacity(opacityBuf);
|
||||||
if (AmmoImage)
|
if (AmmoImage)
|
||||||
AmmoPanel->SetRenderOpacity(opacityAmmo);
|
AmmoPanel->SetRenderOpacity(opacityAmmo);
|
||||||
|
if (DialoguePanel)
|
||||||
|
DialoguePanel->SetRenderOpacity(opacityDialogue);
|
||||||
if (!DynamicViewFinderMaterial)
|
if (!DynamicViewFinderMaterial)
|
||||||
{
|
{
|
||||||
if (!ViewFinder)
|
if (!ViewFinder)
|
||||||
|
|
@ -129,8 +152,9 @@ void UWBP_PlayerUI::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||||
}
|
}
|
||||||
if (DynamicViewFinderMaterial)
|
if (DynamicViewFinderMaterial)
|
||||||
{
|
{
|
||||||
DynamicViewFinderMaterial->SetScalarParameterValue("Percent",shootingViewFinderPercent);
|
float changeViewFinderProcent=FMath::Clamp( FMath::Pow(shootingViewFinderPercent,3),0,1.0f);
|
||||||
ViewFinder->SetRenderScale(FVector2D(1.0f, 1.0f)*((1.0f-shootingViewFinderPercent)*3+1));
|
DynamicViewFinderMaterial->SetScalarParameterValue("Percent",changeViewFinderProcent);
|
||||||
|
ViewFinder->SetRenderScale(FVector2D(1.0f, 1.0f)*((1.0f-changeViewFinderProcent)*3+1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ public:
|
||||||
|
|
||||||
void SetAmmoNumber(int ammo);
|
void SetAmmoNumber(int ammo);
|
||||||
|
|
||||||
|
void SetDialogueText(FText text);
|
||||||
|
|
||||||
UUWBP_Buf* AddBuf(UTexture2D* texture,float procent);
|
UUWBP_Buf* AddBuf(UTexture2D* texture,float procent);
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, meta = (BindWidget))
|
UPROPERTY(EditAnywhere, meta = (BindWidget))
|
||||||
|
|
@ -42,6 +44,12 @@ public:
|
||||||
UPROPERTY(EditAnywhere, meta = (BindWidget))
|
UPROPERTY(EditAnywhere, meta = (BindWidget))
|
||||||
class UCanvasPanel* AmmoPanel;
|
class UCanvasPanel* AmmoPanel;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, meta = (BindWidget))
|
||||||
|
class UCanvasPanel* DialoguePanel;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, meta = (BindWidget))
|
||||||
|
class UTextBlock* DialogueText;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buf")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Buf")
|
||||||
float BufRange;
|
float BufRange;
|
||||||
|
|
||||||
|
|
@ -55,7 +63,10 @@ public:
|
||||||
TMap<EAmmoType, UTexture2D*> AmmoIconMap;
|
TMap<EAmmoType, UTexture2D*> AmmoIconMap;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Display")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Display")
|
||||||
float DisplaySpeed=1.0f;
|
float DisplaySpeed = 1.0f;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Display")
|
||||||
|
float DialogueSpeed = 0.1f;
|
||||||
|
|
||||||
void SetVisibilityHP(bool visibility);
|
void SetVisibilityHP(bool visibility);
|
||||||
|
|
||||||
|
|
@ -66,6 +77,8 @@ public:
|
||||||
void SetVisibilityViewFinder(bool visibility);
|
void SetVisibilityViewFinder(bool visibility);
|
||||||
|
|
||||||
void SetShootingViewFinder(bool Shooting);
|
void SetShootingViewFinder(bool Shooting);
|
||||||
|
|
||||||
|
void SetVisibilityDialogue(bool visibility);
|
||||||
protected:
|
protected:
|
||||||
void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
|
void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
|
||||||
private:
|
private:
|
||||||
|
|
@ -73,10 +86,12 @@ private:
|
||||||
|
|
||||||
void updateBufPosition();
|
void updateBufPosition();
|
||||||
|
|
||||||
bool showHp = true, showBuf = true, showAmmo = true, showViewFinder = true;
|
bool showHp = true, showBuf = true, showAmmo = true, showViewFinder = true, showDialogue = true;
|
||||||
float opacityHp = 1.0f, opacityBuf = 1.0f, opacityAmmo = 1.0f, opacityViewFinder = 1.0f;
|
float opacityHp = 1.0f, opacityBuf = 1.0f, opacityAmmo = 1.0f, opacityViewFinder = 1.0f, opacityDialogue = 1.0f;
|
||||||
bool shootingViewFinder = false;
|
bool shootingViewFinder = false;
|
||||||
float shootingViewFinderPercent = 1.0f;
|
float shootingViewFinderPercent = 1.0f;
|
||||||
|
float timerDialogue = 0.0f;
|
||||||
|
FText textDialogue = FText();
|
||||||
|
|
||||||
UMaterialInstanceDynamic* DynamicViewFinderMaterial = nullptr;
|
UMaterialInstanceDynamic* DynamicViewFinderMaterial = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user