initial commit
This commit is contained in:
commit
e8c3f9862a
193 files changed
+29795
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Game\Entities;
|
||||
|
||||
use App\Game\EntityList;
|
||||
use App\Game\Player;
|
||||
use App\Game\Room;
|
||||
|
||||
final class MegaTank extends Zombie
|
||||
{
|
||||
public function __construct(
|
||||
float $x,
|
||||
float $y,
|
||||
EntityList $container,
|
||||
Room $room,
|
||||
?Player $initialTarget,
|
||||
array $config = [],
|
||||
?callable $onDeath = null,
|
||||
) {
|
||||
$spawnCount = $config['spawnCount'] ?? 3;
|
||||
$spawnOnDeath = $config['spawnOnDeath'] ?? null;
|
||||
parent::__construct($x, $y, $container, $room, $config, $onDeath ?? function (Zombie $mega) use ($spawnCount, $spawnOnDeath): void {
|
||||
if ($spawnOnDeath === null) {
|
||||
return;
|
||||
}
|
||||
for ($i = 0; $i < $spawnCount; $i++) {
|
||||
$angle = ($i / $spawnCount) * M_PI * 2.0;
|
||||
$offset = $mega->size + 28.0;
|
||||
$spawnOnDeath(
|
||||
$mega->pos->x + cos($angle) * $offset,
|
||||
$mega->pos->y + sin($angle) * $offset,
|
||||
$mega->container,
|
||||
$mega->room,
|
||||
$mega->target,
|
||||
);
|
||||
}
|
||||
});
|
||||
if ($initialTarget !== null) {
|
||||
$this->target = $initialTarget;
|
||||
}
|
||||
}
|
||||
|
||||
public function kind(): string
|
||||
{
|
||||
return 'megatank';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user