/* * 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); }
/* * 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(); } }
@Override public void decreaseHealth(float decrease) { try { (new Sound("data/sounds/ouch.wav")).play(); } catch (SlickException ex) { } if (!Cheats.isImmortal()) { super.decreaseHealth(decrease); } }
@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); } }
/** * 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; }
/* * 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) { } }
@Override public boolean hasProperty(String name) { return delegate.hasProperty(name); }
@Override public boolean isMayImplementMissingProperties() { return implementsMissing && includeProperties && delegate.isMayImplementMissingProperties(); }
@Override public boolean isMayImplementMissingMethods() { return implementsMissing && delegate.isMayImplementMissingMethods(); }
@Override public Object invokeMethod(String name, Object... arguments) throws MissingMethodException { return delegate.invokeMethod(name, arguments); }
@Override public boolean hasMethod(String name, Object... arguments) { return delegate.hasMethod(name, arguments); }
@Override public Map<String, ?> getProperties() { return delegate.getProperties(); }
@Override public void setProperty(final String name, Object value) throws MissingPropertyException { delegate.setProperty(name, value); }
@Override public Object getProperty(String name) throws MissingPropertyException { return delegate.getProperty(name); }
public void invalidObject(final DynamicObject dynamicObject) { if (dynamicObject.equals(getWrappedObject())) { setWrappedObject(null); } }