本文整理汇总了C++中CNpc::GetIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CNpc::GetIndex方法的具体用法?C++ CNpc::GetIndex怎么用?C++ CNpc::GetIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNpc
的用法示例。
在下文中一共展示了CNpc::GetIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleKey
void CAction::HandleKey(int actionKey, CTile *pTile)
{
// If the key is the shop keeper key
if(actionKey == kShopKeeperKey)
{
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
// Let's open a store and go to the shop menu by passing in the shop keeper npc
g_Shop.OpenStore((CNpc*)pTile);
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
}
// If we are doing the first contact with Trendor
else if(actionKey == kTrendorSceneKey)
{
// If we have not already done this, do the first dialog scene
if(m_actionKeys[actionKey] != 1)
DoTrendorCutScene();
// Otherwise, add Trendor to our party if we already talked to the Governor
else if(m_actionKeys[kGovernorSceneKey])
HandleKey(kAddTrendorKey, pTile);
else // Else encourage the player to talk to the Governor
DisplayCutSceneDialog("Trendor: Quinn, let me know if there is anything I can do to help. I am interested in what the Governor will say.");
// Set this action key as "happened" (1)
m_actionKeys[actionKey] = 1;
}
// If the key is to add Trendor
else if(actionKey == kAddTrendorKey)
{
// Check if we haven't added Trendor yet, then add him
if(!m_actionKeys[actionKey])
{
DisplayCutSceneDialog("Trendor: You talked to the Governor?!?!? That's great. I am coming with you. I don't want to just sit here and do nothing too.");
// Cast the passed in tile to it's correct type, which is an npc, then add Trendor
CNpc *pNpc = (CNpc*)pTile;
AddTrendorToGroup(pNpc);
m_actionKeys[actionKey] = 1;
g_Menu.DrawMessageBox("Trendor Joined your party!");
}
}
// If the action key is that we found the potion
else if(actionKey == kPotionKey)
{
// Set the potion key to being accomplished
m_actionKeys[actionKey] = 1;
}
// If we are meeting the Governor
else if(actionKey == kGovernorSceneKey)
{
// If we haven't talked with the Governor yet, do the long dialog
if(m_actionKeys[actionKey] != 1)
DoGovernorCutScene();
else // Otherwise, see if the player needs permission and is good enough
{
// If the player has enough experience to get permission
if(g_Player.GetExperience() >= kPermissionExpNeeded)
{
// If we already received permission, wish the player good luck
if(m_actionKeys[kPermissionKey])
DisplayCutSceneDialog("Governor: Good luck in the new world. I hope you find the sage you seek.");
else
{ // Otherwise, let's give the player permission to go across the bridge
DisplayCutSceneDialog("Governor: Wow Quinn, you have really improved. I think with your experience and strength you should be fine. You have my permission to enter the new world.");
m_actionKeys[kPermissionKey] = 1;
}
}
else // We aren't experienced enough, give encouragement
DisplayCutSceneDialog("Governor: I think you need to be a little stronger and with more experience. Come back after you improve a bit more.");
}
// Set the action key to true so that we know we already talked with the Governor
m_actionKeys[actionKey] = 1;
}
// If we are talking with the bridge guard
else if(actionKey == kBridgeGuardKey)
{
// If we don't have permission, tell the player they need permission to pass
if(m_actionKeys[kPermissionKey] == 0)
DisplayCutSceneDialog("Guard: Nobody gets by me unless you have the Governor's permission.");
else // Otherwise, we got permission!
{
// Cast the tile as the guard npc
CNpc *pGuard = (CNpc*)pTile;
// If the player is on the left side of the bridge, say we received permission
if(g_Player.GetPosition().x <= pGuard->GetIndex().x)
{
// Move the player past the guard and safely across the bridge
POINT newPosition = {g_Player.GetPosition().x + 2, g_Player.GetPosition().y};
// Tell the guard we received permission from the Governor and set new position
DisplayCutSceneDialog("Quinn: I just received permission from the Governor to pass.");
DisplayCutSceneDialog("Guard: Okay, you may pass. Be carefull over there.");
//.........这里部分代码省略.........