Пример #1
0
void PlayerEntity::Load(MetadataObject &metadata, SceneNode *sprites)
{
	SpriteEntity::Load(metadata, sprites);
	pSprite->SetZ(-10);

	if (this->GetClassName() == "OptimistPlayer")
		pText = sdNew(Sprite(*static_cast<Sprite *>(sprites->GetChildByName("BallonOptimist"))));
	else if (this->GetClassName() == "RealistPlayer")
		pText = sdNew(Sprite(*static_cast<Sprite *>(sprites->GetChildByName("BallonRealist"))));
	else
		pText = sdNew(Sprite(*static_cast<Sprite *>(sprites->GetChildByName("BallonPessimist"))));

	pText->SetPosition(0, 0);
	pText->SetVisible(false);
	gScene->Add(pText);

	b2Vec2 customSize(32, 32);

	pBody = gPhysics->CreateBody(pSprite, &customSize);
	pBody->SetFixedRotation(true);
	pBody->GetFixtureList()->SetUserData(this);

	pInput->AddKeyboardListener(this);
	//fVelocity = 2.0f;
	vPlayerVectorDirection = VECTOR_ZERO;
}
Пример #2
0
void BallEntity::Load(Seed::MetadataObject &metadata, Seed::SceneNode *sprites)
{
    SpriteEntity::Load(metadata, sprites);
    b2Vec2 customSize(22, 22);

    pBody = gPhysicsManager->CreateBody(pSprite, &customSize);
    pBody->SetFixedRotation(true);
    pBody->GetFixtureList()->SetUserData(this);

    vDirection = b2Vec2(-1, -1);
}
Пример #3
0
void EnemyEntity::Load(MetadataObject &metadata, SceneNode *sprites)
{
	SpriteEntity::Load(metadata, sprites);
	pSprite->SetZ(-10);
	clSensor.Load(metadata, this);

	if (!metadata.GetProperty("DisplayName").empty())
		sEnemy.displayName = metadata.GetProperty("DisplayName");
	else
		sEnemy.displayName = "Enemy";

	if (!metadata.GetProperty("EnemyId").empty())
		sEnemy.iEnemyId = std::stoi(metadata.GetProperty("EnemyId"));
	else
		sEnemy.iEnemyId = 0;

	if (!metadata.GetProperty("Level").empty())
		sEnemy.iLevel = std::stoi(metadata.GetProperty("Level"));
	else
		sEnemy.iLevel = 1;

	if (!metadata.GetProperty("AttackPower").empty())
		sEnemy.iAttackPower = std::stoi(metadata.GetProperty("AttackPower"));
	else
		sEnemy.iAttackPower = 3;

	if (!metadata.GetProperty("DefensePower").empty())
		sEnemy.iDefensePower = std::stoi(metadata.GetProperty("DefensePower"));
	else
		sEnemy.iDefensePower = 2;

	if (!metadata.GetProperty("Life").empty())
		sEnemy.iLife = std::stoi(metadata.GetProperty("Life"));
	else
		sEnemy.iLife = 5;

	if (!metadata.GetProperty("LifeTotal").empty())
		sEnemy.iLifeTotal = std::stoi(metadata.GetProperty("LifeTotal"));
	else
		sEnemy.iLifeTotal = 5;

	b2Vec2 customSize(40, 40);

	pBody = gPhysics->CreateKinematicBody(pSprite, &customSize);
	pBody->SetFixedRotation(true);
	pBody->GetFixtureList()->SetUserData(this);
}
Пример #4
0
void PlayerEntity::Load(Seed::MetadataObject &metadata, Seed::SceneNode *sprites)
{
	SpriteEntity::SetPSZSprite(metadata.sName.c_str());
	SpriteEntity::Load(metadata, sprites);

	b2Vec2 customSize(12, 56);

	pBody = gPhysicsManager->CreateBody(pSprite, &customSize);
	pBody->SetFixedRotation(true);
	pBody->GetFixtureList()->SetUserData(this);

	vDirection = VECTOR_ZERO;

	// Send the initial position
	if ((pRSClient->iIDPlayer == pRSClient->PlayerOne && this->GetName() == "PlayerLeft")
		|| (pRSClient->iIDPlayer == pRSClient->PlayerTwo && this->GetName() == "PlayerRight"))
	{
		pRSClient->sPacketData.vRemotePlayer = pBody->GetPosition();
		pRSClient->cSocket.Send(pRSClient->GetAddress(), &pRSClient->sPacketData, sizeof(pRSClient->sPacketData));
	}

	pInput->AddKeyboardListener(this);
}