Exemplo n.º 1
0
        /**
	     * Registers a 'coordiante' event.
	     * @param event
	     */
	    public static void registerCoordinateEvent(CoordinateEvent coordinateEvent) {
            Event newCoordinateEvent = new Event(0);
            newCoordinateEvent.setAction(() => {
				bool standingStill = coordinateEvent.getPlayer().getSprites().getPrimarySprite() == -1 && coordinateEvent.getPlayer().getSprites().getSecondarySprite() == -1;
				if(coordinateEvent.getPlayer().getDistanceEvent() == null || !coordinateEvent.getPlayer().getDistanceEvent().Equals(coordinateEvent)) {
					newCoordinateEvent.stop();
					return;
				}
				if (standingStill) {
					if((coordinateEvent.getPlayer().getLocation().Equals(coordinateEvent.getTargetLocation()) && coordinateEvent.getPlayer().getLocation().Equals(coordinateEvent.getOldLocation())) || coordinateEvent.getFailedAttempts() >= 15) {
						if(newCoordinateEvent.getTick() == 0) {
							coordinateEvent.run();
							newCoordinateEvent.stop();
							coordinateEvent.setPlayerNull();
						} else {
							if(!coordinateEvent.hasReached()) {
								coordinateEvent.setReached(true);
							} else {
								coordinateEvent.run();
								newCoordinateEvent.stop();
								coordinateEvent.setPlayerNull();
							}
						}
					}
				} else {
					if(!coordinateEvent.getPlayer().getLocation().Equals(coordinateEvent.getOldLocation())) {
						coordinateEvent.setOldLocation(coordinateEvent.getPlayer().getLocation());
					} else {
						coordinateEvent.incrementFailedAttempts();
					}
				}
				newCoordinateEvent.setTick(200);
		    });
            registerEvent(newCoordinateEvent);
	    }