34 lines
751 B
C++
34 lines
751 B
C++
// 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);
|
|
}
|