/**
  *
  * @param
  *        	$ticks
  */
 public function onRun($ticks)
 {
     try {
         if (empty($this->lv)) {
             return;
         }
         $start_time = microtime(true);
         $k = 1;
         foreach ($this->lv->currentMap->livePlayers as $gamer) {
             $targetWorldName = $gamer->levelName . "_TEMP";
             $this->lv->level->addSound(new LaunchSound($gamer->player->getPosition()), array($gamer->player));
             MapPortal::teleportToMap($targetWorldName, $gamer->player);
             $this->lv->currentMap->enterArena($gamer);
             MagicUtil::addEffect($gamer->player, Effect::INVISIBILITY, 1);
             foreach ($this->lv->currentMap->livePlayers as $gp) {
                 if ($gp instanceof GamePlayer) {
                     $gamer->hidePlayerFrom($gp->player);
                 }
             }
             $this->plugin->log("[HungerGamesLevelPlayerToArenaTask] " . $this->lv->type . " | selected map " . $targetWorldName . " TP player [" . $k++ . "]" . $gamer->player->getName() . ")");
         }
         $this->plugin->log("[HungerGamesLevelPlayerToArenaTask: took " . (microtime(true) - $start_time));
     } catch (\Exception $e) {
         $this->plugin->printError($e);
     }
 }
示例#2
0
 /**
  *
  * @param GameLevelModel $lv        	
  */
 public function generateRandomEffect(GameLevelModel $lv)
 {
     if (!empty($lv->currentMap) && count($lv->currentMap->livePlayers) > 0 && $lv->type === 2) {
         if ($lv->currentStep === GameLevelModel::STEP_HUNTING or $lv->currentStep === GameLevelModel::STEP_DEATH_MATCH) {
             foreach ($lv->currentMap->livePlayers as $gplayer) {
                 if ($gplayer instanceof GamePlayer) {
                     $eid = MagicUtil::generateRandomEffects();
                     MagicUtil::addEffect($gplayer->player, $eid, 80);
                     $particleName = MagicUtil::matchEffectParticles($eid);
                     if (!is_null($eid) && !is_null($particleName)) {
                         MagicUtil::addParticles($lv->currentMap->level, "explode", $gplayer->player->getPosition(), 120);
                     }
                 }
             }
         }
     }
 }
 /**
  *
  * @param
  *        	$ticks
  */
 public function onRun($ticks)
 {
     try {
         if (empty($this->lv) || empty($this->lv->currentMap)) {
             return;
         }
         $start_time = microtime(true);
         $k = 1;
         foreach ($this->lv->currentMap->livePlayers as $gamer) {
             $gamer->player->teleport(new Vector3($this->lv->currentMap->deathMatchEnter->x, $this->lv->currentMap->deathMatchEnter->y, $this->lv->currentMap->deathMatchEnter->z));
             MagicUtil::addEffect($gamer->player, Effect::INVISIBILITY, 1);
             $players[] = $gamer->player;
             $this->lv->level->addSound(new LaunchSound($gamer->player->getPosition()), $players);
             foreach ($this->lv->currentMap->livePlayers as $gp) {
                 $gamer->showPlayerTo($gp->player);
             }
             unset($players);
             $this->plugin->log("[HungerGamesPlayerToDeathMatchTask] " . $this->lv->type . " | death-match |" . $this->lv->currentMap->name . " TP player [" . $k++ . "]" . $gamer->player->getName() . ")");
         }
         $this->plugin->log("[HungerGamesPlayerToDeathMatchTask: took " . (microtime(true) - $start_time));
     } catch (\Exception $e) {
         $this->plugin->printError($e);
     }
 }
示例#4
0
 /**
  *
  * @param GameLevelModel $lv        	
  * @param Player $player        	
  * @return boolean
  */
 public function portalEnter(HungerGamesPlugIn $plugin, GameLevelModel $lv, Player $player)
 {
     if ($player->getLevel()->getName() != $lv->levelName) {
         return true;
     }
     if ($lv->insideLevelEntracePortal($player->getPosition())) {
         if (!isset($this->joinedPlayers[$player->getName()])) {
             if ($plugin->storyenforceaccess && $lv->type != 1) {
                 $w = $plugin->storyManager->hasPlayerWonLevel($player->getName(), $lv->type - 1);
                 if (!$w) {
                     $player->sendMessage(TextFormat::RED . "[HG Story Mode Enabled]");
                     $player->sendMessage(TextFormat::YELLOW . "Required " . TextFormat::GOLD . "WIN " . TextFormat::YELLOW . "previous level before play this level!");
                     $player->getLevel()->addSound(new LaunchSound($player->getPosition()), array($player));
                     if ($player->isOp()) {
                         $player->sendMessage(TextFormat::AQUA . "[Admin BY-PASS Story Mode Checking]");
                     } else {
                         $player->teleport($lv->enterpos);
                         return;
                     }
                 }
             }
             $this->joinedPlayers[$player->getName()] = $player;
             $message = TextFormat::GRAY . "[HG] [" . TextFormat::AQUA . $player->getName() . TextFormat::GRAY . "] joined " . $lv->displayName . " [" . TextFormat::GREEN . count($lv->joinedPlayers) . TextFormat::GRAY . " |" . TextFormat::WHITE . "minimal " . TextFormat::YELLOW . $lv->minPlayers . TextFormat::GRAY . "]";
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player->getPosition()), $lv->joinedPlayers);
             $effect = MagicUtil::addEffect($player, Effect::STRENGTH);
             if ($effect != null) {
                 $this->playersWithEffects[$player->getName()] = $effect;
             }
             if (!$player->isOp()) {
                 if (!$player->isSurvival()) {
                     $player->setGamemode(Player::SURVIVAL);
                 }
             }
             $player->sendMessage(TextFormat::YELLOW . "[HG] Please wait here");
             $player->sendMessage(TextFormat::GRAY . "[HG] The game auto start with minimal players");
         }
     } else {
         if (isset($this->joinedPlayers[$player->getName()])) {
             $message = TextFormat::GRAY . "[ " . $player->getName() . " ] left " . $lv->displayName;
             $player->getServer()->broadcastMessage($message, $this->joinedPlayers);
             $lv->level->addSound(new DoorSound($player), $lv->joinedPlayers);
             unset($this->joinedPlayers[$player->getName()]);
             if (count($this->joinedPlayers) < $lv->minPlayers) {
                 $lv->joinDownCounter = $lv->joinDownCounterReset;
             }
             foreach ($plugin->arenaManager->arenas as &$arena) {
                 if ($arena instanceof MapArenaModel) {
                     if (isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                         if ($arena->vote >= 1) {
                             $arena->vote--;
                         }
                         break;
                     }
                 }
             }
             if (isset($this->playersWithEffects[$player->getName()])) {
                 $effect = $this->playersWithEffects[$player->getName()];
                 if ($effect != null) {
                     $player->removeEffect($effect->getId());
                     unset($this->playersWithEffects[$player->getName()]);
                 }
             }
         }
     }
 }
示例#5
0
 /**
  *
  * Handle Tap On Arena Signs
  *
  * @param Player $player        	
  * @param unknown $b        	
  * @return boolean
  */
 public function handleTapOnArenaSigns(Player $player, $b)
 {
     foreach ($this->arenas as &$arena) {
         if ($arena instanceof MapArenaModel) {
             // tap on vote sign
             if (!empty($arena->signVote)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signVote->x) . "." . round($arena->signVote->y) . "." . round($arena->signVote->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     if (!$arena->published) {
                         $player->sendMessage("[HG] This map is not available yet! please try another one.");
                         break;
                     }
                     $players[] = $player;
                     $player->getLevel()->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "reddust", $arena->signVote, 20);
                     if ($arena->vote === 0 && isset($arena->votedPlayers[$player->getName()])) {
                         unset($arena->votedPlayers[$player->getName()]);
                     }
                     if (!isset($arena->votedPlayers[$player->getName()])) {
                         $arena->vote++;
                         $arena->votedPlayers[$player->getName()] = $player;
                     } else {
                         $player->sendMessage(TextFormat::YELLOW . "[HG] Already voted! [" . $arena->displayName . "]");
                     }
                     $player->sendMessage(TextFormat::GRAY . "[HG] " . $arena->displayName . " map votes [" . TextFormat::YELLOW . $arena->vote . TextFormat::GRAY . "]");
                     break;
                 }
             }
             if (!empty($arena->signExit) && !empty($arena->arenaExitPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signExit->x) . "." . round($arena->signExit->y) . "." . round($arena->signExit->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->level->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                     unset($arena->joinedPlayers[$player->getName()]);
                     unset($arena->livePlayers[$player->getName()]);
                     $player->teleport($arena->arenaExitPos);
                     break;
                 }
             }
             if (!empty($arena->signJoin) && !empty($arena->arenaEnterPos)) {
                 $blockPosKey = round($b->x) . "." . round($b->y) . "." . round($b->z);
                 $casePosKey = round($arena->signJoin->x) . "." . round($arena->signJoin->y) . "." . round($arena->signJoin->z);
                 if ($blockPosKey === $casePosKey && $blockPosKey != "0.0.0") {
                     $players[] = $player;
                     $player->level->addSound(new ClickSound($player->getPosition()), $players);
                     MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                     MapPortal::teleportToMap($arena->levelName, $player);
                     $player->teleport($arena->arenaEnterPos);
                     break;
                 }
             }
         }
     }
 }
示例#6
0
 public function updateVIPSigns()
 {
     if (!empty($this->plugin->vipSignPos) and !empty($this->plugin->hubLevel)) {
         $sign = $this->plugin->hubLevel->getTile(new Vector3($this->plugin->vipSignPos->x, $this->plugin->vipSignPos->y, $this->plugin->vipSignPos->z));
         if (!is_null($sign) and $sign instanceof Sign) {
             $sign->setText(TextFormat::GOLD . "-VIP members-", TextFormat::GREEN . "Enter", TextFormat::BOLD . TextFormat::WHITE . "[ " . TextFormat::RED . "VIP+ " . TextFormat::AQUA . "Lodge" . TextFormat::WHITE . " ]", TextFormat::WHITE . "---");
             MagicUtil::addParticles($this->plugin->hubLevel, "reddust", $this->plugin->vipSignPos, 8);
         }
         unset($sign);
     }
     if (!empty($this->plugin->vipExitSignPos) and !empty($this->plugin->vipLevel)) {
         $sign = $this->plugin->vipLevel->getTile(new Vector3($this->plugin->vipExitSignPos->x, $this->plugin->vipExitSignPos->y, $this->plugin->vipExitSignPos->z));
         if (!is_null($sign) and $sign instanceof Sign) {
             $sign->setText(TextFormat::GOLD . "---", TextFormat::RED . "EXIT", TextFormat::BOLD . TextFormat::WHITE . "[ " . TextFormat::AQUA . "HG " . TextFormat::AQUA . "Lobby" . TextFormat::WHITE . " ]", TextFormat::WHITE . "---");
             MagicUtil::addParticles($this->plugin->hubLevel, "reddust", $this->plugin->vipSignPos, 8);
         }
         unset($sign);
     }
 }
示例#7
0
 /**
  *
  * Handle Level 3 - Exploding Arrows
  *
  * @param ProjectileHitEvent $event        	
  */
 public function onProjectTileHit(ProjectileHitEvent $event)
 {
     if ($event->getEntity() instanceof Arrow) {
         foreach ($this->plugin->getAvailableLevels() as &$lv) {
             try {
                 if ($lv instanceof GameLevelModel) {
                     if ($lv->type === GameLevelModel::LEVEL_THREE || $lv->type === GameLevelModel::LEVEL_VIP || $lv->type === GameLevelModel::LEVEL_FOUR) {
                         if (empty($lv->currentMap)) {
                             continue;
                         }
                         $pos = new Position($event->getEntity()->getPosition()->x, $event->getEntity()->getPosition()->y, $event->getEntity()->getPosition()->z, $event->getEntity()->getLevel());
                         MagicUtil::makeExplosion($event->getEntity()->getLevel(), $pos);
                         MagicUtil::addParticles($event->getEntity()->getLevel(), "explode", $event->getEntity()->getPosition(), 20);
                         MagicUtil::addParticles($event->getEntity()->getLevel(), "flame", $event->getEntity()->getPosition(), 20);
                         break;
                     }
                 }
             } catch (\Exception $e) {
                 $this->plugin->printError($e);
             }
         }
     }
 }
 /**
  *
  * @param GameLevelModel $lv        	
  */
 public function handleLevelGameOver(GameLevelModel &$lv)
 {
     $start = microtime(true);
     if (!empty($lv->currentMap)) {
         if (count($lv->currentMap->livePlayers) === 0) {
             Server::getInstance()->broadcastMessage(TextFormat::AQUA . "[HG] Game ended without winner!", $lv->currentMap->joinedPlayers);
         }
         if (count($lv->currentMap->livePlayers) > 0) {
             foreach ($lv->currentMap->livePlayers as $gamer) {
                 if ($gamer instanceof GamePlayer) {
                     $lv->level->addSound(new FizzSound($gamer->player), array($gamer->player));
                     $lv->level->addSound(new PopSound($gamer->player), array($gamer->player));
                     if (count($lv->currentMap->livePlayers) === 1) {
                         if (isset($lv->currentMap->playerscores[$gamer->player->getName()])) {
                             $scores = $lv->currentMap->playerscores[$gamer->player->getName()];
                             if ($scores != null) {
                                 $message = TextFormat::WHITE . "Final : ";
                                 $message .= TextFormat::AQUA . "shots " . TextFormat::LIGHT_PURPLE . $scores["shots"] . TextFormat::GRAY . " | ";
                                 $message .= TextFormat::AQUA . "points " . TextFormat::LIGHT_PURPLE . $scores["hits"] . TextFormat::GRAY . " | ";
                                 $message .= "\n";
                                 $winmsg = TextFormat::GOLD . "--------------------------------------\n";
                                 $winmsg .= TextFormat::GOLD . TextFormat::WHITE . " " . TextFormat::BOLD . TextFormat::LIGHT_PURPLE . "BRAVO " . TextFormat::WHITE . "[" . TextFormat::GOLD . $gamer->player->getName() . TextFormat::WHITE . "] Won [" . TextFormat::GOLD . $lv->winnerCoins . TextFormat::WHITE . "] coins \n";
                                 $winmsg .= TextFormat::WHITE . " Level: " . TextFormat::GREEN . $lv->displayName . TextFormat::WHITE . " | Map: " . TextFormat::GREEN . $lv->currentMap->name . "\n";
                                 $winmsg .= TextFormat::GREEN . " " . $message . "\n";
                                 $winmsg .= TextFormat::GOLD . "--------------------------------------\n";
                                 Server::getInstance()->broadcastMessage($winmsg, $lv->currentMap->joinedPlayers);
                                 if (isset($lv->currentMap->playerscores[$gamer->player->getName()])) {
                                     unset($lv->currentMap->playerscores[$gamer->player->getName()]);
                                 }
                                 if (isset($lv->currentMap->votedPlayers[$gamer->player->getName()])) {
                                     unset($lv->currentMap->votedPlayers[$gamer->player->getName()]);
                                 }
                                 $pmap = $lv->currentMap->name;
                                 $recordwins = new HungerGamesRecordWinsTask($this->plugin, $lv, $pmap, $gamer->player->getName(), $scores["hits"]);
                                 $this->plugin->getServer()->getScheduler()->scheduleDelayedTask($recordwins, mt_rand(2, 5));
                                 for ($i = 0; $i < 50; $i++) {
                                     $gamer->player->sendTip(TextFormat::BOLD . TextFormat::GOLD . "[ = V I C T O R Y ! = ]");
                                 }
                             }
                         }
                     } else {
                         if (isset($lv->currentMap->playerscores[$gamer->player->getName()])) {
                             $scores = $lv->currentMap->playerscores[$gamer->player->getName()];
                             if ($scores != null) {
                                 $message = TextFormat::WHITE . "Final : ";
                                 $message .= TextFormat::AQUA . "shots " . TextFormat::LIGHT_PURPLE . $scores["shots"] . TextFormat::GRAY . " | ";
                                 $message .= TextFormat::AQUA . "points " . TextFormat::LIGHT_PURPLE . $scores["hits"] . TextFormat::GRAY . " | ";
                                 $message .= "\n";
                             }
                         }
                         for ($i = 0; $i < 50; $i++) {
                             $gamer->player->sendTip(TextFormat::BOLD . TextFormat::AQUA . "[ * IT'S A DRAW ! * ]");
                         }
                         $drawmsg = TextFormat::RED . "--------------------------------------\n";
                         $drawmsg .= TextFormat::RED . " -more than 1 player remains [" . count($lv->currentMap->livePlayers) . "]\n";
                         $drawmsg .= TextFormat::WHITE . " " . TextFormat::BOLD . TextFormat::YELLOW . "IT's A DRAW " . TextFormat::WHITE . "[" . TextFormat::GOLD . $gamer->player->getName() . TextFormat::WHITE . "]" . TextFormat::WHITE . "- try again?\n";
                         $drawmsg .= TextFormat::GREEN . " " . $message . "\n";
                         $drawmsg .= TextFormat::RED . "--------------------------------------" . "\n";
                         Server::getInstance()->broadcastMessage($drawmsg, $lv->currentMap->joinedPlayers);
                     }
                     $lv->level->addSound(new FizzSound($gamer->player), array($gamer->player));
                     MapPortal::teleportToMap($lv->levelName, $gamer->player);
                     for ($i = 0; $i < 500; $i++) {
                     }
                     MapPortal::safeTeleporting($gamer->player, $lv->currentMap->arenaExitPos);
                     foreach ($lv->currentMap->livePlayers as $gp) {
                         $gamer->showPlayerTo($gp->player);
                     }
                     if (!empty($gamer->player->getInventory())) {
                         HungerGameKit::clearAllInventories($gamer->player);
                         $gamer->player->getInventory()->clearAll();
                         $gamer->player->setHealth(20);
                     }
                     MagicUtil::addEffect($gamer->player, Effect::JUMP, 10);
                     MagicUtil::addParticles($gamer->player->level, "heart", $gamer->player->getPosition(), 30);
                     $players[] = $gamer->player;
                     $lv->level->addSound(new PopSound($gamer->player), $players);
                 }
             }
         }
         try {
             $task = new HungerGamesMapResetTask($this->plugin, $lv->currentMap);
             $this->plugin->getServer()->getScheduler()->scheduleDelayedTask($task, 12);
             foreach ($lv->maps as $mapname) {
                 if (isset($this->plugin->getAvailableArenas()[$mapname])) {
                     $this->plugin->log($lv->name . "> * reset votes for map: " . $mapname);
                     $arena = $this->plugin->getAvailableArenas()[$mapname];
                     $arena->vote = 0;
                     $arena->votedPlayers = [];
                     $this->plugin->getAvailableArenas()[$mapname] = $arena;
                     break;
                 }
             }
             $lv->joinDownCounter = 10;
         } catch (Exception $e) {
             $this->plugin->printError($e);
         }
     }
     $this->plugin->log("#8 " . $lv->name . " handleLevelGameOver took " . (microtime(true) - $start) . " ms");
 }
示例#9
0
文件: MagicUtil.php 项目: robozeri/SG
 public static function addLevelFireworks(Level $level, Position $pos1, $count = 3)
 {
     if (!is_null($level)) {
         $pos = new Position($pos1->x, $pos1->y + 3, $pos1->z, $level);
         $pos2 = new Position($pos1->x, $pos1->y + 1, $pos1->z, $level);
         // $exp = new Explosion ( $pos, 1 );
         // $exp->explodeB ();
         MagicUtil::addParticles($level, "explode", $pos2, 100);
         // for($i = 0; $i < $count; $i ++) {
         // $pos = new Position ( $pos1->x + rand ( - 1, 2 ), $pos1->y + rand ( 0, 3 ), $pos1->z + rand ( - 1, 2 ), $level );
         // $level->addParticle ( new DustParticle ( $pos, rand ( 1, 255 ), rand ( 1, 255 ), rand ( 1, 255 ) ) );
         // $level->addParticle ( new DustParticle ( $pos, rand ( 1, 255 ), rand ( 1, 255 ), rand ( 1, 255 ) ) );
         // $level->addParticle ( new DustParticle ( $pos, rand ( 1, 255 ), rand ( 1, 255 ), rand ( 1, 255 ) ) );
         // $level->addParticle ( new DustParticle ( $pos, rand ( 1, 255 ), rand ( 1, 255 ), rand ( 1, 255 ) ) );
         // $level->addParticle ( new DustParticle ( $pos, rand ( 1, 255 ), rand ( 1, 255 ), rand ( 1, 255 ) ) );
         // $level->addParticle ( new DustParticle ( $pos, rand ( 1, 255 ), rand ( 1, 255 ), rand ( 1, 255 ) ) );
         // }
         MagicUtil::addParticles($level, "lava", $pos1, 100);
     }
 }
示例#10
0
 public function handlePlayerTapOnStatueBlock(Player $player, $block)
 {
     $posKey = round($block->x) . "." . round($block->y) . "." . round($block->z);
     if (isset($this->npcsPositions[$posKey])) {
         $statue = $this->npcsPositions[$posKey];
         if ($statue instanceof StatueModel) {
             if ($statue->category === StatueModel::STATUS_CATEGORY_KIT) {
                 $this->processKitPurchaseTranssaction($player, $statue);
             } else {
                 MagicUtil::addParticles($player->getLevel(), "portal", $player->getPosition(), 100);
                 $player->sendPopup(TextFormat::BOLD . TextFormat::GOLD . $statue->message);
                 $player->teleport($statue->destinationPos);
                 $player->sendMessage(TextFormat::GRAY . "[HG]" . $statue->message);
             }
         }
     }
 }