private int healingThisTick(){ return (int)GameMath.gate(1, Math.round(healingLeft * percentHealPerTick) + flatHealPerTick, healingLeft); }
protected void updateMotion() { float elapsed = Game.elapsed; float d = (GameMath.speed( speed.x, acc.x ) - speed.x) / 2; speed.x += d; x += speed.x * elapsed; speed.x += d; d = (GameMath.speed( speed.y, acc.y ) - speed.y) / 2; speed.y += d; y += speed.y * elapsed; speed.y += d; angle += angularSpeed * elapsed; }
private int healingThisTick(){ return (int)GameMath.gate(1, Math.round(healingLeft * percentHealPerTick) + flatHealPerTick, healingLeft); }
protected final Point getDoorCenter(){ PointF doorCenter = new PointF(0, 0); for (Door door : connected.values()) { doorCenter.x += door.x; doorCenter.y += door.y; } Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); if (Random.Float() < doorCenter.x % 1) c.x++; if (Random.Float() < doorCenter.y % 1) c.y++; c.x = (int) GameMath.gate(left+2, c.x, right-2); c.y = (int)GameMath.gate(top+2, c.y, bottom-2); return c; }
protected final Point getDoorCenter(){ PointF doorCenter = new PointF(0, 0); for (Door door : connected.values()) { doorCenter.x += door.x; doorCenter.y += door.y; } Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); if (Random.Float() < doorCenter.x % 1) c.x++; if (Random.Float() < doorCenter.y % 1) c.y++; c.x = (int) GameMath.gate(left+2, c.x, right-2); c.y = (int)GameMath.gate(top+2, c.y, bottom-2); return c; }
@Override public boolean onMouseScroll(int scroll) { mouseZoom -= scroll / 3f; if (PDInputProcessor.modifier) { mouseZoom = zoom( mouseZoom ); } else { zoom( Math.round( mouseZoom ) ); mouseZoom = GameMath.gate( PixelScene.minZoom, mouseZoom, PixelScene.maxZoom ); } return true; }
protected final Point getDoorCenter(){ PointF doorCenter = new PointF(0, 0); for (Door door : connected.values()) { doorCenter.x += door.x; doorCenter.y += door.y; } Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); if (Random.Float() < doorCenter.x % 1) c.x++; if (Random.Float() < doorCenter.y % 1) c.y++; c.x = (int) GameMath.gate(left+2, c.x, right-2); c.y = (int)GameMath.gate(top+2, c.y, bottom-2); return c; }
protected final Point getDoorCenter(){ PointF doorCenter = new PointF(0, 0); for (Door door : connected.values()) { doorCenter.x += door.x; doorCenter.y += door.y; } Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); if (Random.Float() < doorCenter.x % 1) c.x++; if (Random.Float() < doorCenter.y % 1) c.y++; c.x = (int)GameMath.gate(left+1, c.x, right-1); c.y = (int)GameMath.gate(top+1, c.y, bottom-1); return c; } }
protected final Point getDoorCenter(){ PointF doorCenter = new PointF(0, 0); for (Door door : connected.values()) { doorCenter.x += door.x; doorCenter.y += door.y; } Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); if (Random.Float() < doorCenter.x % 1) c.x++; if (Random.Float() < doorCenter.y % 1) c.y++; c.x = (int) GameMath.gate(left+2, c.x, right-2); c.y = (int)GameMath.gate(top+2, c.y, bottom-2); return c; }
protected final Point getDoorCenter(){ PointF doorCenter = new PointF(0, 0); for (Door door : connected.values()) { doorCenter.x += door.x; doorCenter.y += door.y; } Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); if (Random.Float() < doorCenter.x % 1) c.x++; if (Random.Float() < doorCenter.y % 1) c.y++; c.x = (int)GameMath.gate(left+1, c.x, right-1); c.y = (int)GameMath.gate(top+1, c.y, bottom-1); return c; } }
public float penaltyFactor( Hero hero, boolean identified ) { return 1.0f - 0.025f * GameMath.gate( 0, penaltyBase(hero, strShown( identified ) ) - ( this instanceof Weapon && ((Weapon)this).enchantment instanceof Ethereal ? bonus : 0 ), 20 ); }
public static Armor randomArmor(int floorSet) { floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1); try { Armor a = (Armor)Category.ARMOR.classes[Random.chances(floorSetTierProbs[floorSet])].newInstance(); a.random(); return a; } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
public static Armor randomArmor(int floorSet) { floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1); try { Armor a = (Armor)Category.ARMOR.classes[Random.chances(floorSetTierProbs[floorSet])].newInstance(); a.random(); return a; } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
public static int getInt( String key, int defValue, int min, int max ) { try { int i = get().getInt( key, defValue ); if (i < min || i > max){ int val = (int)GameMath.gate(min, i, max); put(key, val); return val; } else { return i; } } catch (ClassCastException e) { //ShatteredPixelDungeon.reportException(e); put(key, defValue); return defValue; } }
public static MissileWeapon randomMissile(int floorSet) { floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1); try { Category c = misTiers[Random.chances(floorSetTierProbs[floorSet])]; MissileWeapon w = (MissileWeapon)c.classes[Random.chances(c.probs)].newInstance(); w.random(); return w; } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
public static MeleeWeapon randomWeapon(int floorSet) { floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1); try { Category c = wepTiers[Random.chances(floorSetTierProbs[floorSet])]; MeleeWeapon w = (MeleeWeapon)c.classes[Random.chances(c.probs)].newInstance(); w.random(); return w; } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }
@Override protected void onDrag(Touchscreen.Touch touch) { if (pressed) { PointF p = camera().screenToCamera((int) touch.current.x, (int) touch.current.y); sliderNode.x = GameMath.gate(sliderBG.x - 2, p.x, sliderBG.x + sliderBG.width() - 2); } }
public static MeleeWeapon randomWeapon(int floorSet) { floorSet = (int)GameMath.gate(0, floorSet, floorSetTierProbs.length-1); try { Category c = wepTiers[Random.chances(floorSetTierProbs[floorSet])]; MeleeWeapon w = (MeleeWeapon)c.classes[Random.chances(c.probs)].newInstance(); w.random(); return w; } catch (Exception e) { ShatteredPixelDungeon.reportException(e); return null; } }