本文整理汇总了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)));
}