Пример #1
1
  public void arrive(Thing t) {

    Map map = getMap();

    if (map == null) throw new Error("EdgePortal Error - no map specified");

    int tx = -1;
    int ty = -1;
    int i = 0;

    while (tx == -1) {
      switch (RPG.d(5)) {
        case 1:
          if ((side & NORTH) > 0) {
            ty = 0;
            tx = RPG.r(map.getWidth());
          }
          ;
          break;
        case 2:
          if ((side & SOUTH) > 0) {
            ty = map.getHeight() - 1;
            tx = RPG.r(map.getWidth());
          }
          ;
          break;
        case 3:
          if ((side & WEST) > 0) {
            tx = 0;
            ty = RPG.r(map.getHeight());
          }
          ;
          break;
        case 4:
          if ((side & EAST) > 0) {
            tx = map.getWidth() - 1;
            ty = RPG.r(map.getHeight());
          }
          ;
          break;
        case 5:
          if ((side & ZONE) > 0) {
            tx = RPG.r(map.getWidth());
            ty = RPG.r(map.getHeight());
          }
          ;
          break;
      }

      i++;
      if (i > 5000)
        throw new Error("EdgePortal Error - unable to find space to add " + t.getName());

      if ((tx >= 0) && (map.isBlocked(tx, ty))) tx = -1;
    }
    ;

    t.moveTo(map, tx, ty);
  }
Пример #2
0
  public static void main(String[] args) {
    // 产生一个对象
    Thing thing = new Thing();

    // 拷贝一个对象
    Thing cloneThing = thing.clone();
  }
Пример #3
0
 public static void improveSlightly(Thing h) {
   h.incStat(RPG.ST_MOVESPEED, 100);
   h.incStat(RPG.ST_ATTACKSPEED, 100);
   h.incStat("ARM", 10);
   h.incStat(RPG.ST_REGENERATE, 50);
   h.incStat(RPG.ST_RECHARGE, 50);
 }
Пример #4
0
 void tickFrame(long elapsed) {
   for (int i = 0; i < things.size(); ++i) {
     Thing thing = things.get(i);
     thing.setAngles(mPitch, mAzimuth, mRoll);
     thing.tick(elapsed);
   }
 }
Пример #5
0
 public static ArrayList<StateMachine> allStateMachines(Thing thing) {
   ArrayList<StateMachine> result = new ArrayList<StateMachine>();
   for (Thing t : allThingFragments(thing)) {
     result.addAll(t.getBehaviour());
   }
   return result;
 }
Пример #6
0
  public static int gainKillExperience(Thing h, Thing t) {
    int hlevel = h.getLevel();
    int tlevel = t.getLevel();

    int killcount = 0;
    if (h.isHero()) {
      killcount = incKillCount(t);
      if (killcount == 1) {
        Score.scoreFirstKill(t);
      }
    }

    int base = t.getStat("XPValue");
    double xp = base;
    xp = xp * Math.pow(experienceDecay, killcount);
    xp = xp * Math.pow(experienceLevelMultiplier, tlevel - 1);

    // decrease xp gain for killing lower level monsters
    if (hlevel > tlevel) xp = xp / (hlevel - tlevel);

    int gain = (int) xp;

    Hero.gainExperience(gain);
    return gain;
  }
Пример #7
0
 public static ArrayList<Function> allFunctions(Thing thing) {
   ArrayList<Function> result = new ArrayList<Function>();
   for (Thing t : allThingFragments(thing)) {
     result.addAll(t.getFunctions());
   }
   return result;
 }
Пример #8
0
 public static ArrayList<Property> allProperties(Thing thing) {
   ArrayList<Property> result = new ArrayList<Property>();
   for (Thing t : allThingFragments(thing)) {
     result.addAll(t.getProperties());
   }
   return result;
 }
Пример #9
0
 public static ArrayList<Port> allPorts(Thing thing) {
   ArrayList<Port> result = new ArrayList<Port>();
   for (Thing t : allThingFragments(thing)) {
     result.addAll(t.getPorts());
   }
   return result;
 }
  /** funkcja dodajaca przedmiot do ekwipunku */
  public void found(Thing f) {
    Scanner sc = new Scanner(System.in);
    String line;
    char dec = 'a';
    int num = 0;

    System.out.println("Found something! :");
    String info = f.show();
    System.out.println("\t" + info + "\n");
    if (f.id() == 'i') {
      foundItem(f);
      return;
    }
    show();
    System.out.println("Wanna add? (y/n)");
    while (dec != 'y' && dec != 'n') {
      line = sc.nextLine();
      dec = line.charAt(0);
      if (dec != 'y' && dec != 'n') System.out.println("Only y/n answer Idjit!");
    }
    if (dec == 'n') return;

    System.out.println("Which position change? (1-8)");
    while (num < 1 || num > 8) {
      num = sc.nextInt();
      if (num > 0 && num < 9) things[num - 1] = f;
      else System.out.println("Wrong number Idjit!");
    }
    System.out.println("Added!");
  }
Пример #11
0
 public Map<String, Double> getProductsPrice() throws Exception {
   List<Thing> products = productCollection.getThings();
   Map<String, Double> result = new HashMap<String, Double>();
   for (Thing product : products) {
     result.put(product.getName(), product.getPrice());
   }
   return result;
 }
Пример #12
0
 public boolean sellMaterial(String materialName, int quantity) throws Exception {
   Thing material = materialCollection.getThingByName(materialName);
   if (!accountManager.subMoney(material.getPrice() * quantity)) {
     return false;
   }
   storageManager.addMaterial(material, quantity);
   return true;
 }
Пример #13
0
 public boolean buyProduct(String productName, int quantity) throws Exception {
   Thing product = productCollection.getThingByName(productName);
   if (!storageManager.removeMaterials(product.getProportions(), quantity)) {
     return false;
   }
   accountManager.addMoney(product.getPrice() * quantity);
   return true;
 }
Пример #14
0
 public Map<String, Double> getStorage() throws Exception {
   Map<Thing, Double> storage = storageManager.getAllMaterials();
   Map<String, Double> result = new HashMap<String, Double>();
   for (Thing material : storage.keySet()) {
     result.put(material.getName(), storage.get(material));
   }
   return result;
 }
Пример #15
0
 public Map<String, Double> getMaterialsPrice() throws Exception {
   List<Thing> materials = materialCollection.getThings();
   Map<String, Double> result = new HashMap<String, Double>();
   for (Thing material : materials) {
     result.put(material.getName(), material.getPrice());
   }
   return result;
 }
Пример #16
0
 @Override
 public int getVolume() {
   int volume = 0;
   for (Thing t : this.things) {
     volume = volume + t.getVolume();
   }
   return volume;
 }
Пример #17
0
    @Override
    public void onDesiredSizeChanged(int desiredWidth, int desiredHeight) {
      super.onDesiredSizeChanged(desiredWidth, desiredHeight);

      for (int i = 0; i < things.size(); ++i) {
        Thing thing = things.get(i);
        thing.setLWPSize(desiredWidth, desiredHeight);
      }
    }
Пример #18
0
 public static void addQuest(Thing h, Thing q) {
   ArrayList qs = (ArrayList) h.get("Quests");
   if (qs == null) {
     qs = new ArrayList();
     h.set("Quests", qs);
   }
   q.set("Hero", h);
   qs.add(q);
 }
Пример #19
0
 @Test
 public void createValidThing() throws Exception {
   Thing thing = new Thing();
   thing.setName("simon");
   thing.setAmount(6);
   thing.setDueDate(Date.from(Instant.now().plus(1, ChronoUnit.DAYS)));
   thing.setTags(Collections.singletonList("super"));
   thingManager.create(thing);
 }
Пример #20
0
 public static void addSubQuest(Thing q, Thing sq) {
   ArrayList qs = (ArrayList) q.get("Quests");
   if (qs == null) {
     qs = new ArrayList();
     q.set("Quests", qs);
   }
   sq.set("Parent", q);
   qs.add(sq);
 }
Пример #21
0
 private static HashMap getKillHashMap() {
   Thing h = Game.hero();
   HashMap hm = (HashMap) h.get("Kills");
   if (hm == null) {
     hm = new HashMap();
     h.set("Kills", hm);
   }
   return hm;
 }
Пример #22
0
 /**
  * Determine whether this instance is nested inside the tree of an instance of the same type (for
  * example, a neurite_branch inside another neurite_branch)
  */
 public boolean isNested() {
   Thing p = this.parent;
   while (null != p) {
     if (this.type.equals(p.getType())) {
       return true; // nested!
     }
     p = p.getParent();
   }
   return false;
 }
 private void setValue(Thing data, Map<String, AnnotationValue> values, String name, Object def) {
   AnnotationValue annotationValue = values.get(name);
   if (annotationValue == null) {
     if (def != null) {
       data.put(name, def);
     }
   } else {
     data.put(name, annotationValue.getValue());
   }
 }
Пример #24
0
 public static ArrayList<Thing> findThing(ThingMLModel model, String name, boolean fuzzy) {
   ArrayList<Thing> result = new ArrayList<Thing>();
   for (Thing t : allThings(model)) {
     if (t.getName().startsWith(name)) {
       if (fuzzy) result.add(t);
       else if (t.getName().equals(name)) result.add(t);
     }
   }
   return result;
 }
Пример #25
0
 public static Thing createKillNumberQuest(String desc, String name, int number) {
   Thing t = Lib.create("kill number quest");
   if (name.startsWith("[")) {
     t.set("TargetType", name.substring(1, name.length() - 1));
   } else {
     t.set("TargetName", name);
   }
   t.set("TargetCount", number);
   t.set("Description", desc);
   return t;
 }
Пример #26
0
  private static boolean notify(Event e) {
    ArrayList qs = getQuests();

    for (Iterator it = qs.iterator(); it.hasNext(); ) {
      Thing q = (Thing) it.next();

      if (q.getFlag("IsActive")) {
        q.handle(e);
      }
    }
    return false;
  }
Пример #27
0
    @Override
    public void onDestroy() {
      for (int i = 0; i < things.size(); ++i) {
        Thing thing = things.get(i);
        thing.destroyEngine();
      }

      mHandler.removeCallbacks(mDrawCB);

      seh.unregister();
      mPrefs.unregisterOnSharedPreferenceChangeListener(this);
      super.onDestroy();
    }
Пример #28
0
  /**
   * <code>set</code> transforms the given Thing into a DoubleThing, internally.
   *
   * @param thing a <code>Thing</code> value
   * @exception HeclException if an error occurs
   */
  private static void set(Thing thing) throws HeclException {
    RealThing realthing = thing.getVal();

    if (realthing instanceof DoubleThing) return;

    if (NumberThing.isNumber(realthing)) {
      // It's already a number
      thing.setVal(new DoubleThing(((NumberThing) realthing).doubleValue()));
    } else {
      /* Otherwise, try and parse the string representation. */
      thing.setVal(new DoubleThing(thing.toString()));
    }
  }
 @Test
 public void testFoo() throws Exception {
   ConfigurationObjectFactory c =
       new ConfigurationObjectFactory(
           new Properties() {
             {
               setProperty("hello", "world");
               setProperty("theValue", "value");
             }
           });
   Thing t = c.build(Thing.class);
   assertEquals(t.getName(), "world");
 }
Пример #30
0
  @Override
  public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub

    width = frame.getWidth();
    height = frame.getHeight();
    sizeControl.width = width;
    sizeControl.height = height;

    if (info.pressed == true && !showGuide) {
      showGuide = true;
    }

    if (back.pressed == true && showGuide) {
      showGuide = false;
    }

    go.x = width / 2;
    go.y = height / 2;
    info.x = width / 2;
    info.y = height / 2 + 150;
    back.x = 3 * width / 4;
    back.y = height / 2 + 150;

    for (int i = 0; i < boomList.size(); i++) {
      boomList.get(i).updatePosition();
      if (Integer.parseInt(boomList.get(i).toString()) <= 0) {
        boomList.remove(i);
      } else {
        for (int ii = 0; ii < gravList.size(); ii++) {
          gravList.get(ii).pull(boomList.get(i));
          if (boomList.get(i).collide(gravList.get(ii))) {
            boomList.remove(i);
          }
        }
      }
    }

    count--;
    if (count <= 0) {

      double rand1 = Math.random();
      double rand2 = Math.random();
      for (int ii = 0; ii < num; ii++) {
        boomList.add(new boom(rand1 * width, rand2 * height));
      }
      count = delay;
    }

    repaint();
  }