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


C++ IWeapon::setTarget方法代码示例

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


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

示例1: updateControls


//.........这里部分代码省略.........

            if(KeyboardState::keyReleased[m_KeyFirstPersonCamera])
            {
                toggleFirstPersonCamera();
            }
            break;

        // =====
        case STATE_NUKE:
        case STATE_BUILDING_PLACEMENT:
            // sanity check
            if(m_State == STATE_BUILDING_PLACEMENT && (!m_pCurrentBuildButton || !m_pCurrentBuildAssetDef)) {
                changeState(STATE_ASSET_CONTROL);
                break;
            }

            // update selector
            D3DXMATRIX matProj, matView;
            D3DXVECTOR3 rayOrigin, rayDir;
            m_pDevice->GetTransform(D3DTS_PROJECTION, &matProj);
            m_pDevice->GetTransform(D3DTS_VIEW, &matView);
            MouseState::transformTo3D(matView, matProj, rayOrigin, rayDir);
            D3DXVECTOR3* hitSquare = TerrainIntersection::pickTerrain(rayOrigin, rayDir);
            if(hitSquare)
            {
                m_pSelector->setPoint(D3DXVECTOR2(hitSquare->x, hitSquare->y));
                delete hitSquare;
            }

            // mouse actions
            if(MouseState::mouseButtonReleased[MouseState::mouseSecondButton]) {
                // return the preserved ore
                if(m_CurrentBuildOreTaken) {
                    m_pCurrentPlayer->modifyOre(m_CurrentBuildOreTaken);
                }
                // cancel build state with secondary mouse button
                changeState(STATE_ASSET_CONTROL);
                setNukeSilo(NULL);
                break;
            } else if(MouseState::mouseButtonReleased[MouseState::mouseFirstButton] && m_State == STATE_BUILDING_PLACEMENT) {
                // placement made
                if(m_pSelector->isBuildable()) {
                    D3DXVECTOR2 bpos = m_pSelector->getBuildingPoint();
                    // @TODO: assetfactory->create
                    IAsset* newAsset = AssetFactory::createAsset(m_pCurrentPlayer, m_pCurrentBuildAssetDef->tag, (short)bpos.x, (short)bpos.y);
                    if(newAsset) {
                        m_pCurrentBuildButton->setEnabled(false);
                        m_pCurrentBuildButton->setRandomObject(newAsset);
                        m_ButtonsToUpdate.pushHead(m_pCurrentBuildButton);
                    }
                    // problem, new asset not created, return ore to player
                    else {
                        if(m_CurrentBuildOreTaken)
                            m_pCurrentPlayer->modifyOre(m_CurrentBuildOreTaken);
                    }
                    changeState(STATE_ASSET_CONTROL);
                    break;
                }
                // @TODO ??
            } else if(MouseState::mouseButtonReleased[MouseState::mouseFirstButton] && m_State == STATE_NUKE) {
                if (m_pCurrentNukeSilo != NULL)
                {
                    IWeapon* pWeapon = m_pCurrentNukeSilo->getWeapon();
                    pWeapon->setTarget(new Target((unsigned short)m_pSelector->getNukePoint().x, (unsigned short)m_pSelector->getNukePoint().y));
                }
                changeState(STATE_ASSET_CONTROL);
                setNukeSilo(NULL);
                break;
            }

            break;

    } // switch

    // if mouse idles over asset, display tooltip showing it's name
    if(!MouseState::mouseMoved && (MouseState::mouseIdle > m_TooltipTreshold))
    {
        if(!m_TooltipShown)
        {
            D3DXMATRIX matProj, matView;
            D3DXVECTOR3 rayOrigin, rayDir;
            m_pDevice->GetTransform(D3DTS_PROJECTION, &matProj);
            m_pDevice->GetTransform(D3DTS_VIEW, &matView);
            MouseState::transformTo3D(matView, matProj, rayOrigin, rayDir);
            UIAsset* pUIAsset = UI3DObjectManager::pickAsset(rayOrigin, rayDir);
            if(pUIAsset)
            {
                string assetName = pUIAsset->getAsset()->getDef()->name;
                Cursor::getInstance()->setTooltip(assetName.c_str(), m_TooltipLifetime);
                m_TooltipShown = true;
            }
        }
    }
    else if(m_TooltipShown)
    {
        m_TooltipShown = false;
        Cursor::getInstance()->clearTooltip();
    }

}
开发者ID:underkround,项目名称:mazerts,代码行数:101,代码来源:UIAssetController.cpp


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