|
@@ -23,7 +23,7 @@ class RoomRandom extends Room {
|
|
public randomizable = true; // non-randomizable rooms don't get placed automatically
|
|
public randomizable = true; // non-randomizable rooms don't get placed automatically
|
|
public placed = false;
|
|
public placed = false;
|
|
public appearChance = 75;
|
|
public appearChance = 75;
|
|
- public extraConnectionChance = 75;
|
|
|
|
|
|
+ public extraConnectionChance = 15;
|
|
public backgroundImage = "tomato";
|
|
public backgroundImage = "tomato";
|
|
|
|
|
|
public lastMap : RoomRandomMap;
|
|
public lastMap : RoomRandomMap;
|
|
@@ -50,6 +50,7 @@ class RoomRandom extends Room {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ console.warn("Room background " + this.backgroundImage + " not found.");
|
|
return false;
|
|
return false;
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.warn("Unable to read image");
|
|
console.warn("Unable to read image");
|
|
@@ -121,6 +122,26 @@ class RoomRandom extends Room {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the closest direction we have in North, South, etc.
|
|
|
|
+ * @param coordinates
|
|
|
|
+ */
|
|
|
|
+ public getOverallDirectionTo (coordinates) {
|
|
|
|
+ let myCoordinates = this.lastMap.getCoordinates(this);
|
|
|
|
+ let dy = (coordinates[1] - myCoordinates[1]);
|
|
|
|
+ let dx = (coordinates[0] - myCoordinates[0]);
|
|
|
|
+ let theta = Math.atan2(dy, dx); // range (-PI, PI]
|
|
|
|
+ theta *= 180 / Math.PI; // rads to degs, range (-180, 180];
|
|
|
|
+ theta = Math.round(theta / 45);
|
|
|
|
+ if (theta < 0) {
|
|
|
|
+ theta = 8 + theta;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let directions = [Direction.EAST, Direction.NORTHEAST, Direction.NORTH, Direction.NORTHWEST, Direction.WEST, Direction.SOUTHWEST, Direction.SOUTH, Direction.SOUTHEAST];
|
|
|
|
+ return directions[theta];
|
|
|
|
+ //if (theta < 0) theta = 360 + theta; // range [0, 360)
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This implementation is sufficiently fast for constant use.
|
|
* This implementation is sufficiently fast for constant use.
|
|
* @param pathEnd
|
|
* @param pathEnd
|