Package cross

Source Code of cross.HidingPlace

package cross;

import game_timer.GameTimer;

import java.util.ArrayList;
import java.util.Map;

import logger.Logger;
import misc.carType;
import route.Route;
import vehicles.Vehicle;
import _main.Game;
/**
* Rejtekhely oszt�ly. Egy keresztez�d�s, ahova, ha behajt a bankrabl�, akkor a j�t�kos megnyerte a j�t�kot.
*
*/
public class HidingPlace extends Cross {
 
  private Map m;
  private ArrayList<Route> inroutes = new ArrayList<Route>();
  private ArrayList<Route> outroutes = new ArrayList<Route>();
  private ArrayList<Vehicle> vehicleInCross = new ArrayList<Vehicle>();
  private ArrayList<Vehicle> vehiclesAtCross = new ArrayList<Vehicle>();
  Vehicle v1;
 
  /**
   *
   * az id�l�ptet� f�ggv�ny; megh�vja a megfelel� f�ggv�nyeket adott id�k�z�nk�nt
   */
 
  public void onTick() {
    Logger.get().addOrdinaryMessage("[HidingPlace.OnTick]: called!");
    Logger.get().addOrdinaryMessage("[HidingPlace.Constructor]: registering to observer...");
    Logger.get().addMethodCall("\t", "GameTimer", "registObserver");
    GameTimer.getInstance().registObserver(this);
    Logger.get().addMethodReturn("\t", "GameTimer", "registObserver");
  }
 
  /**
   * friss�ti a vehiclesAtCross-t a rejtekhely bemen� �tjain tal�lhat� aut�kr�l,
   * �s n�zi, hogy kimen� �ton van-e szembe j�v� �llapotban bankrabl�.
   */
 
  public void updateVehiclesAtCross() {

    Logger.get().addMethodCall("", "HidingPlace", "updateVehiclesAtCross");
    for(Route r : inroutes){//get dummy cars from the routes
      vehiclesAtCross.add(r.test_getACar());
    }
    stepIntoCross();
   
    if (v1.getCarType()==carType.Robbery)
    {
      Game.getInstance().youWin();
    }
    else
    {
      vehicleOut();
      Logger.get().addMethodReturn("", "HidingPlace", "updateVehiclesAtCross");
    }
  }
 
  /**
   *
   * egy �tr�l bel�ptet egy j�rm�t a rejtekhelybe
   */
 
  public void stepIntoCross() {
    Logger.get().addMethodCall("", "HidingPlace", "stepIntoCross");
    Logger.get().addOrdinaryMessage("[HidingPlace.stepIntoCross]: A [vehiclesAtCross] tombbol a kovetkezo auto kivalasztasa, majd a bemeno uttol valo elkerese!");
    v1 = inroutes.get(0).getAndRemoveLastCar(); // v1 aut� elk�r�se
    vehicleInCross.add(v1);//get the car and add it to the cross   
    Logger.get().addMethodReturn("", "HidingPlace", "stepIntoCross");
  }
 
  /**
   *
   * a rejtekhelyb�l l�v� aut�t kil�pteti
   */
 
  public void vehicleOut() {
    Logger.get().addMethodCall("", "HidingPlace", "vehicleOut");
    Route selectedOutRoute = vehicleInCross.get(0).selectRoute(outroutes);
    selectedOutRoute.addVehicle(vehicleInCross.get(0));
    Logger.get().addMethodReturn("", "HidingPlace", "vehicleOut");
  }
 
  /**
   * az inroutes t�mbh�z hozz�ad egy bemen� utat
   * @param r bemen� �t hozz�ad�sa
   */
 
  public void addInRoutes(Route r) {//TODO: addInRoute es nem Routes
    Logger.get().addOrdinaryMessage("[HidingPlace.addInRoutes]: Called! and [inRoute added!]");
    inroutes.add(r);
  }
 
  /**
   * 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
    Logger.get().addOrdinaryMessage("[HidingPlace.addOutRoutes]: Called! and [outRoute added!]");
    outroutes.add(r);
  }
 
  /**
   * Aut�t tesz a rejtekhelybe
   * @param v a rejtekhelybe teend� aut�
   */
 
  public void addVehicleToCross(Vehicle v) {
    vehicleInCross.add(v);
  }
 
 

}
TOP

Related Classes of cross.HidingPlace

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.