Package it.timehero.actors

Examples of it.timehero.actors.Actor


   * @param e
   * @return null se non l'ha trovata
   */
  public Actor findActor(Entity e){
    for (int i = 0; i < actors.size(); i++) {
      Actor temp = actors.get(i);
      if (temp.getEntity().equals(e)){
        return temp;
      }
    }
    return null;
  }
View Full Code Here


    /**
   * @return the agent by name
   */
    public Actor getActorAgentByID(String id) {
      for (int i = 0; i < actors.size(); i++) {
      Actor actor = actors.get(i);
      if (actor.getID().equalsIgnoreCase(id)){
        return actor;
      }
    }
      return null;
    }
View Full Code Here

   * @return l'Actor corrispondente al giocatore identificato dall'ID GIGI,
   *         null se non lo trova
   */
    public Actor getPlayerActor(){
      for (int i = 0; i < actors.size(); i++) {
      Actor actor = actors.get(i);
      if (actor.getID().equalsIgnoreCase(Helper.GIGI)){
        return actor;
      }
    }
      return null;
    }
View Full Code Here

   *
   * @param temp
   * @return true se � rimosso, false se c'� errore
   */
  public boolean removeEntity(Entity temp) {
    Actor a = findActor(temp);
    if (a==null){
      return false;
    } else {
      return actors.remove(a);
    }
View Full Code Here

    // mi � arrivata notifica del movimento voluto dall'utente
    if (o.getClass() == UserInputController.class && arg.getClass() == MovementNotify.class){
      MovementNotify mn = (MovementNotify)arg;
      // Log.info("notifica da UserInputController: "+mn.toString());

      Actor gigiActor = getPlayerActor();
      gigiActor.setStato(Helper.MOVIMENTO);
      Entity gigi = gigiActor.getEntity();
     
      boolean keyUp= mn.movement.equalsIgnoreCase(Helper.UP_DIR);
      boolean keyDown= mn.movement.equalsIgnoreCase(Helper.DOWN_DIR);
      boolean keyLeft= mn.movement.equalsIgnoreCase(Helper.LEFT_DIR);
      boolean keyRight= mn.movement.equalsIgnoreCase(Helper.RIGHT_DIR);
     
      int delta = mn.delta;
     
      // associazione tasto/notifica a gigi del movimento voluto
      if (keyRight) {
        if (tryToMoveEntity(gigi,Helper.MOVE_SPEED,0)){
          gigi.addHorizontalMovement(Helper.MOVE_SPEED);
          gigi.getPlayerWalkRight().update(delta);
          gigi.setMovementRight();
        } else {
          gigi.addHorizontalMovement(-Helper.GIGI_CONTROMOVIMENTO);
        }
      }
      if (keyLeft) {
        if (tryToMoveEntity(gigi,-Helper.MOVE_SPEED*1,0) ){
          gigi.addHorizontalMovement(- Helper.MOVE_SPEED);
          gigi.getPlayerWalkLeft().update(delta);
          gigi.setMovementLeft();
        } else {
          gigi.addHorizontalMovement(Helper.GIGI_CONTROMOVIMENTO);
        }
      }
      if (keyUp) {
        if (tryToMoveEntity(gigi,0,-Helper.MOVE_SPEED*1)){
          gigi.addVerticalMovement(- Helper.MOVE_SPEED);
          gigi.getPlayerWalkUp().update(delta);
          gigi.setMovementUp();
        } else {
          gigi.addVerticalMovement(Helper.GIGI_CONTROMOVIMENTO);
        }
      }
      if (keyDown) {
        if (tryToMoveEntity(gigi,0,Helper.MOVE_SPEED*1)){
          gigi.addVerticalMovement(Helper.MOVE_SPEED);
          gigi.getPlayerWalkDown().update(delta);
          gigi.setMovementDown();
        } else {
          gigi.addVerticalMovement(-Helper.GIGI_CONTROMOVIMENTO);
        }
      }
     
      // devo informare tutti gli altri attori di questo movimento!
      for (int i = 0; i < actors.size(); i++) {
        Actor actor = actors.get(i);
        // evito di dirlo a gigi :P
        if (actor.getAgent()!=null){
          actor.getAgent().setPlayerMove(gigi.lastDirection);         
        }
      }
    }
    // mi � arrivata notifica di movimento da un agente
    if (o.getClass()==AgentInputController.class  && arg.getClass() == MovementNotify.class){
      MovementNotify mn = (MovementNotify)arg;
      // Log.info("notifica da UserInputController: "+mn.toString());
     
      Actor actorActor = getActorAgentByID(mn.entityID);
      actorActor.setStato(Helper.MOVIMENTO);
      Entity actor = actorActor.getEntity();
     
      boolean keyUp= mn.movement.equalsIgnoreCase(Helper.UP_DIR);
      boolean keyDown= mn.movement.equalsIgnoreCase(Helper.DOWN_DIR);
      boolean keyLeft= mn.movement.equalsIgnoreCase(Helper.LEFT_DIR);
      boolean keyRight= mn.movement.equalsIgnoreCase(Helper.RIGHT_DIR);
     
      int delta = mn.delta;
     
      // associazione tasto/notifica all'agente del movimento voluto
      if (keyRight) {
        if (tryToMoveEntity(actor,Helper.MOVE_SPEED*3,0)){
          actor.addHorizontalMovement(Helper.MOVE_SPEED*3);
          actor.getPlayerWalkRight().update(delta);
          actor.setMovementRight();
        }
      }
      if (keyLeft) {
        if (tryToMoveEntity(actor,-Helper.MOVE_SPEED*3,0) ){
          actor.addHorizontalMovement(- Helper.MOVE_SPEED*3);
          actor.getPlayerWalkLeft().update(delta);
          actor.setMovementLeft();
        }
      }
      if (keyUp) {
        if (tryToMoveEntity(actor,0,-Helper.MOVE_SPEED*3)){
          actor.addVerticalMovement(- Helper.MOVE_SPEED*3);
          actor.getPlayerWalkUp().update(delta);
          actor.setMovementUp();
        }
      }
      if (keyDown) {
        if (tryToMoveEntity(actor,0,Helper.MOVE_SPEED*3)){
          actor.addVerticalMovement(Helper.MOVE_SPEED*3);
          actor.getPlayerWalkDown().update(delta);
          actor.setMovementDown();
        }
      }
     
      try {
        actorActor.getAgent().getTS().getAg().addBel(Literal.parseLiteral("own_position(" + actor.getX() + "," + actor.getY() +")"));
      } catch (RevisionFailedException e) {
        e.printStackTrace();
      }   
    }
    // mi � arrivata notifica dell'attacco da parte dell'utente
    if (o.getClass() == UserInputController.class  && arg.getClass() == AttackNotify.class){
      AttackNotify an = (AttackNotify)arg;
      // Log.info("notifica da UserInputController: "+an.toString());
     
      Actor gigi = getActorAgentByID(an.entityID);
      gigi.setStato(Helper.ATTACCO);
      Entity gigiEntity= gigi.getEntity();

      if (gigiEntity.getLastDirection()== null){
        return;
      }
      boolean keyUp= gigiEntity.getLastDirection().equalsIgnoreCase(Helper.UP_DIR);
View Full Code Here

  private void collisione(Entity me, float x, float y) {

    Entity him = entityCollision(me,x,y);
    if (him == null) return;
     
    Actor meActor = findActor(me);
    Actor nemico = findActor(him);
    if (meActor==null || nemico==null) return;

    // l'attore non pu� avere conflitti con se stesso
    if (!meActor.getID().equalsIgnoreCase(nemico.getID())){
      GusEngine.resolveConflict(meActor, nemico,Helper.CONFLITTO_SPADA);     
    }
     
  }
View Full Code Here

  /**
   * Rimuovo dagli attori registrati tutti coloro che hanno 0 o meno pf
   */
  public void removeDeadActors() {
    for (int i = 0; i < this.getActorSize(); i++) {
      Actor actor = this.getActor(i);
      if (actor.getScheda().getPf().getValore() <= 0) {
        removeActor(actor);
      }
     
    }   
  }
View Full Code Here

   * @param e
   * @return null se non l'ha trovata
   */
  public Actor findActor(Entity e){
    for (int i = 0; i < actors.size(); i++) {
      Actor temp = actors.get(i);
      if (temp.getEntity().equals(e)){
        return temp;
      }
    }
    return null;
  }
View Full Code Here

     * Ritorna un attore
   * @return the agent by name
   */
    public Actor getActorAgentByID(String id) {
      for (int i = 0; i < actors.size(); i++) {
      Actor actor = actors.get(i);
      if (actor.getID().equalsIgnoreCase(id)){
        return actor;
      }
    }
      return null;
    }
View Full Code Here

   * @return l'Actor corrispondente al giocatore identificato dall'ID GIGI,
   *         null se non lo trova
   */
    public Actor getPlayerActor(){
      for (int i = 0; i < actors.size(); i++) {
      Actor actor = actors.get(i);
      if (actor.getID().equalsIgnoreCase(Helper.GIGI)){
        return actor;
      }
    }
      return null;
    }
View Full Code Here

TOP

Related Classes of it.timehero.actors.Actor

Copyright © 2018 www.massapicom. 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.