Package cross

Source Code of cross.EntryPoint

package cross;

import _main.Game;
import misc.carType;
import game_timer.GameTimer;
import route.Route;
import vehicles.Vehicle;

/**
* Az aut�k kiindul�si pontja; egy olyan keresztez�d�s, melyb�l csak kifel� �gaznak utak.
*
*/

public class EntryPoint extends Cross {
 
  public EntryPoint(){
    GameTimer.getInstance().registObserver(this);
  }
 
  /**
   * az id�l�ptet� f�ggv�ny; megh�vja a megfelel� f�ggv�nyeket adott id�k�z�nk�nt
   */
  public void onTick() {
    if(vehicleInCross != null){
      vehicleOut();
    }
  }
 
  /**
   *
   * az entrypointban l�v� aut�t kil�pteti
   */
  @Override
  public void vehicleOut() {
    Route selectedOutRoute = vehicleInCross.selectRoute(outroutes);
    selectedOutRoute.addVehicle(vehicleInCross);
    vehicleInCross = null;
  }
 
  @Override
  public void addInRoutes(Route r) {
    throw new UnsupportedOperationException("Entrypointnal nincsenek inrouteok, hanem az outroute rakja ra az autokat!");
  }
 
  /**
   * Az outroutes t�mbh�z hozz�ad egy bemen� utat
   * @param r kimen� �t hozz�ad�sa
   */
  public void addOutRoutes(Route r) {//TODO: addOutRoute es nem Routes
    outroutes.add(r);
  }
 
 
  /**
   * Aut�t tesz az entrypointba
   * @param v a entrypointba teend� aut�
   */
  public void addVehicleToCross(Vehicle v) {
    //ha a robbery probal meg belepni, akkor kampec: game over!
    if(v.getCarType() == carType.Robbery){
      Game.getInstance().finishGame();
    }
   
    //maskulonben csak hozzaadjuk
    if(v != null)
      vehicleInCross = v;
  }

}
TOP

Related Classes of cross.EntryPoint

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.