コード例 #1
0
 /*
  * Vykresleni
  */
 @Override
 public void render(Graphics graphics) {
   super.render(graphics);
   graphics.setColor(Color.black);
   graphics.fillRect(530, 10, 102, 7);
   graphics.setColor(Color.red);
   graphics.fillRect(531, 11, (float) (hStep * getHealth()), 5);
   inventory.draw(graphics);
 }
コード例 #2
0
  /*
   * Aktualizace objektu
   */
  @Override
  public void update(GameContainer gc, StateBasedGame sbg, int delta) {
    super.update(gc, sbg, delta);

    if (!isAlive) {
      if ((System.currentTimeMillis() - timeOfDeath) > spawnInterval) {
        position = new Vector2f(Level.getScreenXToLevelX(100), Level.getScreenYToLevelY(100));
        isAlive = true;
        animation = animations.getStayAnimation(getSide());
        setHealth(100);
      }
    }

    int border = 250;
    float screen_speed = 3f;
    if (position.x < engine.level.Level.getScreenShape().getMinX() + border) {
      if (position.x > engine.level.Level.getLevelShape().getMinX()
          && engine.level.Level.getLevelShape().getMinX()
              < engine.level.Level.getScreenShape().getMinX()) {
        engine.level.Level.moveScreen(screen_speed, 0);
      }
    }
    if (getCollisionShape().getMaxX() > engine.level.Level.getScreenShape().getMaxX() - border) {
      if (position.x < engine.level.Level.getLevelShape().getMaxX()
          && engine.level.Level.getLevelShape().getMaxX()
              > engine.level.Level.getScreenShape().getMaxX()) {
        engine.level.Level.moveScreen(-screen_speed, 0);
      }
    }
    if (position.y < engine.level.Level.getScreenShape().getMinY() + border) {
      if (position.y > engine.level.Level.getLevelShape().getMinY()
          && engine.level.Level.getLevelShape().getMinY()
              < engine.level.Level.getScreenShape().getMinY()) {
        engine.level.Level.moveScreen(0, screen_speed);
      }
    }
    if (getCollisionShape().getMaxY() > engine.level.Level.getScreenShape().getMaxY() - border) {
      if (getCollisionShape().getMaxY() < engine.level.Level.getLevelShape().getMaxY()
          && engine.level.Level.getLevelShape().getMaxY()
              > engine.level.Level.getScreenShape().getMaxY()) {
        engine.level.Level.moveScreen(0, -screen_speed);
      }
    }

    if (position.x < engine.level.Level.getScreenShape().getMinX()) {
      position.x = engine.level.Level.getScreenShape().getMinX();
    }
    if (getCollisionShape().getMaxX() > Level.getScreenShape().getMaxX()) {
      position.x = Level.getScreenShape().getMaxX() - getCollisionShape().getWidth();
    }
    if (position.y < Level.getScreenShape().getMinY()) {
      position.y = Level.getScreenShape().getMinY();
    }
    if (position.y > Level.getLevelShape().getMaxY()) {
      this.deactivate();
    }
  }
コード例 #3
0
 @Override
 public void decreaseHealth(float decrease) {
   try {
     (new Sound("data/sounds/ouch.wav")).play();
   } catch (SlickException ex) {
   }
   if (!Cheats.isImmortal()) {
     super.decreaseHealth(decrease);
   }
 }
コード例 #4
0
 @Override
 public void increaseHealth(float increase) {
   try {
     (new Sound("data/sounds/aaah.wav")).play();
   } catch (SlickException ex) {
   }
   if (getHealth() + increase > 100) {
     setHealth(100);
   } else {
     super.increaseHealth(increase);
   }
 }
コード例 #5
0
ファイル: ClassInfoImpl.java プロジェクト: nile/beankeeper
 /**
  * Instantiate an object of this info entity. If the object in question is a dynamic object, it's
  * dynamic name will be set.
  *
  * @param marshalledValues The values for which this object will be created.
  */
 public Object newInstance(Map marshalledValues)
     throws InstantiationException, IllegalAccessException {
   // If primitive type, then construct with primitive value
   if (isPrimitive())
     return ((StrictPrimitiveHandler) getHandler(getSourceEntry())).newInstance(marshalledValues);
   // It's a custom object, create it
   Object result = sourceEntry.getSourceClass().newInstance();
   // If it's a dynamic object, then set it's dynamic name
   if (DynamicObject.class.isAssignableFrom(sourceEntry.getSourceClass()))
     ((DynamicObject) result).setPersistenceDynamicName(sourceEntry.getDynamicName());
   return result;
 }
コード例 #6
0
 /*
  * Co se stane po smrti
  */
 @Override
 public void notifyDeath() {
   super.notifyDeath();
   try {
     (new Sound("data/sounds/death.wav")).play();
   } catch (SlickException ex) {
   }
   animation = animations.getDiedFigure(getSide());
   timeOfDeath = System.currentTimeMillis();
   GameStats.nextDeath();
   try {
     GameStats.nextLive();
   } catch (SlickException ex) {
   }
 }
コード例 #7
0
 @Override
 public boolean hasProperty(String name) {
   return delegate.hasProperty(name);
 }
コード例 #8
0
 @Override
 public boolean isMayImplementMissingProperties() {
   return implementsMissing && includeProperties && delegate.isMayImplementMissingProperties();
 }
コード例 #9
0
 @Override
 public boolean isMayImplementMissingMethods() {
   return implementsMissing && delegate.isMayImplementMissingMethods();
 }
コード例 #10
0
 @Override
 public Object invokeMethod(String name, Object... arguments) throws MissingMethodException {
   return delegate.invokeMethod(name, arguments);
 }
コード例 #11
0
 @Override
 public boolean hasMethod(String name, Object... arguments) {
   return delegate.hasMethod(name, arguments);
 }
コード例 #12
0
 @Override
 public Map<String, ?> getProperties() {
   return delegate.getProperties();
 }
コード例 #13
0
 @Override
 public void setProperty(final String name, Object value) throws MissingPropertyException {
   delegate.setProperty(name, value);
 }
コード例 #14
0
 @Override
 public Object getProperty(String name) throws MissingPropertyException {
   return delegate.getProperty(name);
 }
コード例 #15
0
 public void invalidObject(final DynamicObject dynamicObject) {
   if (dynamicObject.equals(getWrappedObject())) {
     setWrappedObject(null);
   }
 }