本文整理汇总了C++中Part::getActScript方法的典型用法代码示例。如果您正苦于以下问题:C++ Part::getActScript方法的具体用法?C++ Part::getActScript怎么用?C++ Part::getActScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part::getActScript方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activation
void Player::activation()
{
float lowestDist = 90;
bool partFound = false;
Part* closestPart = NULL;
int closestPartID;
float partDist = lowestDist + 1;
//Looping thru all of the parts
for(int i = 0; i < world->getPartAmount(); i++)
{
if(world->getPartUsable(i) == 1) //Making sure we are only looking at parts that can actually be used
{
float partX = world->getPartX(i);
float partY = world->getPartY(i);
float distX = partX - x;
float distY = partY - y;
float dist = agk::Sqrt(distX * distX + distY * distY);
int useRange = 90;
if(dist < useRange) //Checking if the part is within reach
{
partFound = true;
if(dist < lowestDist) //CHecking if this is the closest part found
{
lowestDist = dist; //Changing the lowest distance
partDist = dist;
closestPart = world->getPartFromID(i); //Changing the lowest part we have found
closestPartID = i;
}
}
}
}
bool npcFound = false;
NPC* closestNPC = NULL;
float npcDist = lowestDist + 1;
//Looping thru all the NPCs (Using the)
for(unsigned int i = 0; i < defaultNPCGroup->getNPCAmount(); i++)
{
NPC* npc = defaultNPCGroup->getNPC(i);
if(npc != NULL)
{
float npcX = npc->getX();
float npcY = npc->getY();
float distX = npcX - x;
float distY = npcY - y;
float dist = agk::Sqrt(distX * distX + distY * distY);
if(dist < lowestDist)
{
npcFound = true;
lowestDist = dist;
npcDist = dist;
closestNPC = npc;
}
}
}
if((partFound == true && closestPart != NULL) || (npcFound == true && closestNPC != NULL))
{
if(partDist < npcDist)
{
//Positioning the activation text
agk::SetTextVisible(activateText, 1);
agk::SetTextPosition(activateText, agk::WorldToScreenX( closestPart->getX() ), agk::WorldToScreenY( closestPart->getY() ));
//Changing the text to the use text of the part
std::string fText;
fText = i_activateName;
fText.append(") ");
fText.append(closestPart->getUseMsg());
agk::SetTextString(activateText, fText.data());
//Adding the background
agk::SetSpritePosition(activateSprite, agk::WorldToScreenX(closestPart->getX()) -5.0f, agk::WorldToScreenY(closestPart->getY()) - 2.5f);
agk::SetSpriteVisible(activateSprite, 1);
agk::SetSpriteScale(activateSprite, agk::GetTextTotalWidth(activateText) + 10, agk::GetTextTotalHeight(activateText) + 5);
//Checking if the part is activated
if(Input::activate() == true)
{
//Getting the script of the item
std::string actScript;
actScript = ("scripts/");
actScript.append(closestPart->getActScript());
//Saving the part that was activated last for use with labels in lua
world->setLastActive(closestPartID);
//Checking if this is a lua script or an old script
//.........这里部分代码省略.........