Beispiel #1
0
  public void addChild(Item child, Point2D location) {
    child.setParent(this);
    if (location.getX() == 0 && location.getY() == 0) {
      location = getRandomContainerLocation();
    }
    if (this.graphic == Items.GFX_SPELLBOOK) {
      child.setAmount(Spell.fromScrollGraphic(child.getGraphic()).toByte());
    } else if (this.graphic == Items.GFX_SHOP_CONTAINER) {
      // the client sorts the shop list by location and uses that as index
      int index = children.size();
      location = new Point2D(index, index);
    }

    child.location = new Point3D(location, 0);
    children.add(child);
    for (ObjectObserver o : observers) o.onChildAdded(this, child);
  }
Beispiel #2
0
 public void setAmount(int amount) {
   this.amount = amount;
   for (ObjectObserver o : observers) o.onObjectUpdate(this);
 }
Beispiel #3
0
 public void setDragged(Player who) {
   this.draggedBy = who;
   for (ObjectObserver o : observers) o.onItemDragged(this, who);
 }
Beispiel #4
0
 public void setLightLevel(byte level) {
   this.lightLevel = level;
   for (ObjectObserver o : observers) o.onObjectUpdate(this);
 }
Beispiel #5
0
 public void removeChild(Item child) {
   children.remove(child);
   for (ObjectObserver o : observers) o.onChildRemoved(this, child);
 }