Beispiel #1
0
 /**
  * called on incoming arrow
  *
  * @param Arrow $arrow
  */
 public function registerShot(Arrow $arrow)
 {
     // trigger initialization of leg-gears so they can listen for events
     $this->getGameGears()->getCurrentLegGears();
     $event = new ArrowEvent();
     $event->setArrow($arrow);
     $this->eventDispatcher->dispatch(EngineEvents::ARROW_INCOMING, $event);
 }
Beispiel #2
0
 /**
  * @param ArrowEvent               $arrowIncomingEvent
  * @param string                   $name
  * @param EventDispatcherInterface $dispatcher
  */
 public function onIncomingArrow(ArrowEvent $arrowIncomingEvent, $name, EventDispatcherInterface $dispatcher)
 {
     //        $this->log('onIncomingArrow');
     $incomingArrow = $arrowIncomingEvent->getArrow();
     $arrow = $this->handleArrow(clone $incomingArrow);
     if (null === $arrow) {
         throw new \RuntimeException('LegGears::handleArrow(...) must return an arrow');
     }
     if (null === $arrow->getNumber()) {
         throw new \RuntimeException('handleArrow must set arrow-number!');
     }
     $arrowRegisteredEvent = new ArrowEvent();
     $arrowRegisteredEvent->setArrow($arrow);
     $dispatcher->dispatch(EngineEvents::ARROW_REGISTERED, $arrowRegisteredEvent);
     if (null !== $this->turnCompleted) {
         $turnCompletedEvent = new TurnEvent();
         $turnCompletedEvent->setTurn($this->turnCompleted);
         $dispatcher->dispatch(EngineEvents::TURN_COMPLETED, $turnCompletedEvent);
     }
     if (null !== $this->legCompleted) {
         $legCompletedEvent = new LegEvent();
         $legCompletedEvent->setLeg($this->legCompleted);
         $dispatcher->dispatch(EngineEvents::LEG_COMPLETED, $legCompletedEvent);
     }
 }