void ASHUD::DrawCenterDot() { float CenterX = Canvas->ClipX / 2; float CenterY = Canvas->ClipY / 2; float CenterDotScale = 0.07f; ASPlayerController* PCOwner = Cast<ASPlayerController>(PlayerOwner); if (PCOwner) { ASCharacter* Pawn = Cast<ASCharacter>(PCOwner->GetPawn()); if (Pawn && Pawn->IsAlive()) { // Boost size when hovering over a switchable object. ASUsableActor* usable = Pawn->GetUsableInView(); if (usable) CenterDotScale *= 1.5f; Canvas->SetDrawColor(255, 255, 255, 255); Canvas->DrawIcon(CenterDotIcon, CenterX - CenterDotIcon.UL*CenterDotScale / 2.0f, CenterY - CenterDotIcon.VL*CenterDotScale / 2.0f, CenterDotScale); } } }
void ASHUD::DrawCenterDot() { float lCenterX = Canvas->ClipX * 0.5f; float lCenterY = Canvas->ClipY * 0.5f; float lCenterDotScale = 0.07f; ASPlayerController* lOwner = Cast<ASPlayerController>(PlayerOwner); if (lOwner) { ASCharacter* lPawn = Cast<ASCharacter>(lOwner->GetPawn()); if (lPawn && lPawn->IsAlive()) { ASUsableActor* lUsable = lPawn->GetUsableInView(); if (lUsable) lCenterDotScale *= 1.5f; Canvas->SetDrawColor(255, 255, 255, 255); Canvas->DrawIcon(CenterDotIcon, lCenterX - CenterDotIcon.UL * lCenterDotScale * 0.5f, lCenterY - CenterDotIcon.VL * lCenterDotScale * 0.5f, lCenterDotScale); } } }
void ASGameMode::DefaultTimer() { /* This function is called every 1 second. */ Super::DefaultTimer(); /* Immediately start the match while playing in editor */ //if (GetWorld()->IsPlayInEditor()) { if (GetMatchState() == MatchState::WaitingToStart) { StartMatch(); } } /* Only increment time of day while game is active */ if (IsMatchInProgress()) { ASGameState* MyGameState = Cast<ASGameState>(GameState); if (MyGameState) { /* Increment our time of day */ MyGameState->ElapsedGameMinutes += MyGameState->GetTimeOfDayIncrement(); /* Determine our state */ MyGameState->GetAndUpdateIsNight(); /* Trigger events when night starts or ends */ bool CurrentIsNight = MyGameState->GetIsNight(); if (CurrentIsNight != LastIsNight) { FString MessageText = CurrentIsNight ? "SURVIVE!" : "You Survived! Now prepare for the coming night!"; ASGameState* MyGameState = Cast<ASGameState>(GameState); if (MyGameState) { MyGameState->BroadcastGameMessage(MessageText); } /* The night just ended, respawn all dead players */ if (!CurrentIsNight) { /* Respawn spectating players that died during the night */ for (FConstPlayerControllerIterator It = GetWorld()->GetPlayerControllerIterator(); It; It++) { /* Look for all players that are spectating */ ASPlayerController* MyController = Cast<ASPlayerController>(*It); if (MyController) { if (MyController->PlayerState->bIsSpectator) { RestartPlayer(MyController); MyController->ClientHUDStateChanged(EHUDState::Playing); } else { /* Player still alive, award him some points */ ASCharacter* MyPawn = Cast<ASCharacter>(MyController->GetPawn()); if (MyPawn && MyPawn->IsAlive()) { ASPlayerState* PS = Cast<ASPlayerState>(MyController->PlayerState); if (PS) { PS->ScorePoints(NightSurvivedScore); } } } } } } /* Update bot states */ if (CurrentIsNight) { WakeAllBots(); } else { PassifyAllBots(); } } LastIsNight = MyGameState->bIsNight; } } }