コード例 #1
0
void PlayerSpawner::spawnPlayer(float x, float y, float z, uint32_t player_id, uint32_t team_id, uint32_t version, bool is_pinto)
{
	bool self = false;

	if(player_id == NetworkManager::instance()->player_id)
		self = true;

	PlayerCharacter *player = new PlayerCharacter(self, scene, "PixelMan.mesh",
            x, y + 50, z,
            0, 0, 0, 1,
            10, 10, 10,
            player_id, version, is_pinto);
	player->team_id = team_id;
	if(player->team_id == BLUE_TEAM)
	{
		player->switchToBlueTeam();
	}

	GameState::instance()->players[player_id] = player;

	if(self)
	{
		GameState::instance()->player = player;
	}
}
コード例 #2
0
Ogre::Vector3 PlayerSpawner::spawnPlayer(uint32_t player_id, bool is_pinto)
{
	Ogre::Vector3 position;
	if(GameState::instance()->team_mode == FFA || GameState::instance()->game_mode == PINTO)
	{
		position = free_positions[RAND_RANGE(0, free_positions.size())];
	}
	else
	{
		float rand_x = RAND_RANGE(0, SPAWN_RAND_RADIUS_MAX) - SPAWN_RAND_RADIUS_MAX;
		float rand_z = RAND_RANGE(0, SPAWN_RAND_RADIUS_MAX) - SPAWN_RAND_RADIUS_MAX;
		if(NetworkManager::instance()->player_team_id_map[player_id] == RED_TEAM)
		{
			position = red_position;
			position.x = position.x + rand_x;
			position.z = position.z + rand_z;
		}
		else
		{
			position = blue_position;
			position.x = position.x + rand_x;
			position.z = position.z + rand_z;
		}
	}
	
	bool self = false;

	if(player_id == NetworkManager::instance()->player_id)
	{
		self = true;
	}

	uint32_t version = RAND_RANGE(0, 5);

	PlayerCharacter *player = new PlayerCharacter(self, scene, "PixelMan.mesh",
            position.x, position.y + 50, position.z,
            0, 0, 0, 1,
            10, 10, 10,
            player_id, version, is_pinto);

	player->team_id = NetworkManager::instance()->player_team_id_map[player_id];
	if(player->team_id == BLUE_TEAM)
	{
		player->switchToBlueTeam();
	}

	GameState::instance()->players[player_id] = player;

	if(self)
	{
		GameState::instance()->player = player;
	}

	NetworkManager::instance()->vital->setPlayerRespawn(position.x, position.y, position.z, 
				player_id, NetworkManager::instance()->player_team_id_map[player_id], version, is_pinto);

	return position;
}