Files
video-record-ue-poc/Source/AudioVideoRecord/Variant_Shooter/ShooterGameMode.cpp

34 lines
751 B
C++
Raw Normal View History

2026-03-11 11:25:15 +05:30
// Copyright Epic Games, Inc. All Rights Reserved.
#include "Variant_Shooter/ShooterGameMode.h"
#include "ShooterUI.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/World.h"
void AShooterGameMode::BeginPlay()
{
Super::BeginPlay();
// create the UI
ShooterUI = CreateWidget<UShooterUI>(UGameplayStatics::GetPlayerController(GetWorld(), 0), ShooterUIClass);
ShooterUI->AddToViewport(0);
}
void AShooterGameMode::IncrementTeamScore(uint8 TeamByte)
{
// retrieve the team score if any
int32 Score = 0;
if (int32* FoundScore = TeamScores.Find(TeamByte))
{
Score = *FoundScore;
}
// increment the score for the given team
++Score;
TeamScores.Add(TeamByte, Score);
// update the UI
ShooterUI->BP_UpdateScore(TeamByte, Score);
}