Beispiel #1
0
  public void moveForward(int spaces) {
    // change y +
    if (me.direction.equals("N")) {
      int i = 1;
      while (!map.isBlocked(me.x, me.y + 1) && i <= spaces) {
        me.y += 1;
        i++;
      }
      // went too far
      if (i < spaces) {
        explode();
      }
    }

    // change y -
    else if (me.direction.equals("S")) {
      int i = 1;
      while (!map.isBlocked(me.x, me.y - 1) && i <= spaces) {
        me.y -= 1;
        i++;
      }

      // went too far
      if (i < spaces) {
        explode();
      }
    }

    // change x +
    else if (me.direction.equals("E")) {
      int i = 1;
      while (!map.isBlocked(me.x + 1, me.y) && i <= spaces) {
        me.x += 1;
        i++;
      }

      // went too far
      if (i < spaces) {
        explode();
      }
    }

    // change x -
    else if (me.direction.equals("W")) {
      int i = 1;

      while (!map.isBlocked(me.x - 1, me.y) && i <= spaces) {
        me.x -= 1;
        i++;
      }

      // went too far
      if (i < spaces) {
        explode();
      }
    } else {
      // error - do nothing
    }
  }
 public synchronized void avatar(int id, int frame, List<Indir<Resource>> layers) {
   Gob g = getgob(id, frame);
   if (g == null) return;
   Avatar ava = g.getattr(Avatar.class);
   if (ava == null) {
     ava = new Avatar(g);
     g.setattr(ava);
   }
   ava.setlayers(layers);
 }
Beispiel #3
0
 public void printCourses(Avatar a) {
   List<Course> fc = a.getFinishedCourses();
   List<Course> uc = a.getUnfinishedCourses();
   System.out.println("Finished courses: ");
   for (int i = 0; i < fc.size(); i++) {
     System.out.println(fc.get(i));
   }
   System.out.println("Unfinished courses: ");
   for (int j = 0; j < uc.size(); j++) {
     System.out.println(uc.get(j));
   }
 }
 /**
  * Move the map origin to a new location
  *
  * @param location
  */
 public void setLocation(final Location location) {
   // origin.setSC(location.scX, location.scY, 0);
   origin.set(location);
   ani.stop();
   final Avatar avatar = World.getAvatar();
   if (avatar != null) {
     avatar.animationFinished(false);
   }
   elevation = World.getMap().getElevationAt(origin);
   dX = 0;
   dY = 0;
   dL = -elevation;
   Camera.getInstance().markEverythingDirty();
 }
Beispiel #5
0
 public void phase4() {
   System.out.println("Phase 4");
   lblStatus1.setText("Main Phase");
   lblStatus2.setText("Assigning AT...");
   lblStatus3.setText("");
   for (int i = iChar; i < listChar.length; iChar = ++i) {
     System.out.println(listChar[i]);
     if (listChar[i].isATReady()) {
       oActiveAvatar = listChar[i];
       oActiveAvatar.giveAT();
       lblStatus3.setText(oActiveAvatar.getName() + "'s AT");
       if (oParty.contains(oActiveAvatar)) stateAT();
       else stateWaiting();
       return;
     }
   }
   phase1();
 }
Beispiel #6
0
 @Override
 public void update(final float tpf) {
   super.update(tpf);
   final Vector3f modelForwardDir = spatial.getWorldRotation().mult(Vector3f.UNIT_Z);
   final Vector3f modelLeftDir = spatial.getWorldRotation().mult(Vector3f.UNIT_X);
   walkDirection.set(0, 0, 0);
   if (forward) {
     walkDirection.addLocal(modelForwardDir.mult(avatar.forwardSpeed(running)));
   } else if (backward) {
     walkDirection.addLocal(modelForwardDir.negate().mult(avatar.backwardSpeed(running)));
   }
   if (leftStrafe) {
     walkDirection.addLocal(modelLeftDir.mult(avatar.sideSpeed(running)));
   } else if (rightStrafe) {
     walkDirection.addLocal(modelLeftDir.negate().mult(avatar.sideSpeed(running)));
   }
   this.avatar.setLocation(convertVectorToArray(spatial.getLocalTranslation()));
 }
Beispiel #7
0
 public void turnCClock() {
   List<String> dirArr = Arrays.asList("N", "W", "S", "E");
   String current = me.direction;
   int i = dirArr.indexOf(current);
   i++;
   if (i == 4) {
     i = 0;
   }
   me.direction = dirArr.get(i);
 }
 @Override
 public String toString() {
   return "Person [id="
       + id
       + ", firstName="
       + firstName
       + ", lastName="
       + lastName
       + ", avatar="
       + avatar.getId()
       + "]";
 }
Beispiel #9
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((articleVersions == null) ? 0 : articleVersions.hashCode());
   result = prime * result + ((avatar == null) ? 0 : avatar.hashCode());
   result = prime * result + ((creationdate == null) ? 0 : creationdate.hashCode());
   result = prime * result + ((email == null) ? 0 : email.hashCode());
   result = prime * result + (googleAcount ? 1231 : 1237);
   result = prime * result + ((idUser == null) ? 0 : idUser.hashCode());
   result = prime * result + ((lastLoginDate == null) ? 0 : lastLoginDate.hashCode());
   result = prime * result + ((loginName == null) ? 0 : loginName.hashCode());
   result = prime * result + ((name == null) ? 0 : name.hashCode());
   result = prime * result + ((password == null) ? 0 : password.hashCode());
   result = prime * result + ((registrationHash == null) ? 0 : registrationHash.hashCode());
   result = prime * result + ((role == null) ? 0 : role.hashCode());
   result = prime * result + state;
   result = prime * result + ((surname == null) ? 0 : surname.hashCode());
   return result;
 }
  @Override
  public void create() {

    super.create();

    Music.INSTANCE.play(Assets.HAPPY, true);
    Music.INSTANCE.volume(ShatteredPixelDungeon.musicVol() / 10f);

    uiCamera.visible = false;

    int w = Camera.main.width;
    int h = Camera.main.height;

    Archs archs = new Archs();
    archs.reversed = true;
    archs.setSize(w, h);
    add(archs);

    float vx = align((w - SKY_WIDTH) / 2);
    float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2);

    Point s = Camera.main.cameraToScreen(vx, vy);
    viewport = new Camera(s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom);
    Camera.add(viewport);

    Group window = new Group();
    window.camera = viewport;
    add(window);

    boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7;

    Sky sky = new Sky(dayTime);
    sky.scale.set(SKY_WIDTH, SKY_HEIGHT);
    window.add(sky);

    if (!dayTime) {
      for (int i = 0; i < NSTARS; i++) {
        float size = Random.Float();
        ColorBlock star = new ColorBlock(size, size, 0xFFFFFFFF);
        star.x = Random.Float(SKY_WIDTH) - size / 2;
        star.y = Random.Float(SKY_HEIGHT) - size / 2;
        star.am = size * (1 - star.y / SKY_HEIGHT);
        window.add(star);
      }
    }

    float range = SKY_HEIGHT * 2 / 3;
    for (int i = 0; i < NCLOUDS; i++) {
      Cloud cloud =
          new Cloud((NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float(range / NCLOUDS), dayTime);
      window.add(cloud);
    }

    int nPatches = (int) (sky.width() / GrassPatch.WIDTH + 1);

    for (int i = 0; i < nPatches * 4; i++) {
      GrassPatch patch =
          new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime);
      patch.brightness(dayTime ? 0.7f : 0.4f);
      window.add(patch);
    }

    Avatar a = new Avatar(Dungeon.hero.heroClass);
    // Removing semitransparent contour
    a.am = 2;
    a.aa = -1;
    a.x = PixelScene.align((SKY_WIDTH - a.width) / 2);
    a.y = SKY_HEIGHT - a.height;
    window.add(a);

    final Pet pet = new Pet();
    pet.rm = pet.gm = pet.bm = 1.2f;
    pet.x = SKY_WIDTH / 2 + 2;
    pet.y = SKY_HEIGHT - pet.height;
    window.add(pet);

    window.add(
        new TouchArea(sky) {
          protected void onClick(Touch touch) {
            pet.jump();
          };
        });

    for (int i = 0; i < nPatches; i++) {
      GrassPatch patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime);
      patch.brightness(dayTime ? 1.0f : 0.8f);
      window.add(patch);
    }

    Image frame = new Image(Assets.SURFACE);

    frame.frame(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
    frame.x = vx - FRAME_MARGIN_X;
    frame.y = vy - FRAME_MARGIN_TOP;
    add(frame);

    if (dayTime) {
      a.brightness(1.2f);
      pet.brightness(1.2f);
    } else {
      frame.hardlight(0xDDEEFF);
    }

    RedButton gameOver =
        new RedButton("Game Over") {
          protected void onClick() {
            Game.switchScene(TitleScene.class);
          }
        };
    gameOver.setSize(SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT);
    gameOver.setPos(frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4);
    add(gameOver);

    Badges.validateHappyEnd();

    fadeIn();
  }
Beispiel #11
0
 public AvatarControl(final Avatar avatar) {
   super(avatar.getRadius(), avatar.getHeight(), avatar.getMass());
   this.head = new Node(avatar.getName() + "-head");
   this.head.setLocalTranslation(0, avatar.getHeight(), 0);
   this.avatar = avatar;
 }
 /**
  * Fix avatar's position in the middle of the screen and Z-Order
  *
  * @param av
  */
 public void glueAvatarToOrigin(final Avatar av) {
   av.setScreenPos(
       origin.getDcX() - dX, (origin.getDcY() - dY) + dL, origin.getDcZ(), Layers.CHARS);
 }
Beispiel #13
0
  public static void main(String args[]) {
    Main m = new Main();
    World w = new World();
    Avatar a = w.getAvatar();
    Room currentRoom = w.getFirst();
    while (true) {
      // kolla sphinxen - går ur loopen
      // printa rummet
      //	    System.out.print("\033[2J\033[;H");
      System.out.println("=============== PollaxMUD ================");
      System.out.println(currentRoom);
      // kommandon - inläsning från användaren:
      String input =
          m.readInput(
              "go north",
              "go south",
              "go east",
              "go west",
              "inventory",
              "pick up",
              "drop",
              "check courses",
              "talk",
              "trade",
              "graduate",
              "enroll",
              "unlock south",
              "unlock west",
              "unlock east",
              "unlock north");
      // System.out.println(input);
      // go väderstreck - uppdatera currentRoom
      if (input.equals("go north")) {
        if (currentRoom.getRoomNorth() != null) {
          if (currentRoom.getRoomNorth().getDoorNorth() != false) {
            // kolla nycklar o shit
            currentRoom = currentRoom.getRoomNorth();
          } else {
            System.out.println("The door is locked");
          }
          // kolla nycklar o shit
          currentRoom = currentRoom.getRoomNorth();
        } else {
          System.out.println("There is no room in the north direction");
        }
      } else if (input.equals("go south")) {
        if (currentRoom.getRoomSouth() != null) {
          if (currentRoom.getRoomSouth().getDoorSouth() != false) {
            // kolla nycklar o shit
            currentRoom = currentRoom.getRoomSouth();
          } else {
            System.out.println("The door is locked");
          }
        } else {
          System.out.println("There is no room in the south direction");
        }
      } else if (input.equals("go east")) {
        if (currentRoom.getRoomEast() != null) {
          if (currentRoom.getRoomEast().getDoorEast() != false) {
            // kolla nycklar o shit
            currentRoom = currentRoom.getRoomEast();
          } else {
            System.out.println("The door is locked");
          }
        } else {
          System.out.println("There is no room in the east direction");
        }
      } else if (input.equals("go west")) {
        if (currentRoom.getRoomWest() != null) {
          if (currentRoom.getRoomWest().getDoorWest() != false) {
            // kolla nycklar o shit
            currentRoom = currentRoom.getRoomWest();
          } else {
            System.out.println("The door is locked");
          }
        } else {
          System.out.println("There is no room in the west direction");
        }
      } else if (input.equals("unlock south")) {
        Room room = currentRoom.getRoomSouth();
        if (room != null) {
          if (room.getDoorSouth() == false) {
            if (a.getBackpack().getTotalObjects() != 0) {
              Item key = a.getBackpack().getFirstObjectList();
              a.getBackpack().drop(key);
              room.setDoorSouth(true);
            } else {
              System.out.println("You don´t have any keys to use");
            }

          } else {
            System.out.println("The door is already open");
          }
        } else {
          System.out.println("There is no room in the south direction");
        }

      } else if (input.equals("unlock east")) {
        Room room = currentRoom.getRoomEast();
        if (room != null) {
          if (room.getDoorEast() == false) {
            if (a.getBackpack().getTotalObjects() != 0) {
              Item key = a.getBackpack().getFirstObjectList();
              a.getBackpack().drop(key);
              room.setDoorEast(true);
            } else {
              System.out.println("You don´t have any keys to use");
            }

          } else {
            System.out.println("The door is already open");
          }
        } else {
          System.out.println("There is no room in the east direction");
        }

      } else if (input.equals("unlock west")) {
        Room room = currentRoom.getRoomWest();
        if (room != null) {
          if (room.getDoorWest() == false) {
            if (a.getBackpack().getTotalObjects() != 0) {
              Item key = a.getBackpack().getFirstObjectList();
              a.getBackpack().drop(key);
              room.setDoorWest(true);
            } else {
              System.out.println("You don´t have any keys to use");
            }

          } else {
            System.out.println("The door is already open");
          }
        } else {
          System.out.println("There is no room in the east direction");
        }

      } else if (input.equals("unlock north")) {
        Room room = currentRoom.getRoomNorth();
        if (room != null) {
          if (room.getDoorNorth() == false) {
            if (a.getBackpack().getTotalObjects() != 0) {
              Item key = a.getBackpack().getFirstObjectList();
              a.getBackpack().drop(key);
              room.setDoorNorth(true);
            } else {
              System.out.println("You don´t have any keys to use");
            }

          } else {
            System.out.println("The door is already open");
          }
        } else {
          System.out.println("There is no room in the east direction");
        }

      }

      // inventory
      else if (input.equals("inventory")) {
        Backpack b = a.getBackpack();
        b.inventory();
      }
      // kolla kurser
      else if (input.equals("check courses")) {
        m.printCourses(a);
      } else if (input.equals("graduate")) {
        System.out.println("not implemented yet");
        // kolla om sfinxen finns i rummet
      } else if (input.substring(0, 4).equals("talk")) {
        //		System.out.println("not implemented yet");
        String talkPerson = input.substring(5, input.length());
        System.out.print(talkPerson);
        if (talkPerson.equals("teacher")) {
          if (currentRoom.getTeacher() != null) {
            Teacher t = currentRoom.getTeacher();
            t.talk(a);
          }
        } else if (currentRoom.checkStudentName(talkPerson)) {
          Student s = currentRoom.getStudent();
          s.talk(a);
        } else {
          System.out.println("No such person in the room");
        }
      }
      // plocka upp saker
      else if (input.equals("pick up")) {
        ArrayList<Item> Items = currentRoom.getItemsinRoom();
        if (Items.size() != 0) {
          Item key = Items.get(0);
          a.getBackpack().pack(key);
          Items.remove(key);
        } else {
          System.out.println("Det finns inga nycklar i det här rummet");
        }

      } else if (input.length() >= 6) {
        if (input.substring(0, 6).equals("enroll")) {
          System.out.println("not implemented yet");
        }
      }
      // dropa saker
      else if (input.substring(0, 4).equals("drop")) {
        System.out.println("not implemented yet");
      } else if (input.substring(0, 5).equals("trade")) {
        System.out.println("not implemented yet");
      } else {
        System.out.println("OH NOES!!!");
      }
    }
  }
 /**
  * Fix avatar's position in the middle of the screen and Z-Order
  *
  * @param av
  */
 public void glueAvatarToOrigin(@Nonnull Avatar av) {
   av.setScreenPos(origin.getDcX() - dX, (origin.getDcY() - dY) + dL, origin.getDcZ());
 }
Beispiel #15
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   User other = (User) obj;
   if (articleVersions == null) {
     if (other.articleVersions != null) {
       return false;
     }
   } else if (!articleVersions.equals(other.articleVersions)) {
     return false;
   }
   if (avatar == null) {
     if (other.avatar != null) {
       return false;
     }
   } else if (!avatar.equals(other.avatar)) {
     return false;
   }
   if (creationdate == null) {
     if (other.creationdate != null) {
       return false;
     }
   } else if (!creationdate.equals(other.creationdate)) {
     return false;
   }
   if (email == null) {
     if (other.email != null) {
       return false;
     }
   } else if (!email.equals(other.email)) {
     return false;
   }
   if (googleAcount != other.googleAcount) {
     return false;
   }
   if (idUser == null) {
     if (other.idUser != null) {
       return false;
     }
   } else if (!idUser.equals(other.idUser)) {
     return false;
   }
   if (lastLoginDate == null) {
     if (other.lastLoginDate != null) {
       return false;
     }
   } else if (!lastLoginDate.equals(other.lastLoginDate)) {
     return false;
   }
   if (loginName == null) {
     if (other.loginName != null) {
       return false;
     }
   } else if (!loginName.equals(other.loginName)) {
     return false;
   }
   if (name == null) {
     if (other.name != null) {
       return false;
     }
   } else if (!name.equals(other.name)) {
     return false;
   }
   if (password == null) {
     if (other.password != null) {
       return false;
     }
   } else if (!password.equals(other.password)) {
     return false;
   }
   if (registrationHash == null) {
     if (other.registrationHash != null) {
       return false;
     }
   } else if (!registrationHash.equals(other.registrationHash)) {
     return false;
   }
   if (role == null) {
     if (other.role != null) {
       return false;
     }
   } else if (!role.equals(other.role)) {
     return false;
   }
   if (state != other.state) {
     return false;
   }
   if (surname == null) {
     if (other.surname != null) {
       return false;
     }
   } else if (!surname.equals(other.surname)) {
     return false;
   }
   return true;
 }