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


C++ GameObject::GetDescription方法代码示例

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


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

示例1: if

void
GuardRoom::Execute( ExamineCommand & cmd )
{
    Room & room  = *this;

    if ( cmd.m_strTarget == "guard")
    {
        m_numSearches++;
        m_numTotalSearches++;
        // Three consequtive searches wake guard
        if ( m_numSearches >= 3 )
        {
            // Report death message attached to room
            cout << GetProperty("deathmessage").As<string>() <<  "\n";
            g_Game.SetProperty("running", false);
        }
        else if ( m_numTotalSearches == 4 && g_Game.GetPlayer().GetItems()["key"] == NULL )
        {
            cout << GetProperty("key_found_message").As<string>() << ". ";
            GameObject *pKey = new GameObject();
            pKey->SetId("ID_KEY");
            pKey->SetName("key");
            pKey->SetDescription("key you pick-pocketed from guard");
            g_Game.GetPlayer().GetItems().push_back( pKey);
        }
        else
        {
            cout << GetProperty("guard_search_msg").As<string>() << ". ";
        }
    }
    else if ( cmd.m_strTarget == "room" )
    {
        cout << room.GetDescription() << "\n";
        list<string> items;
        for(auto item : room.GetItems())
        {
            items.push_back(item->GetName());
        }

        if ( items.empty())
        {
            cout << "There seems to be nothing in the room. ";
        }
        else
        {
            cout << "You can see " << Game::MakeReadable(items) << " in here.";
        }
        cout << "\n";
    }
    else
    {
        // examining room items.
        GameObject * item = GetItems()[cmd.m_strTarget];
        if ( item ) cout << item->GetDescription() << ". ";
        else     cout << "I do not know how to examine " << cmd.m_strTarget << ". ";
        cout << "\n";
    }
}
开发者ID:noxshroom,项目名称:SDL,代码行数:58,代码来源:GuardRoom.cpp

示例2: GetItems

void
Player::Execute( ExamineCommand & cmd )
{
  
  GameObject * item = GetItems()[cmd.m_strTarget];
  if ( !item ) throw ExamineCommandFailOnPlayerException("");
  cout << "After taking a closer look, you see " << item->GetDescription() << ". ";
  
}
开发者ID:jjalo,项目名称:SDL,代码行数:9,代码来源:Player.cpp


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