コード例 #1
0
void ALabyrinthGameMode::DefaultTimer()
{
	Super::DefaultTimer();

	// don't update timers for play in editor mode, it's not a real match
	if (GetWorld()->IsPlayInEditor())
	{
		// start the match if necessary
		if (GetMatchState() == MatchState::WaitingToStart)
		{
			StartMatch();
		}
		return;
	}

	ALGameState* const MyGameState = Cast<ALGameState>(GameState);
	if (MyGameState && MyGameState->RemainingTime > 0 && !MyGameState->bIsTimerPaused)
	{
		MyGameState->RemainingTime--;
		if (MyGameState->RemainingTime <= 0)
		{
			if (GetMatchState() == MatchState::WaitingPostMatch)
			{
				RestartGame();
			}
			else if (GetMatchState() == MatchState::InProgress)
			{
				FinishMatch();

				// Send end round events
				ALGameState* const MyGameState = Cast<ALGameState>(GameState);

				for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; It++)
				{
					ALPlayerController* PlayerController = Cast<ALPlayerController>(*It);
					if (PlayerController && MyGameState)
					{
						ALPlayerState* PlayerState = Cast<ALPlayerState>((*It)->PlayerState);
						const bool bIsWinner = IsWinner(PlayerState);

						// TO-DO: Add this to the Player controller
						//PlayerController->ClientSendRoundEndEvent(bIsWinner, MyGameState->ElapsedTime);
					}
				}
			}
			else if (GetMatchState() == MatchState::WaitingToStart)
			{
				StartMatch();
			}
		}
	}
}
コード例 #2
0
void AShooterGameMode::DefaultTimer()
{
	// don't update timers for Play In Editor mode, it's not real match
	if (GetWorld()->IsPlayInEditor())
	{
		// start match if necessary.
		if (GetMatchState() == MatchState::WaitingToStart)
		{
			StartMatch();
		}
		return;
	}

	AShooterGameState* const MyGameState = Cast<AShooterGameState>(GameState);
	if (MyGameState && MyGameState->RemainingTime > 0 && !MyGameState->bTimerPaused)
	{
		MyGameState->RemainingTime--;
		
		if (MyGameState->RemainingTime <= 0)
		{
			if (GetMatchState() == MatchState::WaitingPostMatch)
			{
				RestartGame();
			}
			else if (GetMatchState() == MatchState::InProgress)
			{
				FinishMatch();

				// Send end round events
				for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; ++It)
				{
					AShooterPlayerController* PlayerController = Cast<AShooterPlayerController>(*It);
					
					if (PlayerController && MyGameState)
					{
						AShooterPlayerState* PlayerState = Cast<AShooterPlayerState>((*It)->PlayerState);
						const bool bIsWinner = IsWinner(PlayerState);
					
						PlayerController->ClientSendRoundEndEvent(bIsWinner, MyGameState->ElapsedTime);
					}
				}
			}
			else if (GetMatchState() == MatchState::WaitingToStart)
			{
				StartMatch();
			}
		}
	}
}
VOID LeagueOfLegendsHelperDlg::CheckButtonPresses()
{
    m_lcd.ModifyDisplay(LG_MONOCHROME);

    if (m_lcd.ButtonTriggered(LG_BUTTON_1))
        StartMatch();
	else if (m_lcd.ButtonTriggered(LG_BUTTON_2))
		EndMatch();
	else if (m_lcd.ButtonTriggered(LG_BUTTON_3))
		notify = !notify;
	else if (m_lcd.ButtonTriggered(LG_BUTTON_4))
		m_lcd.ShowPage((m_lcd.GetCurrentPageNumber() + 1) % m_lcd.GetPageCount());

	if(GetKeyState(VK_CONTROL) & 0x80 && GetKeyState(VK_SHIFT) & 0x80 && GetKeyState(VK_MENU) & 0x80)
	{
		if(GetKeyState(VK_F1) & 0x80)
			redFriendly.Trigger();
		else if(GetKeyState(VK_F2) & 0x80)
			redEnemy.Trigger();
		else if(GetKeyState(VK_F3) & 0x80)
			dragon.Trigger();
		else if(GetKeyState(VK_F4) & 0x80)
			blueFriendly.Trigger();
		else if(GetKeyState(VK_F5) & 0x80)
			blueEnemy.Trigger();
		else if(GetKeyState(VK_F6) & 0x80)
			baron.Trigger();
	}
}
コード例 #4
0
void AMainMenuMode::StartPlay()
{
	Super::StartPlay();
	StartMatch();

	UMainMenuWidget::Create(GetWorld());
}
コード例 #5
0
void ABoidGameMode::StartPlay()
{
	Super::StartPlay();

	StartMatch();

	ABoidController* boidController = GetWorld()->SpawnActor<ABoidController>(ABoidController::StaticClass());

}
コード例 #6
0
ファイル: Judge.cpp プロジェクト: VSRonin/MagiQ
void Judge::SomebodyDisconnected(int a){
	QMap<int,MagiQPlayer*>::iterator playpoint=PlayersList.find(a);
	if (playpoint==PlayersList.end()) return;
	QString Temp=playpoint.value()->GetPlayerName();
	PlayersList.erase(playpoint);
	SendServerInfos();
	SendLeftTheGame(Temp);
	if (EverybodyReady() && !GameStarted) StartMatch();
}
コード例 #7
0
ファイル: FPGameMode.cpp プロジェクト: LightK3340/Light.K3340
void AFPGameMode::StartPlay(){
	Super::StartPlay();
	StartMatch();

	if (GEngine)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("FPGameMode loaded"));
	}
}
コード例 #8
0
void AOnlineArenaGameMode::DefaultTimer()
{
	const auto World = GetWorld();
	if (nullptr != World && World->IsPlayInEditor())
	{
		//!< PIE ‚Ì�ê�‡
		if (MatchState::WaitingToStart == GetMatchState())
		{
			StartMatch();
		}
	}
	else
	{
		const auto MatchSteate = GetMatchState();

		const auto GS = Cast<AOnlineGameState>(GameState);
		if (nullptr != GS)
		{
			--GS->RemainingTime;
			if (GS->RemainingTime <= 0)
			{
				GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, TEXT("TIME UP"));
				if (MatchState::WaitingPostMatch == MatchState)
				{
					RestartGame();
				}
				else if (MatchState::InProgress == MatchState)
				{
					EndMatch();
				}
			}
			else
			{
				GEngine->AddOnScreenDebugMessage(-1, 1.0f, FColor::Red, FString::FromInt(GS->RemainingTime));
				if (MatchState::WaitingToStart == MatchState)
				{
					StartMatch();
				}
			}
		}
	}
}
コード例 #9
0
void AMoveGameMode::StartPlay()
{
    Super::StartPlay();

    StartMatch();

    if (GEngine)
    {
        //GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Spider"));
    }
}
コード例 #10
0
void AVRGameMode::StartPlay()
{
	Super::StartPlay();

	StartMatch();

	UWorld* const World = GetWorld();

	if (GEngine && World)
	{
		ASongContainer* SongContainer = World->SpawnActor<ASongContainer>();
	}
}
コード例 #11
0
void ASGameMode::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)
			{
				EHUDMessage MessageID = CurrentIsNight ? EHUDMessage::Game_SurviveStart : EHUDMessage::Game_SurviveEnded;
				MyGameState->BroadcastGameMessage(MessageID);

				/* The night just ended, respawn all dead players */
				if (!CurrentIsNight)
				{
					OnNightEnded();
				}

				/* Update bot states */
				if (CurrentIsNight)
				{
					WakeAllBots();
				}
				else
				{
					PassifyAllBots();
				}
			}

			LastIsNight = MyGameState->bIsNight;
		}
	}
}
コード例 #12
0
ファイル: gamecontroller.cpp プロジェクト: eguopt/teeworlds
void IGameController::Tick()
{
	// handle game states
	if(m_GameState != IGS_GAME_RUNNING)
	{
		if(m_GameStateTimer > 0)
			--m_GameStateTimer;

		if(m_GameStateTimer == 0)
		{
			// timer fires
			switch(m_GameState)
			{
			case IGS_WARMUP_USER:
				// end warmup
				SetGameState(IGS_WARMUP_USER, 0);
				break;
			case IGS_START_COUNTDOWN:
				// unpause the game
				SetGameState(IGS_GAME_RUNNING);
				break;
			case IGS_GAME_PAUSED:
				// end pause
				SetGameState(IGS_GAME_PAUSED, 0);
				break;
			case IGS_END_ROUND:
				// check if the match is over otherwise start next round
				DoWincheckMatch();
				if(m_GameState != IGS_END_MATCH)
					StartRound();
				break;
			case IGS_END_MATCH:
				// start next match
				CycleMap();
				StartMatch();
				m_MatchCount++;
				break;
			case IGS_WARMUP_GAME:
			case IGS_GAME_RUNNING:
				// not effected
				break;
			}
		}
		else
		{
			// timer still running
			switch(m_GameState)
 			{
			case IGS_WARMUP_USER:
				// check if player ready mode was disabled and it waits that all players are ready -> end warmup
				if(!g_Config.m_SvPlayerReadyMode && m_GameStateTimer == TIMER_INFINITE)
					SetGameState(IGS_WARMUP_USER, 0);
				break;
			case IGS_START_COUNTDOWN:
			case IGS_GAME_PAUSED:
				// freeze the game
				++m_GameStartTick;
				break;
			case IGS_WARMUP_GAME:
			case IGS_GAME_RUNNING:
			case IGS_END_MATCH:
			case IGS_END_ROUND:
				// not effected
				break;
 			}
		}
	}

	// do team-balancing (skip this in survival, done there when a round starts)
	if(IsTeamplay() && !(m_GameFlags&GAMEFLAG_SURVIVAL))
	{
		switch(m_UnbalancedTick)
		{
		case TBALANCE_CHECK:
			CheckTeamBalance();
			break;
		case TBALANCE_OK:
			break;
		default:
			if(Server()->Tick() > m_UnbalancedTick+g_Config.m_SvTeambalanceTime*Server()->TickSpeed()*60)
				DoTeamBalance();
		}
	}

	// check for inactive players
	DoActivityCheck();

	// win check
	if((m_GameState == IGS_GAME_RUNNING || m_GameState == IGS_GAME_PAUSED) && !GameServer()->m_World.m_ResetRequested)
	{
		if(m_GameFlags&GAMEFLAG_SURVIVAL)
			DoWincheckRound();
		else
			DoWincheckMatch();
	}
}
コード例 #13
0
ファイル: gamecontroller.cpp プロジェクト: eguopt/teeworlds
void IGameController::SetGameState(EGameState GameState, int Timer)
{
	// change game state
	switch(GameState)
	{
	case IGS_WARMUP_GAME:
		// game based warmup is only possible when game or any warmup is running
		if(m_GameState == IGS_GAME_RUNNING || m_GameState == IGS_WARMUP_GAME || m_GameState == IGS_WARMUP_USER)
		{
			if(Timer == TIMER_INFINITE)
			{
				// run warmup till there're enough players
				m_GameState = GameState;
 				m_GameStateTimer = TIMER_INFINITE;
		
				// enable respawning in survival when activating warmup
				if(m_GameFlags&GAMEFLAG_SURVIVAL)
				{
					for(int i = 0; i < MAX_CLIENTS; ++i)
						if(GameServer()->m_apPlayers[i])
							GameServer()->m_apPlayers[i]->m_RespawnDisabled = false;
				}
			}
			else if(Timer == 0)
			{
				// start new match
				StartMatch();
			}
		}
		break;
	case IGS_WARMUP_USER:
		// user based warmup is only possible when the game or a user based warmup is running
		if(m_GameState == IGS_GAME_RUNNING || m_GameState == IGS_WARMUP_USER)
		{
			if(Timer != 0)
			{
				// start warmup
				if(Timer < 0 && g_Config.m_SvPlayerReadyMode)
				{
					// run warmup till all players are ready
					m_GameState = GameState;
 					m_GameStateTimer = TIMER_INFINITE;
 					SetPlayersReadyState(false);
				}
				else if(Timer > 0)
				{
					// run warmup for a specific time intervall
					m_GameState = GameState;
					m_GameStateTimer = Timer*Server()->TickSpeed();
				}
		
				// enable respawning in survival when activating warmup
				if(m_GameFlags&GAMEFLAG_SURVIVAL)
				{
					for(int i = 0; i < MAX_CLIENTS; ++i)
						if(GameServer()->m_apPlayers[i])
							GameServer()->m_apPlayers[i]->m_RespawnDisabled = false;
				}
			}
			else
			{
				// start new match
				StartMatch();
			}
		}
		break;
	case IGS_START_COUNTDOWN:
		// only possible when game, pause or start countdown is running
		if(m_GameState == IGS_GAME_RUNNING || m_GameState == IGS_GAME_PAUSED || m_GameState == IGS_START_COUNTDOWN)
		{
			m_GameState = GameState;
			m_GameStateTimer = 3*Server()->TickSpeed();
			GameServer()->m_World.m_Paused = true;
		}
		break;
	case IGS_GAME_RUNNING:
		// always possible
		{
			m_GameState = GameState;
			m_GameStateTimer = TIMER_INFINITE;
			SetPlayersReadyState(true);
			GameServer()->m_World.m_Paused = false;
		}
		break;
	case IGS_GAME_PAUSED:
		// only possible when game is running or paused
		if(m_GameState == IGS_GAME_RUNNING || m_GameState == IGS_GAME_PAUSED)
		{
			if(Timer != 0)
			{
				// start pause
				if(Timer < 0)
				{
					// pauses infinitely till all players are ready or disabled via rcon command
					m_GameStateTimer = TIMER_INFINITE;
					SetPlayersReadyState(false);
				}
				else
				{
					// pauses for a specific time intervall
					m_GameStateTimer = Timer*Server()->TickSpeed();
				}

				m_GameState = GameState;
				GameServer()->m_World.m_Paused = true;
			}
			else
			{
				// start a countdown to end pause
				SetGameState(IGS_START_COUNTDOWN);
			}
		}
		break;
	case IGS_END_ROUND:
	case IGS_END_MATCH:
		// only possible when game is running or over
		if(m_GameState == IGS_GAME_RUNNING || m_GameState == IGS_END_MATCH || m_GameState == IGS_END_ROUND || m_GameState == IGS_GAME_PAUSED)
		{
			m_GameState = GameState;
			m_GameStateTimer = Timer*Server()->TickSpeed();
			m_SuddenDeath = 0;
			GameServer()->m_World.m_Paused = true;
		}
	}
}
コード例 #14
0
ファイル: Judge.cpp プロジェクト: VSRonin/MagiQ
void Judge::IsReadyToPlay(int a,bool ready){
	if (PlayersList.find(a)==PlayersList.end()) return;
	PlayersList[a]->SetReadyToStartMatch(ready);
	if (EverybodyReady() && !GameStarted)
		StartMatch();	
}
コード例 #15
0
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;
		}
	}
}