From 121912a0b03dcc11d640aa417613cf8aaccf52cb Mon Sep 17 00:00:00 2001 From: Victor Date: Sun, 16 Mar 2014 15:54:01 +0200 Subject: [PATCH] Util now used RandomExt --- src/com/annimon/turrets/Util.java | 38 ++++++++----------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/com/annimon/turrets/Util.java b/src/com/annimon/turrets/Util.java index 71999ba..5c23091 100644 --- a/src/com/annimon/turrets/Util.java +++ b/src/com/annimon/turrets/Util.java @@ -1,50 +1,30 @@ package com.annimon.turrets; -import java.util.Random; - /** * * @author aNNiMON */ public class Util { - private static final Random random = new Random(); + private static final RandomExt random = new RandomExt(); + + public static void setRandomSeed(long seed) { + random.setSeed(seed); + } public static int rand(int to) { - return random.nextInt(to); + return random.rand(to); } public static int rand(int from, int to) { - return random.nextInt(to - from) + from; + return random.rand(from, to); } public static double rand(double from, double to) { - return random.nextDouble() * (to - from) + from; + return random.rand(from, to); } public static int randomColor(int from, int to) { - if (from < 0) { - from = 0; - } else if (from > 255) { - from = 255; - } - if (to < 0) { - to = 0; - } else if (to > 255) { - to = 255; - } - if (from == to) { - return (0xFF000000 | (from << 16) | (from << 8) | from); - } else if (from > to) { - final int temp = to; - to = from; - from = temp; - } - - final int red = rand(from, to); - final int green = rand(from, to); - final int blue = rand(from, to); - - return (0xFF000000 | (red << 16) | (green << 8) | blue); + return random.randomColor(from, to); } }