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


C++ PlayerEntity::getMode方法代码示例

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


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

示例1: createPlayers

/**

  Designer: Jeff Bayntun, Eric Tsang
  Coder:    Jeff Bayntun, Sanders Lee (Added code for getting player type)
 * @brief ServerGameScene::createPlayers
 * Creates all the vessels and deitys, this includes hooking them up
 * across the network.
 */
void ServerGameScene::createPlayers()
{
    std::map<Session*, PlayerEntity*> players = command->getGameState()->getPlayers();
    PlayerEntity* currPlayer;
    Session* currSession;
    PLAYER_MODE mode;
    PLAYER_TYPE type;
    int vesselNo = 0;
    int vesselX = 0;
    int vesselY = 0;

    // make ServerNetworkController for each vessel
    for(auto it = players.begin(); it != players.end(); ++it)
    {
        currPlayer = it->second;
        currSession = it->first;
        mode = currPlayer->getMode();
        type = currPlayer->getType();
        currPlayer->setSGameScene(this);
	currPlayer->setVessel(NULL);

        switch(mode)
        {
            case PLAYER_MODE::VESSEL:
            {
                // create the controller, and bind it with the player
                ServerNetworkController* cont = new ServerNetworkController();
                currPlayer->setController(cont);

                // register the vessel controller with all clients
                EnemyControllerInit initData;
                switch(type)
                {
                  case PLAYER_TYPE::WARRIOR:
                      initData.type = ENTITY_TYPES::VESSEL_WARRIOR;
                      break;
                  case PLAYER_TYPE::SHAMAN:
                      initData.type = ENTITY_TYPES::VESSEL_SHAMAN;
                      break;
                }

		        gMap->getVesselPosition(vesselNo++, &vesselX, &vesselY);
                initData.x = (float) vesselX;
                initData.y = (float) vesselY;

                Message msg;
                msg.data = (void*) &initData;
                msg.len = sizeof(initData);

                // create vessel, pass it server vessel controller too
                Vessel* e = static_cast<Vessel*>(EntityFactory::getInstance()->makeEntityFromNetworkMessage(cMap,&msg,cont));
				currPlayer->setVessel(e);
				e->setPlayerEntity(currPlayer);

                //Add player entities to the list of players
                playerList.push_back(e);

                // register the server controller with the player
                msg.type = (int) ServerNetworkControllerClientNetworkControllerMsgType::FOLLOW_ME;
                cont->registerSession(currSession,msg);

                // register the server controller with clients
                msg.type = (int) ServerNetworkControllerClientNetworkControllerMsgType::NORMAL;
                command->getGameState()->registerWithAllPlayers(cont,&msg);
                break;
            }
            case PLAYER_MODE::GHOST:
            {
                break;
            }
            case PLAYER_MODE::DEITY:
            {
                //SeverDeityController* deityController = new DeityController();
                //p->setController(deityController);

                //create deity, pass it controller too.
                break;
            }
        }
    }
}
开发者ID:DataComm-Networking,项目名称:finalCD,代码行数:89,代码来源:ServerGameScene.cpp


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