Aura.Channel.World.Dungeons.Dungeon.GeneratePuzzles C# (CSharp) Метод

GeneratePuzzles() приватный Метод

Generates random puzzles for the floor.
private GeneratePuzzles ( int iFloor ) : void
iFloor int The index of the floor.
Результат void
		private void GeneratePuzzles(int iFloor)
		{
			var floorData = this.Generator.Data.Floors[iFloor];
			var rng = this.Generator.RngPuzzles;
			var sections = this.Generator.Floors[iFloor].Sections;

			var indexList = new List<int>();
			for (var section = 0; section < sections.Count; ++section)
			{
				var puzzleCount = floorData.Sections[section].Max;
				var allPuzzlesCount = floorData.Sections[section].Puzzles.Count;
				indexList.Clear();
				for (var s = 0; s < allPuzzlesCount; indexList.Add(s++)) ;
				for (var s = 0; s < allPuzzlesCount; ++s)
				{
					var pos = (int)rng.GetUInt32(0, (uint)allPuzzlesCount - 1);
					var tmp = indexList[pos];
					indexList[pos] = indexList[s];
					indexList[s] = tmp;
				}
				for (var p = 0; p < puzzleCount; ++p)
				{
					var randomPuzzle = indexList[p % puzzleCount];
					var scriptName = floorData.Sections[section].Puzzles[randomPuzzle].Script;
					var puzzleScript = ChannelServer.Instance.ScriptManager.PuzzleScripts.Get(scriptName);
					if (puzzleScript == null)
					{
						Log.Warning("DungeonFloor.GeneratePuzzles: '{0}' puzzle script not found.", scriptName);
						continue;
					}
					Puzzle puzzle = null;
					try
					{
						puzzle = sections[section].NewPuzzle(this, floorData, floorData.Sections[section].Puzzles[randomPuzzle], puzzleScript);
						puzzleScript.OnPrepare(puzzle);
					}
					catch (PuzzleException e)
					{
						sections[section].Puzzles.Remove(puzzle);
						Log.Debug("Floor {0} Section {1}, puzzle '{2}' : {3}", iFloor, section, scriptName, e.Message);
					}
				}
			}
		}