当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerData类代码示例

本文整理汇总了C++中PlayerData的典型用法代码示例。如果您正苦于以下问题:C++ PlayerData类的具体用法?C++ PlayerData怎么用?C++ PlayerData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PlayerData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: net_send_game_init_data

void net_send_game_init_data(GameNetConnection& net, PlayerData& pd, int seed) {
	for (int n = 0; n < pd.all_players().size(); n++) {
		int net_id = pd.all_players()[n].net_id;

		if (net_id == 0) {
			continue; // Don't send to self
		}

		// Send a version to each player detailing which player entry is theirs
		// This is a necessary (slight) evil

		SerializeBuffer& sb = net.grab_buffer(
				GameNetConnection::PACKET_SERV2CLIENT_INITIALPLAYERDATA);

		sb.write_int(seed);
		// Send which index is local player to recipient:
		sb.write_int(n);
		std::vector<PlayerDataEntry>& plist = pd.all_players();
		sb.write_int(plist.size());
		for (int i = 0; i < plist.size(); i++) {
			PlayerDataEntry& pde = plist[i];
			sb.write(pde.player_name);
			sb.write_int(pde.classtype);
			sb.write_int(pde.net_id);
		}
		net.send_packet(sb, net_id);
	}
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:28,代码来源:GameNetConnection.cpp

示例2: net_recv_game_init_data

void net_recv_game_init_data(SerializeBuffer& sb, int sender,
		GameStateInitData& init_data, PlayerData& pd) {
	//Write seed
	sb.read_int(init_data.seed);
	init_data.seed_set_by_network_message = true;

	//Read player data
	int localidx;
	sb.read_int(localidx);
	pd.set_local_player_idx(localidx);
	int playern;
	sb.read_int(playern);
	LANARTS_ASSERT(pd.all_players().empty());
	for (int i = 0; i < playern; i++) {
		std::string name;
		class_id classtype;
		int net_id;
		sb.read(name);
		sb.read_int(classtype);
		sb.read_int(net_id);
		pd.register_player(name, NULL, classtype, net_id);
	}
	printf("Received init packet: seed = 0x%X, localid = %d, nplayers = %d\n",
			init_data.seed, localidx, playern);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:25,代码来源:GameNetConnection.cpp

示例3: tolua_PlayerData_PlayerData_setEnergy00

static int tolua_PlayerData_PlayerData_setEnergy00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"PlayerData",0,&tolua_err) ||
     !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  PlayerData* self = (PlayerData*)  tolua_tousertype(tolua_S,1,0);
  int _energy = ((int)  tolua_tonumber(tolua_S,2,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setEnergy'", NULL);
#endif
  {
   self->setEnergy(_energy);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setEnergy'.",&tolua_err);
 return 0;
#endif
}
开发者ID:gatewen,项目名称:Lua_Example,代码行数:29,代码来源:tolua_PlayerData.cpp

示例4: tolua_PlayerData_PlayerData_getEnergy00

static int tolua_PlayerData_PlayerData_getEnergy00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"PlayerData",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  PlayerData* self = (PlayerData*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getEnergy'", NULL);
#endif
  {
   int tolua_ret = (int)  self->getEnergy();
   tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getEnergy'.",&tolua_err);
 return 0;
#endif
}
开发者ID:gatewen,项目名称:Lua_Example,代码行数:28,代码来源:tolua_PlayerData.cpp

示例5: tolua_PlayerData_PlayerData_setName00

static int tolua_PlayerData_PlayerData_setName00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"PlayerData",0,&tolua_err) ||
     !tolua_isstring(tolua_S,2,0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,3,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  PlayerData* self = (PlayerData*)  tolua_tousertype(tolua_S,1,0);
  char* _name = ((char*)  tolua_tostring(tolua_S,2,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setName'", NULL);
#endif
  {
   self->setName(_name);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setName'.",&tolua_err);
 return 0;
#endif
}
开发者ID:gatewen,项目名称:Lua_Example,代码行数:29,代码来源:tolua_PlayerData.cpp

示例6: tolua_PlayerData_PlayerData_getName00

static int tolua_PlayerData_PlayerData_getName00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
 tolua_Error tolua_err;
 if (
     !tolua_isusertype(tolua_S,1,"PlayerData",0,&tolua_err) ||
     !tolua_isnoobj(tolua_S,2,&tolua_err)
 )
  goto tolua_lerror;
 else
#endif
 {
  PlayerData* self = (PlayerData*)  tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'getName'", NULL);
#endif
  {
   const char* tolua_ret = (const char*)  self->getName();
   tolua_pushstring(tolua_S,(const char*)tolua_ret);
  }
 }
 return 1;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'getName'.",&tolua_err);
 return 0;
#endif
}
开发者ID:gatewen,项目名称:Lua_Example,代码行数:28,代码来源:tolua_PlayerData.cpp

示例7: net_recv_game_init_data

void net_recv_game_init_data(SerializeBuffer& sb, int sender,
        GameStateInitData& init_data, PlayerData& pd) {
    //Write seed
    sb.read(init_data);
    init_data.received_init_data = true;

    //Read player data
    int localidx;
    sb.read_int(localidx);
    int playern;
    sb.read_int(playern);
    LANARTS_ASSERT(pd.all_players().empty());
    for (int i = 0; i < playern; i++) {
        std::string name;
        std::string classtype;
        int net_id;
        sb.read(name);
        sb.read(classtype);
        sb.read_int(net_id);
        pd.register_player(name, NULL, classtype, LuaValue(), (i == localidx), net_id);
    }

    printf(
            "Received init packet: seed = 0x%X, localid = %d, nplayers = %d, "
                    "frame_action_repeat = %d, regen_level_on_death = %d, network_debug_mode = %d, time_per_step = %f\n",
            init_data.seed, localidx, playern, init_data.frame_action_repeat,
            (int) init_data.regen_on_death,
            (int) init_data.network_debug_mode, init_data.time_per_step);
}
开发者ID:ludamad,项目名称:lanarts,代码行数:29,代码来源:GameNetConnection.cpp

示例8:

PlayerData::PlayerData(const PlayerData &other)
	: m_uniqueId(other.GetUniqueId()), m_dbId(other.GetDBId()), m_number(other.GetNumber()), m_startCash(other.GetStartCash()),
	  m_guid(other.GetGuid()), m_oldGuid(other.GetOldGuid()), m_name(other.GetName()), m_password(), m_country(other.GetCountry()),
	  m_avatarFile(other.GetAvatarFile()), m_avatarMD5(other.GetAvatarMD5()), m_type(other.GetType()), m_rights(other.GetRights()),
	  m_isGameAdmin(other.IsGameAdmin()), m_netAvatarFile(), m_dataMutex()
{
}
开发者ID:27183,项目名称:pokerth,代码行数:7,代码来源:playerdata.cpp

示例9: set_ready

void NetClient::set_ready(const bool b)
{
    if (!me || !server || ourself == players.end()) return;
    PlayerData copy = *ourself;
    copy.ready = (char) b;
    ENetPacket* pck = copy.create_packet();
    enet_peer_send(server, LEMNET_CHANNEL_MAIN, pck);
}
开发者ID:AmandaBayless,项目名称:Lix,代码行数:8,代码来源:client.cpp

示例10: set_style_and_spec

void NetClient::set_style_and_spec(const char st, const bool sp)
{
    if (!me || !server || ourself == players.end()) return;
    PlayerData copy = *ourself;
    copy.style = st;
    copy.spec  = sp;
    ENetPacket* pck = copy.create_packet();
    enet_peer_send(server, LEMNET_CHANNEL_MAIN, pck);
}
开发者ID:AmandaBayless,项目名称:Lix,代码行数:9,代码来源:client.cpp

示例11: net_recv_connection_affirm

// Only the server is concerned with this message
void net_recv_connection_affirm(SerializeBuffer& sb, int sender,
		PlayerData& pd) {
	std::string name;
	class_id classtype;
	sb.read(name);
	sb.read_int(classtype);
	printf("connection affirm read\n");
	pd.register_player(name, NULL, classtype, sender);
	printf("now there are %d players\n", (int)pd.all_players().size());
	pd.set_local_player_idx(0);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:12,代码来源:GameNetConnection.cpp

示例12: net_recv_connection_affirm

// Only the server is concerned with this message
void net_recv_connection_affirm(SerializeBuffer& sb, int sender,
        PlayerData& pd) {
    printf("Recv conn with size=%d\n", sb.size());
    std::string name;
    std::string classtype;
    sb.read(name);
    sb.read(classtype);
    printf("connection affirm read\n");
    pd.register_player(name, NULL, classtype, LuaValue(), /* is local player */ false, sender);
    printf("now there are %d players\n", (int) pd.all_players().size());
}
开发者ID:ludamad,项目名称:lanarts,代码行数:12,代码来源:GameNetConnection.cpp

示例13: PlayerData

/**
 * 'Menu Prototype' was selected. Push a Menu state.
 * \todo This will eventually be removed entirely, as it is only a programmer convenience right now.
 */
void MainMenu::MenuPrototypeAction()
{
   PlayerData* playerData = new PlayerData();
   playerData->load(SAVE_GAME);

   /** \todo This is never deleted, causing a memory leak. */
   MenuShell* menuShell = new MenuShell(*playerData);

   HomeMenu* menu = new HomeMenu(executionStack, *menuShell, *playerData);
   executionStack.pushState(menu);
}
开发者ID:linwang,项目名称:EDEn,代码行数:15,代码来源:MainMenuActions.cpp

示例14: if

 X_VOID		MainGame::EndBattle(bool win)
 {
	 
	 //------------打开战斗前的界面
	 m_nGameRunState = RUNING_IN_GAME;
	 SceneManger::GetSingleton()->EnterScene(SceneManger::EM_SS_MAIN);

	if(DataPool::GetSingleton()->BattlyType == EM_COPY_SCENE)
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_LEVELLIST_SHOW);
	else if(DataPool::GetSingleton()->BattlyType == EM_SPORT)
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_RANKLIST_SHOW);
	else if(DataPool::GetSingleton()->BattlyType == EM_WOODPVP)
	{
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_BASE_ACTIVITY_SHOW);
	}
	else if(DataPool::GetSingleton()->BattlyType == EM_BATTLETYPE_QUJING)
	{
		vector<string> str;str.clear();
		str.push_back(UtilTools::IntToString(EM_HUSONG_WOOD));//
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_CHEESE_SHOW,str);
		SendLogicPacket::OpenQuJingUi();
		EventSystem::GetSingleton()->PushEvent(GAME_EVNET_LVL_ESCORTWOOD_SHOW);
	}
	else if(DataPool::GetSingleton()->BattlyType == EM_BATTLETYPE_BLOODBATTLE)
	{
		BloodData* pBloodData = DataPool::GetSingleton()->GetBloodData();
		if (win)
		{
				pBloodData->NextStep();
		}else
		{
				pBloodData->EnterBloodUi();
		}
	}
	else 
		EventSystem::GetSingleton()->PushEvent(GAME_EVENT_CHEESE_SHOW);


	ObjectManager* pManager = DataPool::GetSingleton()->getObjectManager();
	PlayerData* pData = pManager->getSelf()->playerData();
	if (pData && pData->IsLevelUp())
	{
		pData->resetLevelUp();
		EventSystem::GetSingleton()->PushEvent(GAME_EVNET_LVL_UPGRADE_SHOW);
	}
	

	 BattleData * pBattle = DataPool::GetSingleton()->GetBattleData();
	 pBattle->DestroyBattleData();
	 


 }
开发者ID:LSilent,项目名称:moe_hero,代码行数:53,代码来源:MainGame.cpp

示例15: Tick

void Phase_Harvest::Tick()
{
    PlayerData* currentPlayerData = GameSceneManager::getInstance()->getCurrentPlayerData();
    currentPlayerData->setFood(1);

    //만약 옥토 타일 위에 턴주의 병사가 있다면 해당 병사 한명당 식량 1 ++해야함.
    auto characterList = currentPlayerData->getCharacterList();

    for (auto iter : *characterList)
    {
        if (iter->getCurrentTile()->getTypeOfTile() == TILE_RICH || iter->getCurrentTile()->getTypeOfTile() == TILE_RICH_SIDE)
        {
            //currentPlayerData->AddFood(1);
            EventManager::getInstance()->AddHistory(HistoryEventHarvest::Create(iter));
        }
    }
    _NextPhaseInfo = PHASE_OCCUPY;
}
开发者ID:atgchan,项目名称:2015_GaeKyungPu,代码行数:18,代码来源:Phase_Harvest.cpp


注:本文中的PlayerData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。