コード例 #1
0
ファイル: BunniesManager.cpp プロジェクト: asmCode/ssg02
sm::Vec3 BunniesManager::GetRandomRespawnPosition()
{
	static Randomizer rand;

	sm::Vec3 position;

	int side = rand.GetInt(0, 3);

	switch (side)
	{
		case 0: // left
			position = sm::Vec3(-50.0f, 0, rand.GetFloat(-50.0f, 50.0f));
			break;

		case 1: // right
			position = sm::Vec3(50.0f, 0, rand.GetFloat(-50.0f, 50.0f));
			break;

		case 2: // top
			position = sm::Vec3(rand.GetFloat(-50.0f, 50.0f), 0, 50.0f);
			break;

		case 3: // bottom
			position = sm::Vec3(rand.GetFloat(-50.0f, 50.0f), 0, -50.0f);
			break;
	}

	return position;
}
コード例 #2
0
ファイル: BunniesManager.cpp プロジェクト: asmCode/ssg02
void BunniesManager::ResetForNewGame(uint32_t healthyBunniesCount)
{
	static Randomizer random;

	assert(healthyBunniesCount < MaxBunniesCount);

	ClearBunnies();

	for (uint32_t i = 0; i < MaxBunniesCount; i++)
	{
		if (i < healthyBunniesCount)
		{
			sm::Vec3 startPos;
			startPos.x = random.GetFloat(-50.0f, 50.0f);
			startPos.y = 0.0f;
			startPos.z = random.GetFloat(-50.0f, 50.0f);

			m_healthyBunnies[i]->ActivateOnStart(startPos);

			if (i > m_maxHealthyBunnyIndex)
				m_maxHealthyBunnyIndex = i;
		}
	}

	// TEST
	SpawnInfectedBunny();
	InfectedBunny *ib = m_infectedBunnies[0];
	assert(ib != NULL && ib->IsActive());

	ib->SetPosition(sm::Vec3(0, 0, -10));
}
コード例 #3
0
ファイル: HealthyBunny.cpp プロジェクト: asmCode/ssg02
void HealthyBunny::RefreshNewTargetPosition(float seconds)
{
	static Randomizer random;

	float distance = (m_targetPosition - m_position).GetLength();

	m_targetPositionRefreshColldown -= seconds;
	if (m_targetPositionRefreshColldown <= 0.0f || distance <= 0.4f)
	{
		if (m_useRunningAwayInitialDirection)
		{
			m_targetPosition = m_position + m_runningAwayInitialDirection;
			m_useRunningAwayInitialDirection = false;
		}
		else
		{
			m_targetPosition.x = random.GetFloat(-50.0f, 50.0f);
			m_targetPosition.y = 0.0f;
			m_targetPosition.z = random.GetFloat(-50.0f, 50.0f);
		}

		m_targetPositionRefreshColldown = random.GetFloat(
			GameProps::RefreshNewTargetPositionFrom,
			GameProps::RefreshNewTargetPositionTo);
	}
}
コード例 #4
0
ファイル: InfectedBunny.cpp プロジェクト: asmCode/ssg02
void InfectedBunny::Die()
{
	if (GetState()->GetStateType() == IBunnyState::State_Fucking ||
		GetState()->GetStateType() == IBunnyState::State_Hunting)
		m_huntingTarget->SetToIdle();

	m_dieBaseMatrix =
		CalcBoneMatrixZ(sm::Vec3(0, 0, 0), m_moveTarget) *
		sm::Matrix::RotateAxisMatrix(3.1415f, 0, 1, 0);

	static Randomizer random;

	m_dieBodyTrajectory.Throw(m_position, sm::Vec3(random.GetFloat(-0.2f, 0.2f), 1, random.GetFloat(-0.2f, 0.2f)).GetNormalized(), random.GetFloat(10.0f, 14.0f), 30.0f);
	m_dieHeadTrajectory.Throw(m_position, sm::Vec3(random.GetFloat(-0.2f, 0.2f), 1, random.GetFloat(-0.2f, 0.2f)).GetNormalized(), random.GetFloat(10.0f, 14.0f), 30.0f);

	m_dieBodyAxis = sm::Vec3(random.GetFloat(-1.0f, 1.0f), random.GetFloat(-1.0f, 1.0f), random.GetFloat(-1.0f, 1.0f)).GetNormalized();
	m_dieBodyAngleProgress = 0.0f;
	m_dieBodyAngleSpeed = random.GetFloat(2.0f, 6.0f);

	m_dieHeadAxis = sm::Vec3(random.GetFloat(-1.0f, 1.0f), random.GetFloat(-1.0f, 1.0f), random.GetFloat(-1.0f, 1.0f)).GetNormalized();
	m_dieHeadAngleProgress = 0.0f;
	m_dieHeadAngleSpeed = random.GetFloat(2.0f, 6.0f);

	SetState(Dying::GetInstance());
}
コード例 #5
0
ファイル: HealthyBunny.cpp プロジェクト: asmCode/ssg02
void HealthyBunny::SetNewborn()
{
	m_useTransform = true;
	m_transform = sm::Matrix::IdentityMatrix();

	m_growingUpTime = GameProps::GrowingUpTime;

	static Randomizer rand;

	m_borningJumpOutVector = sm::Vec3(rand.GetFloat(-1.0f, 1.0), 0.0f, rand.GetFloat(-1.0f, 1.0f));
	m_borningJumpOutVector.Normalize();

	m_borningJumpOutAxis = m_borningJumpOutVector * sm::Vec3(0, 1, 0);
	m_borningJumpOutAxis.Normalize();

	SetState(Idle::GetInstance());
}
コード例 #6
0
ファイル: InfectedBunny.cpp プロジェクト: asmCode/ssg02
void InfectedBunny::RefreshNewTargetPosition(float seconds)
{
	static Randomizer random;

	float distance = (m_targetPosition - m_position).GetLength();

	m_targetPositionRefreshColldown -= seconds;
	if (m_targetPositionRefreshColldown <= 0.0f || distance <= 0.4f)
	{
		m_targetPositionRefreshColldown = random.GetFloat(
			GameProps::RefreshNewTargetPositionFrom,
			GameProps::RefreshNewTargetPositionTo);

		sm::Vec3 newPos(random.GetFloat(-50.0f, 50.0f), 0.0f, random.GetFloat(-50.0f, 50.0f));
		SetDestinationPosition(newPos);
	}
}
コード例 #7
0
ファイル: Fucking.cpp プロジェクト: asmCode/ssg02
void F*****g::Update(IBunny *bunny, float time, float seconds)
{
	assert(bunny != NULL);

	InfectedBunny *ibunny = dynamic_cast<InfectedBunny*>(bunny);
	assert(ibunny != NULL);

	HealthyBunny *hbunny = ibunny->GetHuntingTarget();
	assert(hbunny != NULL);

	if (!hbunny->IsActive() || hbunny->GetState()->GetStateType() == IBunnyState::State_Dying) // make sure if bunny can be still f****d
	{
		static Randomizer random;

		ibunny->RestingAfterFuckingProgress().SetTicker(random.GetFloat(GameProps::RestingAfterTryingToFuckTimeFrom, GameProps::RestingAfterTryingToFuckTimeTo));
		ibunny->SetState(RestingAfterFucking::GetInstance());
		return;
	}

	ibunny->m_fuckProgressTime += seconds;
	if (ibunny->m_fuckMoveCycles < GameProps::FuckingHipCycles && ibunny->m_fuckProgressTime >= ibunny->m_fuckAnimEnd)
	{
		ibunny->m_fuckMoveCycles++;
		ibunny->m_fuckProgressTime = ibunny->m_fuckAnimStart;
	}

	ibunny->m_currentAnim = ibunny->m_fuckAnim;
	ibunny->m_currentAnimTime = ibunny->m_fuckProgressTime;

	ibunny->FuckingProgress().Progress(seconds);
	if (ibunny->m_currentAnimTime >= ibunny->m_fuckAnim->GetAnimLength())
	{
		static Randomizer random;

		ibunny->RestingAfterFuckingProgress().SetTicker(random.GetFloat(GameProps::RestingAfterFuckingTimeFrom, GameProps::RestingAfterFuckingTimeTo));
		ibunny->SetState(RestingAfterFucking::GetInstance());

		hbunny->StartChangingToInfected();
	}
}
コード例 #8
0
ファイル: Hunting.cpp プロジェクト: asmCode/ssg02
void Hunting::Update(IBunny *bunny, float time, float seconds)
{
	assert(bunny != NULL);

	InfectedBunny *ibunny = dynamic_cast<InfectedBunny*>(bunny);
	assert(ibunny != NULL);

	HealthyBunny *hbunny = ibunny->GetHuntingTarget();
	assert(hbunny != NULL);

	if (!hbunny->CanBeFucked()) // make sure if bunny can be still f****d
	{
		static Randomizer random;

		ibunny->RestingAfterFuckingProgress().SetTicker(random.GetFloat(GameProps::RestingAfterTryingToFuckTimeFrom, GameProps::RestingAfterTryingToFuckTimeTo));
		ibunny->SetState(RestingAfterFucking::GetInstance());
		return;
	}

	sm::Vec3 moveTarget = (hbunny->GetPosition() - ibunny->GetPosition());
	moveTarget.y = 0.0f;

	if (moveTarget.GetLength() <= 0.4f * 2)
	{
		ibunny->FuckingProgress().Reset();
		ibunny->SetState(F*****g::GetInstance());
		hbunny->SetToBeeingFucked(ibunny);
	}
	if (moveTarget.GetLength() <= GameProps::RunningAwayDistance && !ibunny->DidTellToGTFO())
	{
		hbunny->GetTheFuckOut(ibunny);
		ibunny->DidTellToGTFO() = true;
	}
	else
	{
		moveTarget.Normalize();

		ibunny->m_currentAnim = ibunny->m_runAnim;

		ibunny->SetDestinationPosition(hbunny->GetPosition());
		ibunny->UpdateMovement(seconds, GameProps::InfectedBunnyHuntingSpeed, GameProps::DelayBetweenRunJump);
	}
}
コード例 #9
0
ファイル: StreetMap.cpp プロジェクト: asmCode/steering_test
bool StreetMap::GetRandomPavementArea(uint32_t x, uint32_t y, sm::Vec3 &position, sm::Vec3 &direction)
{
	static Randomizer random;

	StreetPiece::PieceType type = GetPieceType(x, y);

	float streetWidth = 10.0f;
	float pavementWidth = 2.0f;

	switch (type)
	{
	case StreetPiece::PieceType_Pavement:
		return false;
		break;
	case StreetPiece::PieceType_StraightHori_1:
		position = sm::Vec3(
			x * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2),
			0,
			y * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * random.GetSign());

		direction = sm::Vec3(MathUtils::Sign(random.GetFloat(-1, 1)), 0, 0);
		return true;
		
	case StreetPiece::PieceType_StraightVert_1:
		position = sm::Vec3(
			x * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * random.GetSign(),
			0,
			y * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2));

		direction = sm::Vec3(0, 0, MathUtils::Sign(random.GetFloat(-1, 1)));
		return true;

	case StreetPiece::PieceType_TurnUpRight_1:
		if (random.GetInt(0, 1) == 1)
		{
			position = sm::Vec3(
				x * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2),
				0,
				y * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2));
		}
		else
		{
			position = sm::Vec3(
				x * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1,
				0,
				y * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2));
		}

		direction = sm::Vec3(0, 0, MathUtils::Sign(random.GetFloat(-1, 1)));
		return true;

	case StreetPiece::PieceType_TurnUpLeft_1:
		if (random.GetInt(0, 1) == 1)
		{
			position = sm::Vec3(
				random.GetFloat(-streetWidth / 2, streetWidth / 2),
				0,
				random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1);
		}
		else
		{
			position = sm::Vec3(
				random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1,
				0,
				random.GetFloat(-streetWidth / 2, streetWidth / 2));
		}

		position = Street::Instance->GetStreetPiece((uint8_t)type)->GetTransform() * position;
		position.x += streetWidth * x;
		position.z += streetWidth * y;

		direction = sm::Vec3(0, 0, MathUtils::Sign(random.GetFloat(-1, 1)));
		return true;

	case StreetPiece::PieceType_TurnDownRight_1:
		if (random.GetInt(0, 1) == 1)
		{
			position = sm::Vec3(
				random.GetFloat(-streetWidth / 2, streetWidth / 2),
				0,
				random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1);
		}
		else
		{
			position = sm::Vec3(
				random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1,
				0,
				random.GetFloat(-streetWidth / 2, streetWidth / 2));
		}

		position = Street::Instance->GetStreetPiece((uint8_t)type)->GetTransform() * position;
		position.x += streetWidth * x;
		position.z += streetWidth * y;

		direction = sm::Vec3(0, 0, MathUtils::Sign(random.GetFloat(-1, 1)));
		return true;

	case StreetPiece::PieceType_TurnDownLeft_1:
		if (random.GetInt(0, 1) == 1)
		{
			position = sm::Vec3(
				random.GetFloat(-streetWidth / 2, streetWidth / 2),
				0,
				random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1);
		}
		else
		{
			position = sm::Vec3(
				random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1,
				0,
				random.GetFloat(-streetWidth / 2, streetWidth / 2));
		}

		position = Street::Instance->GetStreetPiece((uint8_t)type)->GetTransform() * position;
		position.x += streetWidth * x;
		position.z += streetWidth * y;

		direction = sm::Vec3(0, 0, MathUtils::Sign(random.GetFloat(-1, 1)));
		return true;

	case StreetPiece::PieceType_Cross_1:
		break;

	case StreetPiece::PieceType_TUp_1:
		position = sm::Vec3(
			x * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2),
			0,
			y * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1);

		direction = sm::Vec3(MathUtils::Sign(random.GetFloat(-1, 1)), 0, 0);
		return true;

	case StreetPiece::PieceType_TDown_1:
		position = sm::Vec3(
			x * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2),
			0,
			y * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * 1);

		direction = sm::Vec3(MathUtils::Sign(random.GetFloat(-1, 1)), 0, 0);
		return true;

	case StreetPiece::PieceType_TLeft_1:
		position = sm::Vec3(
			x * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * 1,
			0,
			y * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2));

		direction = sm::Vec3(MathUtils::Sign(random.GetFloat(-1, 1)), 0, 0);
		return true;

	case StreetPiece::PieceType_TRight_1:
		position = sm::Vec3(
			x * streetWidth + random.GetFloat(streetWidth / 2 - pavementWidth, streetWidth / 2) * -1,
			0,
			y * streetWidth + random.GetFloat(-streetWidth / 2, streetWidth / 2));

		direction = sm::Vec3(MathUtils::Sign(random.GetFloat(-1, 1)), 0, 0);
		return true;

	case StreetPiece::PieceType_Skycrapper_1:
	case StreetPiece::PieceType_Skycrapper_2:
	case StreetPiece::PieceType_Skycrapper_3:
		break;
	default:
		break;
	}

	return false;
}