changed map and added music and sounds

feature-map-and-sounds
m4xxx1m 2 years ago
parent 648d230cd9
commit 6e1fd803f1

@ -19,6 +19,7 @@ ABattleGameMode::ABattleGameMode()
void ABattleGameMode::BeginPlay() { void ABattleGameMode::BeginPlay() {
Super::BeginPlay(); Super::BeginPlay();
// UGameplayStatics::PlaySound2D(GetWorld(), BackgroundSound);
} }
auto ABattleGameMode::GetMyGameState() const { auto ABattleGameMode::GetMyGameState() const {
@ -137,6 +138,8 @@ void ABattleGameMode::PostLogin(APlayerController *NewPlayer) {
// 0-indexation // 0-indexation
Cast<ABattlePlayerController>(NewPlayer)->SetPlayerIndex( Cast<ABattlePlayerController>(NewPlayer)->SetPlayerIndex(
CurrentNumberOfPlayers - 1); CurrentNumberOfPlayers - 1);
Cast<ABattlePlayerController>(NewPlayer)->
StartPlayingMusic(BackgroundSound);
UE_LOG(LogTemp, Warning, TEXT("%d"), CurrentNumberOfPlayers); UE_LOG(LogTemp, Warning, TEXT("%d"), CurrentNumberOfPlayers);
if (CurrentNumberOfPlayers == 2) { if (CurrentNumberOfPlayers == 2) {
UE_LOG(LogTemp, Warning, TEXT("Game Start")); UE_LOG(LogTemp, Warning, TEXT("Game Start"));

@ -27,6 +27,9 @@ public:
// void CycleTurns(); // void CycleTurns();
protected: protected:
UPROPERTY(BlueprintReadWrite, EditAnywhere)
USoundBase *BackgroundSound;
UPROPERTY() UPROPERTY()
TArray<UClass *> LoadedBpAssets; TArray<UClass *> LoadedBpAssets;

@ -147,6 +147,11 @@ uint8 ABattlePlayerController::GetPlayerIndex() const {
return PlayerIndex; return PlayerIndex;
} }
void ABattlePlayerController::StartPlayingMusic_Implementation(
USoundBase *BackgroundSound) const {
UGameplayStatics::PlaySound2D(GetWorld(), BackgroundSound);
}
// float AMyPlayerController::SetCurrentActionAndReturnRadius(int action) { // float AMyPlayerController::SetCurrentActionAndReturnRadius(int action) {
// return GetMyPlayerState()->SetCurrentActionAndReturnRadius(action); // return GetMyPlayerState()->SetCurrentActionAndReturnRadius(action);
// //

@ -50,6 +50,9 @@ public:
// UFUNCTION(Client, Reliable) // UFUNCTION(Client, Reliable)
// void SetEnemySelection(const TArray<ATrooper *> &Troopers) const; // void SetEnemySelection(const TArray<ATrooper *> &Troopers) const;
UFUNCTION(Client, Reliable)
void StartPlayingMusic(USoundBase *BackgroundSound) const;
private: private:
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
TSubclassOf<UUserWidget> WidgetClass; TSubclassOf<UUserWidget> WidgetClass;

@ -156,8 +156,9 @@ void ABattlePlayerState::OnPlayerAction(const FHitResult &HitResult) {
return; return;
} }
if (NewlySelectedTrooper == nullptr || !NewlySelectedTrooper-> if (HitResult.GetActor()->ActorHasTag(FName("Floor")) ||
IsValidLowLevel() || NewlySelectedTrooper->GetPlayerIndex() != NewlySelectedTrooper != nullptr &&
NewlySelectedTrooper->GetPlayerIndex() !=
PlayerIndex) { PlayerIndex) {
if (SelectedTrooper != nullptr && SelectedTrooper-> if (SelectedTrooper != nullptr && SelectedTrooper->
IsValidLowLevel()) { IsValidLowLevel()) {

@ -2,6 +2,7 @@
#include "SinglePlayerGM.h" #include "SinglePlayerGM.h"
#include "SinglePlayerGS.h" #include "SinglePlayerGS.h"
#include "TurnBasedTutorial/BattleMode/BattlePlayerController.h"
ASinglePlayerGM::ASinglePlayerGM() ASinglePlayerGM::ASinglePlayerGM()
: Super() { : Super() {
@ -18,4 +19,6 @@ void ASinglePlayerGM::BeginPlay() {
void ASinglePlayerGM::PostLogin(APlayerController *NewPlayer) { void ASinglePlayerGM::PostLogin(APlayerController *NewPlayer) {
AGameMode::PostLogin(NewPlayer); AGameMode::PostLogin(NewPlayer);
Cast<ABattlePlayerController>(NewPlayer)->
StartPlayingMusic(BackgroundSound);
} }

@ -1,6 +1,6 @@
{ {
"FileVersion": 3, "FileVersion": 3,
"EngineAssociation": "4.27", "EngineAssociation": "{B4FE6467-4579-3D84-B22A-558A3D607596}",
"Category": "", "Category": "",
"Description": "", "Description": "",
"Modules": [ "Modules": [

Loading…
Cancel
Save