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


C++ IPlayer::SetPos方法代码示例

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


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

示例1: main

int main(int argc, char* argv[])
{
    int nResult = false;
    int nRetCode = false;

    int i = 0;
    printf("%s\n", argv[0]);
    srand( (unsigned)time( NULL ) );

    memset(g_szGMCommandList, 0, MAX_GM_COUNT * MAX_GM_SIZE);
    nRetCode = ProcessArg(argc, argv);
    if (!nRetCode)
    {
        Help();
        goto Exit0;
    }


    //g_thePlayers.empty();

    for (i = g_AccoutIDMin; i <= g_AccoutIDMax; i++)
    {
        char szAccountName[0x100];

        sprintf(szAccountName, "Robot%04d", i);

        printf("Create %s ... ", szAccountName);

        IPlayer *pPlayer = new CPlayer(
            g_szServerIP, g_nServerPort,
            szAccountName
        );
        //Sleep(300);
        if (!pPlayer)
        {
            printf("fail!\n");
            continue;
        }
        printf("ok!\n");

        // flying add these, make the robot at the specified position
        if (g_nFlgSetPos)
            pPlayer->SetPos(g_ptBirthPos.x, g_ptBirthPos.y);
        // flying add these, make the robot auto attack to the NPCs
        if (g_nFlgSetAttack)
            pPlayer->SetAttack();
        pPlayer->SetSilence(g_nFlgSetSilence);
        pPlayer->SetChatTimer(g_nFlgChatTimer);
        pPlayer->ConnectToGateway();

        g_thePlayers.push_back( pPlayer );
    }

    printf("Press \'Q\' to End Program\n");

    while (true)
    {
        int ch = 0;

        PLAYER_LIST::iterator it;
        for ( it = g_thePlayers.begin(); it != g_thePlayers.end(); it ++ )
        {
            while (true)
            {
                if (!kbhit())
                    break;

                ch = getch();

                ch = toupper(ch);

                if ((ch == 'Q') || (ch == 27)) // ESC
                    break;
            }

            if ((ch == 'Q') || (ch == 27)) // ESC
                break;

            //Sleep(rand() % 40);

            CPlayer *pPlayer = (CPlayer *)(*it);

            if (pPlayer == NULL)
            {
                Sleep(100);
                continue;
            }

            if ((pPlayer->GetStatus()) != CPlayer::enumExitGame)
                continue;

            OnlineGameLib::Win32::_tstring sAccountName;

            pPlayer->GetAccountName(sAccountName);

            delete pPlayer;
            pPlayer = NULL;
            *it = NULL;
            printf("Destory %s ... ok!\n", sAccountName.c_str());

//.........这里部分代码省略.........
开发者ID:ueverything,项目名称:mmo-resourse-1,代码行数:101,代码来源:GatewayRobot.cpp


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