Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fill out your copyright notice in the Description page of Project Settings.
- #include "PoGameModeBase.h"
- #include "Kismet/GameplayStatics.h"
- #include "PoPlayerController.h"
- #include "PoPawn.h"
- #include "PoPlayerState.h"
- #include "PoBlockBase.h"
- #include "GameFramework/PlayerStart.h"
- class APoBlockBase;
- APoGameModeBase::APoGameModeBase()
- {
- PlayerControllerClass = APoPlayerController::StaticClass();
- DefaultPawnClass = APoPawn::StaticClass();
- PlayerStateClass = APoPlayerState::StaticClass();
- BlockCount = 0;
- }
- void APoGameModeBase::RegisterBlocks(APoBlockBase* blockActor)
- {
- BlockCount++;
- if (blockActor)
- {
- BlockList.Add(blockActor);
- }
- UE_LOG(LogTemp, Warning, TEXT("Total Number of Blocks: %s"), *FString::FromInt(BlockCount));
- }
- void APoGameModeBase::DeRegisterBlocks()
- {
- BlockCount--;
- if (CheckWinCondition())
- {
- UE_LOG(LogTemp, Warning, TEXT("Player Won!"));
- WinningCall();
- }
- UE_LOG(LogTemp, Warning, TEXT("Total Number of Blocks: %s"), *FString::FromInt(BlockCount));
- }
- bool APoGameModeBase::CheckWinCondition()
- {
- bool bStatus = false;
- if (BlockCount == 0)
- bStatus = true;
- return bStatus;
- }
- void APoGameModeBase::SpawnBall()
- {
- AActor* playerStart = UGameplayStatics::GetActorOfClass(GetWorld(), APlayerStart::StaticClass());
- if (playerStart)
- {
- UE_LOG(LogTemp, Warning, TEXT("got player start"));
- FActorSpawnParameters params;
- BallRef = GetWorld()->SpawnActor<APoBallBase>(BallBP, playerStart->GetActorTransform(), params);
- if(BallRef)
- UE_LOG(LogTemp, Warning, TEXT("Ball is spawned"));
- }
- }
- void APoGameModeBase::BeginPlay()
- {
- Super::BeginPlay();
- }
- void APoGameModeBase::PostInitializeComponents()
- {
- Super::PostInitializeComponents();
- SpawnBall();
- }
- void APoGameModeBase::RandomBlocks()
- {
- UE_LOG(LogTemp, Warning, TEXT("random Command Executed"));
- }
- void APoGameModeBase::SpawnBlocks()
- {
- int totalBlocks = 10;
- FVector Pos1(10, 10, 10);
- FRotator Rot1(0, 0, 0);
- FActorSpawnParameters SpawnInfo;
- for (int i = 0; i < 10; i++)
- {
- FActorSpawnParameters params;
- APoBlockBase* bBlock = GetWorld()->SpawnActor<APoBlockBase>(Pos1,Rot1,SpawnInfo);
- }
- }
Add Comment
Please, Sign In to add comment