void UBrainComponent::LockResource(EAIRequestPriority::Type LockSource)
{
	const bool bWasLocked = ResourceLock.IsLocked();
	ResourceLock.SetLock(LockSource);
	if (bWasLocked == false)
	{
		PauseLogic(FString::Printf(TEXT("Locking Resource with source %s"), *ResourceLock.GetLockPriorityName()));
	}
}
Exemplo n.º 2
0
void DIY_Level::LevelUpdate(float timeStep_)
{
	if (!hasFinishedLoading)
		return;

	Level::LevelUpdate(timeStep_);

	if (InputController::getInstance()->isKeyDown(SDLK_EQUALS))
	{
		sun->scale += Vec3::One() * 1.0f;
		std::cout << sun->scale.toString() << "\n";
	}
	else if (InputController::getInstance()->isKeyDown(SDLK_MINUS))
	{
		sun->scale -= Vec3::One() * 1.0f;
		std::cout << sun->scale.toString() << "\n";
	}	

	//Victory TEST
	if (InputController::getInstance()->isKeyDown(SDLK_v))
	{
		levelState = VICTORY;
	}

	//Game state switch
	switch (levelState)
	{
	case DIY_Level_State::PLAYING:
		gui->shotPower = ((PlayerBall*)playerBall)->GetChargePercent() / 100.0f;

		PauseLogic();

		//Check for Victory
		if (PlayerHasShotBallIntoSun)
		{
			levelState = DIY_Level_State::VICTORY;
		}
		else
		{
			switch (playingState)
			{
			case DIY_Level_Playing_State::SHOOTING:
				if (!isShooting && ((PlayerBall*)playerBall)->GetIsChargingStrike())
					isShooting = true;
				else if (isShooting && !((PlayerBall*)playerBall)->GetIsChargingStrike())
				{
					isShooting = false;
					strokeCount++;
					gui->PlayerTookAStroke();

					playingState = DIY_Level_Playing_State::WATCHING;
				}
				break;
			case DIY_Level_Playing_State::WATCHING:
				if (!playerBall->getComponent<Rigidbody>()->isAwake())
					playingState = DIY_Level_Playing_State::SHOOTING;
				break;
			}

			//if (Input->isMouseDown(SDL_BUTTON_RIGHT))
			//{
			//	//layerContainer->Rotate(Quat(Input->deltaMouse().x * timeStep_, Vec3(0, 1.0f, 0)));
			//	PhysicsWorld::Orbit(Vec3::Zero(), Vec3::BasisY(), mainCamera, Input->deltaMouse().x * timeStep_);
			//	mainCamera->Rotate(Quat(Input->deltaMouse().x * timeStep_, Vec3::BasisY()));
			//}
			//break;
		}
	case DIY_Level_State::PAUSED:
		PauseLogic();
		break;
	case DIY_Level_State::VICTORY:
		switch (victoryState)
		{
		case DIY_Level_Victory_State::REVIEW:
			break;
		case DIY_Level_Victory_State::LEVEL_SELECT:
			break;
		}
		break;
	}

	gui->Update(timeStep_);
}