// STATIC:
	bool PhysicsEntityContainer::doEntitiesOverlap(std::weak_ptr<PhysicsEntity> e1, 
												   std::weak_ptr<PhysicsEntity> e2)
	{
		float bothRadiiCombined = e1._Get()->GetRadius() + e2._Get()->GetRadius();
		float squaredDistance = PhysicsEntityContainer::getSquaredDistance(e1, e2);

		// Compare distance^2 with bothRadii^2
		return squaredDistance < (bothRadiiCombined*bothRadiiCombined);
	}
Exemple #2
0
void Stage::AddPoint(ACTOR_ID id, std::weak_ptr<Player> player)
{
	addPoint = 0;
	//死んだのがプレイヤーなら
	if (id == ACTOR_ID::PLAYER_ACTOR)
	{
		if (ReturnCrystal(ACTOR_ID::CRYSTAL_PLAYERSIDE_ACTOR)._Get()->IsEnemy())
			addPoint++;
		if (ReturnCrystal(ACTOR_ID::CRYSTAL_CENTER_ACTOR)._Get()->IsEnemy())
			addPoint++;
		if (ReturnCrystal(ACTOR_ID::CRYSTAL_ENEMYSIDE_ACTOR)._Get()->IsEnemy())
			addPoint++;
		addPoint = 1 + addPoint;
		enemyPoint += addPoint;

		player._Get()->PlusPoint(addPoint);
	}
	//死んだのがエネミーなら
	else
	{
		if (ReturnCrystal(ACTOR_ID::CRYSTAL_PLAYERSIDE_ACTOR)._Get()->IsPlayer())
			addPoint++;
		if (ReturnCrystal(ACTOR_ID::CRYSTAL_CENTER_ACTOR)._Get()->IsPlayer())
			addPoint++;
		if (ReturnCrystal(ACTOR_ID::CRYSTAL_ENEMYSIDE_ACTOR)._Get()->IsPlayer())
			addPoint++;
		addPoint = 1 + addPoint;
		playerPoint += addPoint;
		player._Get()->PlusPoint(addPoint);
	}

	totalPoint = playerPoint + enemyPoint;

	////加算
	//teamPoint += addPoint;
	////クランプ
	//teamPoint = min(pointMax, teamPoint);
	//teamPoint = max(0, teamPoint);

	////コールド勝ち
	//if (teamPoint >= pointMax)
	//{
	//	//終了
	//	gameEnd = true;
	//	playerTeamWin = true;
	//}
	//else if (teamPoint <= 0)
	//{
	//	//終了
	//	gameEnd = true;
	//	playerTeamWin = false;
	//}
}
TornadoParticle::TornadoParticle(std::weak_ptr<Tornado> tornade_, float radius)
:
tornade(tornade_),
tornadePos(tornade._Get()->GetParameter().mat.GetPosition()),
tornadeMove(Vector3::Zero),
tornadeRadius(Random::GetInstance().Range(radius/3.0f, radius/3.0f + 30.0f)),
tornadeAddRadius(Random::GetInstance().Range(60.0f, 80.0f)),
tornadeSpeed(700.0f),
tornadeDegree(Random::GetInstance().Range(1.0f, 360.0f)),
risingSpeed(Random::GetInstance().Range(TornadoParticleRizeSpeedMin, TornadoParticleRizeSpeedMax)),
risingAddSpeed(Random::GetInstance().Range(0, 2)),
tornadeAddPosition(Vector3::Zero),
position(tornade_._Get()->GetParameter().mat.GetPosition()),
up(Vector3::Zero),
front(Vector3::Zero),
left(Vector3::Zero),
rotmat(Matrix4::Identity),
frame(Random::GetInstance().Range(1, 2))
{
	lifeParam.lifeTime = 0.0f;
	lifeParam.lifeTimeLimit = Random::GetInstance().Range(20.0f, 25.0f);
	lifeParam.isDead = false;

	moveParam.pos = tornadePos;

	drawParam.drawID = MODEL_ID::TORNADOPOLY_MODEL;
	//drawParam.drawID = MODEL_ID::TORNADOPOLY_MODEL;
	drawParam.size = 50.0f + radius / 100.0f;
	drawParam.alpha = 0.8f;
}
Exemple #4
0
		// Run if there is a collision with an object of a different group
		void ControlPlayer::OnCollision(PhysicsCollisionGroups otherGroup, 
										 std::weak_ptr<PhysicsEntity> otherEntity)
		{
			// Check if collision was with a enemy bullet
			if(otherGroup == PhysicsCollisionGroups::GroupD)
			{
				// Delete the bullet no matter what
				otherEntity._Get()->GetGameObject()._Get()->Destroy();

				// Decrement player health
				_health--;

				// Add 1 point for being hit by enemy bullets
				auto scoreKeeperObj = GameObjectContainer::GetByName("ScoreKeeper");
				auto scoreKeeper = scoreKeeperObj._Get()->GetCustomComponent<component::ScoreKeeper>();
				scoreKeeper._Get()->AddScore(1);

				_deathSnd._Get()->Play();
			}

			// Check if player is out of health
			if(_health < 1)
			{
				SceneRegistry::LoadScene<scene::GameOverScene>();
			}
		}
Exemple #5
0
	// Ctor
	PhysicsEntity::PhysicsEntity(std::weak_ptr<GameObject> gameObject) :
		_radius(1.0f),
		_velocity(0.0f, 0.0f, 0.0f),
		_acceleration(0.0f, 0.0f, 0.0f),
		_rotationalVelocity(0.0f, 0.0f, 0.0f),
		_rotationalAcceleration(0.0f, 0.0f, 0.0f),
		_linearDrag(0.0f),
		_angularDrag(0.0f),
		_gameObject(gameObject),
		_transform(gameObject._Get()->GetTransform()),
		_isPersistant(false)
	{
		_uniqueID = _idSource++;
	}
	// STATIC:
	float PhysicsEntityContainer::getSquaredDistance(std::weak_ptr<PhysicsEntity> e1, 
													 std::weak_ptr<PhysicsEntity> e2)
	{
		// Abort if null pointers
		if(e1.expired() || e2.expired()) return 0;

		// Set the difference between positions in each dimension
		float deltaX = e1._Get()->GetTransform()._Get()->GetPosition().x
			- e2._Get()->GetTransform()._Get()->GetPosition().x;
		float deltaY = e1._Get()->GetTransform()._Get()->GetPosition().y
			- e2._Get()->GetTransform()._Get()->GetPosition().y;
		float deltaZ = e1._Get()->GetTransform()._Get()->GetPosition().z
			- e2._Get()->GetTransform()._Get()->GetPosition().z;

		// Squared distance formula (doesn't use square root)
		return deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ;
	}
	// Ctor
	ObjectRendererComponent::ObjectRendererComponent(std::weak_ptr<GameObject> owningGameObject) :
		Component(owningGameObject)
	{
		// Create the Object Renderer with defaults
		_renderer = std::shared_ptr<ObjectRenderer>(
			new ObjectRenderer(
				MeshRegistry::GetByName("CubeMesh"),
				MaterialRegistry::GetByName("Blank")
			)
		);

		// Make persistant, if owning GameObject is
		if(owningGameObject._Get()->IsPersistant())
		{
			_renderer->SetPersistance(true);
		}

		// Add it to the render container
		RendererContainer::Add(_renderer);

		// Run Start
		Start();
	}