public function _createMobInsideArea() { $k = Types::getKindFromString($this->kind); $pos = $this->_getRandomPositionInsideArea(); $mob = new Mob('1' . $this->id . '' . $k . '' . count($this->entities), $k, $pos['x'], $pos['y']); // @todo bind $mob->onMove(array($this->world, 'onMobMoveCallback')); return $mob; }
public function getDroppedItem($mob) { $kind = Types::getKindAsString($mob->kind); $drops = Properties::$properties[$kind]['drops']; $v = rand(0, 100); $p = 0; foreach ($drops as $itemName => $percentage) { $p += $percentage; if ($v <= $p) { $item = $this->addItem($this->createItem(Types::getKindFromString($itemName), $mob->x, $mob->y)); return $item; } } }