コード例 #1
0
 private final float getRandomValueB() {
   if (this.mMinValueB == this.mMaxValueB) {
     return this.mMaxValueB;
   } else {
     return RANDOM.nextFloat() * (this.mMaxValueB - this.mMinValueB) + this.mMinValueB;
   }
 }
コード例 #2
0
  private void splat(PointF start, PointF end, PointF mid, float d) {

    Path firstPath = new Path();
    if (d < 0) {
      d = 0;
    }

    firstPath.moveTo(start.x, start.y);
    firstPath.quadTo(mid.x, mid.y, end.x, end.y);
    fCurrentOperation.addPath(firstPath, d);

    float dst = dist(start.x, start.y, end.x, end.y);
    int quarterDrips = fDrips / 4;
    int nbDrips = quarterDrips + RANDOM.nextInt(fDrips);

    for (int i = 0; i < nbDrips; i++) {
      // positioning of splotch varies between ±4dd, tending towards 0

      float x4 = dst * getProbability(0.5f);
      float y4 = dst * getProbability(0.5f);
      // direction of splotch varies between ±0.5
      float x5 = getProbability(0.5f);
      float y5 = getProbability(0.5f);

      float dd = Math.min(d * (RANDOM.nextFloat() + 0.4f), d);
      Path subPath = new Path();
      subPath.moveTo(start.x + x4, start.y + y4);
      subPath.lineTo(start.x + x4 + x5, start.y + y4 + y5);
      fCurrentOperation.addPath(subPath, dd);
    }
  }
コード例 #3
0
ファイル: NMS.java プロジェクト: kuohsuanlo/Citizens2
 public static void trySwim(org.bukkit.entity.Entity entity, float power) {
   Entity handle = getHandle(entity);
   if (RANDOM.nextFloat() < 0.8F && inWater(entity)) {
     handle.motY += power;
   }
 }