fix random puzzle order
This commit is contained in:
@@ -12,8 +12,8 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 28d04249c1c4438da94b524e7d4afff2, type: 3}
|
||||
m_Name: Desert
|
||||
m_EditorClassIdentifier:
|
||||
minRoomSize: {x: 3, y: 2}
|
||||
playSpace: {x: 4, y: 2}
|
||||
minRoomSize: {x: 3, y: 3}
|
||||
playSpace: {x: 4, y: 3}
|
||||
spaceTile: {fileID: 3229991053255736984, guid: b8f192f7cebe686468af6b1a71c4605b,
|
||||
type: 3}
|
||||
environment: {fileID: 5743657079028767629, guid: 17ecdbaca50efaa4ab503614dfec54a8,
|
||||
|
||||
@@ -86,8 +86,7 @@ namespace EscapeRoomEngine.Engine.Runtime
|
||||
Space space;
|
||||
Passage exit = null;
|
||||
|
||||
var puzzle = _puzzles[0];
|
||||
_puzzles.RemoveAt(0);
|
||||
var puzzle = _puzzles.PopRandomElement();
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -27,7 +27,14 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
|
||||
public static int RandomInclusive(int from, int to) => Random.Range(from, to + 1);
|
||||
|
||||
public static T RandomElement<T>(this List<T> list) => list[Random.Range(0, list.Count)];
|
||||
public static T RandomElement<T>(this HashSet<T> set) => set.ElementAt(Random.Range(0, set.Count));
|
||||
|
||||
public static T PopRandomElement<T>(this List<T> list)
|
||||
{
|
||||
var index = Random.Range(0, list.Count);
|
||||
var element = list[index];
|
||||
list.RemoveAt(index);
|
||||
return element;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user