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


C++ Being::isTalking方法代码示例

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


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

示例1: handle_mouse

    void handle_mouse(Event *evt)
    {
        if (!mapEngine->mapLoaded())
            return;

        Point camPos = graphicsEngine->getCamera()->getPosition();
        Point pos;
        pos.x = evt->x + camPos.x;
        pos.y = evt->y + camPos.y + mapEngine->getTileHeight();

        // left mouse button has finished being pressed
        if (evt->button == SDL_BUTTON_LEFT && evt->type == 1)
        {
            // check user clicked on map
            Node *node = graphicsEngine->getNode(pos.x, pos.y);
            if (node)
            {
                // show name if player/NPC is clicked
                Being *being = beingManager->findBeing(node->getName());
                if (being)
                {
                    // toggle being name
                    being->toggleName();
                    if (being->isNPC() && withinReach(being->getPosition(), player->getSelectedCharacter()->getPosition()) && !being->isTalking())
                    {
                        Packet *p = new Packet(PGMSG_NPC_START_TALK);
                        p->setInteger(being->getId());
                        networkManager->sendPacket(p);
                    }
                    return;
                }

                Point pt = mapEngine->convertPixelToTile(pos.x, pos.y);

                if (mapEngine->blocked(pt))
                    return;

                // send move message
                Packet *p = new Packet(PGMSG_PLAYER_MOVE);
                p->setInteger(pt.x);
                p->setInteger(pt.y);
                networkManager->sendPacket(p);
                //logger->logDebug("Sending move request");

                // save destination for later
                player->getSelectedCharacter()->saveDestination(pt);
            }
        }

		if (evt->button == 0)
		{
		    if (!interfaceManager->getMouse()->cursor)
                return;

//            pos.x += mapEngine->getTileWidth() >> 1;

		    int mapWidth = mapEngine->getWidth() * mapEngine->getTileWidth();
		    int mapHeight = mapEngine->getHeight() * mapEngine->getTileHeight();

		    if (pos.x > mapWidth || -pos.x > mapWidth)
		        return;
		    if (pos.y > mapHeight || pos.y < 0)
		        return;

            Point tilePos = mapEngine->convertPixelToTile(pos.x, pos.y);

		    if (tilePos.x < 0 || tilePos.y < 0)
                return;

		    if (tilePos.x == interfaceManager->getMouse()->cursorPos.x && tilePos.y == interfaceManager->getMouse()->cursorPos.y)
                return;

            interfaceManager->getMouse()->cursorPos = tilePos;

		    Point screenPos;
		    screenPos.x = 0.5 * (tilePos.x - tilePos.y) * mapEngine->getTileWidth();
            screenPos.y = 0.5 * (tilePos.x + tilePos.y) * mapEngine->getTileHeight();
			interfaceManager->getMouse()->cursor->moveNode(&screenPos);
		}
    }
开发者ID:suprafun,项目名称:smalltowns,代码行数:80,代码来源:teststate.cpp


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