本文整理匯總了PHP中Shadowrun4::getNPC方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shadowrun4::getNPC方法的具體用法?PHP Shadowrun4::getNPC怎麽用?PHP Shadowrun4::getNPC使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Shadowrun4
的用法示例。
在下文中一共展示了Shadowrun4::getNPC方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createEnemyNPC
/**
* Create a single NPC, optionally make it join a party. Else create blank party.
* @param string $classname
* @param NULL|SR_Party $party
* @return SR_NPC
*/
public static function createEnemyNPC($classname, $party = NULL)
{
if (false === ($npc = Shadowrun4::getNPC($classname))) {
return Dog_Log::error('Unknown NPC classname in createEnemyNPC: ' . $classname);
}
if ($party === NULL) {
if (false === ($party = SR_Party::createParty())) {
return Dog_Log::error('Cannot create party in createEnemyNPC.');
}
} elseif (!$party instanceof SR_Party) {
return Dog_Log::error('WRONG ARG IN in createEnemyNPC: ' . $party);
}
if (false === ($npc = $npc->spawn($party))) {
return Dog_Log::error('Failed to spawn NPC: ' . $npc->getNPCClassName());
}
if (false === $party->updateMembers()) {
return Dog_Log::error('DB ERROR IN in createEnemyNPC.');
}
$party->recomputeEnums();
return $npc;
}
示例2: onInit
public function onInit()
{
foreach ($this->getImportNPCS() as $classname) {
if (false === ($npc = Shadowrun4::getNPC($classname))) {
die("Unknown import_npc {$classname} in city {$this->getName()}.\n");
}
$this->npcs[$classname] = $npc;
}
}
示例3: getHelpTextNPCs
public function getHelpTextNPCs(SR_Player $player)
{
$npcs = $this->getNPCS($player);
# None
if (count($npcs) === 0) {
return false;
}
# Single
if (count($npcs) === 1) {
$cmd = '#' . key($npcs);
$classname = array_pop($npcs);
$npc = Shadowrun4::getNPC($classname);
$npc->setChatPartner($player);
return ' ' . $player->lang('hlp_talking1', array($cmd, $npc->getName()));
}
# Multiple
$cmds = array();
foreach ($npcs as $cmd => $classname) {
$cmds[] = '#' . $cmd;
}
return ' ' . $player->lang('hlp_talking2', array(GWF_Array::implodeHuman($cmds)));
}