public override Nancy.ViewEngines.Razor.IHtmlString GenerateFieldHtml()
        {
            var model      = FieldGenerator.GetModel();
            var selectList = GetSelectList(model);

            return(GetSelectListHtml(selectList));
        }
        private void Generate_Z_Mines_InXxYField(int rowCount, int columnCount, int mines)
        {
            // Arrange
            IUnityContainer container     = new UnityContainer();
            FieldSettings   fieldSettings = new FieldSettings()
            {
                Mines = mines, Rows = rowCount, Columns = columnCount
            };

            container.RegisterInstance(fieldSettings);
            container.RegisterType <IMineSetter, MineSetter>();
            container.RegisterType <INeighbourMinesCalculator, NeighbourMinesCalculator>();
            var fieldGenerator = new FieldGenerator(container);

            // Act
            fieldGenerator.Generate();
            var field      = container.Resolve <Field>();
            int minesCount = 0;

            for (int columnIndex = 0; columnIndex < field.Columns; columnIndex++)
            {
                for (int rowIndex = 0; rowIndex < field.Rows; rowIndex++)
                {
                    if (field[columnIndex, rowIndex].IsMine)
                    {
                        minesCount++;
                    }
                }
            }

            // Assert
            Assert.IsTrue(minesCount == mines);
        }
Beispiel #3
0
    public void GenerateSelectableLevelFields()
    {
        if (fieldGenerator == null)
        {
            fieldGenerator = GetComponent <FieldGenerator>();
        }

        for (int i = 0; i < levelNodeFields.Length; i++)
        {
            List <FieldGenerator.Node> nodes = fieldGenerator.GenerateField(levelNodeFields[i].FieldSize, levelNodeFields[i].LevelStartDirection, levelNodeFields[i].SpiralCounting, levelNodeFields[i].StartCountingValue, levelNodeFields[i].IsHorizontal);

            foreach (FieldGenerator.Node node in nodes)
            {
                Vector2 gridPosition        = node.Position + levelNodeFields[i].FieldPosition;
                Vector2 nodePositionOffset  = new Vector2(node.Position.x * levelNodeFields[i].ObjectToBuild.transform.localScale.x, node.Position.y * levelNodeFields[i].ObjectToBuild.transform.localScale.y);
                Vector2 fieldPositionOffset = new Vector2(levelNodeFields[i].FieldPosition.x * levelNodeFields[i].ObjectToBuild.transform.localScale.x, levelNodeFields[i].FieldPosition.y * levelNodeFields[i].ObjectToBuild.transform.localScale.y);

                Vector2 positionOffset = nodePositionOffset + fieldPositionOffset;

                Vector2 gridSpacingOffset = new Vector2(positionOffset.x * gridSpacing.x, positionOffset.y * gridSpacing.y);

                Vector2 nodePosition = positionOffset + gridSpacingOffset;

                LevelProgressState status = gameStateModel.Get().CompletedLevels.Contains(node.Counter) ? LevelProgressState.Finished : LevelProgressState.Locked;

                ISelectableLevel levelNode = InstantiateSelectableLevel(levelNodeFields[i].ObjectToBuild, gameObject, nodePosition, node.Counter, status);

                selectableLevels.Add(gridPosition, levelNode);
            }
        }
    }
        public void Simple3x3FieldWith1MineInMiddle()
        {
            // Arrange
            IUnityContainer container     = new UnityContainer();
            FieldSettings   fieldSettings = new FieldSettings()
            {
                Mines = 1, Rows = 3, Columns = 3
            };

            container.RegisterInstance(fieldSettings);
            container.RegisterType <IMineSetter, MineSetter3x3With1Mine>();
            container.RegisterType <INeighbourMinesCalculator, NeighbourMinesCalculator>();
            var fieldGenerator = new FieldGenerator(container);

            // Act
            fieldGenerator.Generate();
            var field = container.Resolve <Field>();

            // Assert
            int[,] solution = new int[, ] {
                { 1, 1, 1 }, { 1, 0, 1 }, { 1, 1, 1 }
            };
            for (int columnIndex = 0; columnIndex < field.Columns; columnIndex++)
            {
                for (int rowIndex = 0; rowIndex < field.Rows; rowIndex++)
                {
                    Assert.IsTrue(field[columnIndex, rowIndex].NeighbourMines == solution[columnIndex, rowIndex]);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Method to fetch fields which are of OBJECT primitive type.
        /// </summary>
        /// <param name="variableList">
        /// @return </param>
        //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
        //ORIGINAL LINE: private static java.util.ArrayList<? extends edu.uta.cse.proggen.classLevelElements.Field> getObjects(java.util.ArrayList<? extends edu.uta.cse.proggen.classLevelElements.Field> variableList)
        //JAVA TO C# CONVERTER TODO TASK: Java wildcard generics are not converted to .NET:
        //ORIGINAL LINE: private static java.util.ArrayList<? extends edu.uta.cse.proggen.classLevelElements.Field> getObjects(java.util.ArrayList<? extends edu.uta.cse.proggen.classLevelElements.Field> variableList)
        //static void Cat<T> (IList<T> sources)



        //Veena : Again unreachable Code.
        // THis is if Objects are being created. Since we are not doing inheritence/Objects, it's Unreacheble.
        //So dont waste time converting it. Get a Life :P
        //private static List<T> getObjects(List<T> variableList) where ? : edu.uta.cse.proggen.classLevelElements.Field where T1 : edu.uta.cse.proggen.classLevelElements.Field
        //{
        //    List<Field> objList = new List<Field>();

        //    foreach (Field @var in variableList)
        //    {
        //        if (@var.Type.Type == Type.Primitives.OBJECT)
        //        {
        //            objList.Add(@var);
        //        }
        //    }
        //    return objList;
        //}

        private static string getParametersForList(List <Variable> parameterList, Method method)
        {
            string parameters = "";

            foreach (Variable @var in parameterList)
            {
                if (@var.Name.Equals("recursionCounter"))
                {
                    parameters += "recursionCounter,";
                    continue;
                }

                Operand         operand;
                Type.Primitives primitive             = @var.Type.getType();//.Type.Type;
                int             optionVariableOrField = (new Random()).Next(1);
                if (optionVariableOrField == 0)
                {
                    operand = VariableGenerator.getRandomizedVariable(method, primitive);
                }
                else
                {
                    operand = FieldGenerator.getRandomField(method.AssociatedClass, primitive, method.Static);
                }
                parameters += operand + ",";
            }
            parameters = parameters.Substring(0, parameters.Length - 1);
            return(parameters);
        }
Beispiel #6
0
 public void Create_WhenCreatingFieldWithModifiers_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("publicintmyField;", FieldGenerator.Create(new Field("myField", typeof(int), new List <Modifiers>()
     {
         Modifiers.Public
     })).ToString());
 }
Beispiel #7
0
    public void Init(InitIntent intent)
    {
        // Get gameplay parameters from level manager
        rows            = levelManager.GetComponent <LevelManager>().rows;
        columns         = levelManager.GetComponent <LevelManager>().columns;
        maxValue        = levelManager.GetComponent <LevelManager>().maxValue;
        numberOfTargets = levelManager.GetComponent <LevelManager>().numberOfTargets;
        movesLimit      = levelManager.GetComponent <LevelManager>().movesLimit;

        // Fix grid layout to make correct number of columns
        gameField.GetComponent <GridLayoutGroup>().constraintCount = columns;

        // Generate the field & pass the target value
        if (intent == InitIntent.NewLevel)
        {
            fieldGenerator = new FieldGenerator(rows, columns, maxValue, numberOfTargets, movesLimit);
        }

        targetValue = fieldGenerator.targetValue;

        // Set global value text in the top HUD
        currentTargetValue     = 0;
        globalTargetText.text  = targetValue.ToString();
        currentTargetText.text = currentTargetValue.ToString();

        // Set progress bar
        resetProgressBar();

        // Create an array of game field cells
        gameFieldCells = new GameFieldCell[rows, columns];

        // Instantiate game field cells and set their values
        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < columns; j++)
            {
                // Instantiate & name
                var cell = Instantiate(cellPrefab, gameField.transform).GetComponent <GameFieldCell>();
                gameFieldCells[i, j]    = cell;
                cell.gameObject.name    = "Button Row " + fieldGenerator.cells[i, j].row.ToString() + " Col " + fieldGenerator.cells[i, j].column.ToString();
                cell.gameplayManager    = gameObject.GetComponent <GameplayManager>();
                cell.helpMessageManager = helpMessageManager.GetComponent <HelpMessageManager>();
                cell.soundPlayer        = soundPlayer.GetComponent <SoundPlayer>();
                // Here goes something ugly IMHO
                cell.normalPressSound = normalPressSound;
                cell.usedPressSound   = usedPressSound;
                cell.arrowsOnSound    = arrowsOnSound;
                cell.arrowsOffSound   = arrowsOffSound;

                // Set values from the generator
                cell.row      = fieldGenerator.cells[i, j].row;
                cell.column   = fieldGenerator.cells[i, j].column;
                cell.Value    = fieldGenerator.cells[i, j].value;
                cell.isTarget = fieldGenerator.cells[i, j].isTarget;
            }
        }

        // Set game state to normal
        gameStateManager.GetComponent <GameStateManager>().StateChange(GameStates.Normal);
    }
Beispiel #8
0
        protected override PropertyBuilder ExecuteBuild()
        {
            Field = new ProxyFieldGnerator($"_{PropertyName}", PropertyType, DeclaringMember);
            Field.Build();

            return(base.ExecuteBuild());
        }
Beispiel #9
0
 public void Create_WhenCreatingFieldWithAttribute_ShouldGenerateCorrectCode()
 {
     Assert.AreEqual("[Test]intmyField;", FieldGenerator.Create(new Field("myField", typeof(int), attributes: new List <Attribute>()
     {
         new Attribute("Test")
     })).ToString());
 }
    void Awake()
    {
        GameObject GameManager = GameObject.Find("GameManager");

        genNumbers = GameManager.GetComponent <GeneralNumbers>();
        fieldData  = GameManager.GetComponent <FieldGenerator>();
    }
Beispiel #11
0
        static void Example()
        {
            // 乱数の設定をコンストラクタで行います。
            FieldGenerator gen = new FieldGenerator(5);

            // フィールドの生成方法
            // フィールドのw, hは2以上
            // ブロックのw, hは5以上かつ奇数という制限があります
            int fieldHeight = 3;
            int fieldWidth = 3;
            int blockHeight = 5;
            int blockWidth = 5;
            gen.SetSize(fieldHeight, fieldWidth, blockHeight, blockWidth);

            // フィールドを生成します
            // 各要素がブロックである2次元配列を生成します
            // したがって、ブロック(i,j)にはreturn_value[i,j]でアクセスし、
            // ブロック(i,j)内の要素(u,v)にはreturn_value[i,j][u,v]でアクセスします
            var field = gen.CreateField();
            gen.DebugPrint(field);

            // 生成したフィールドの1つの要素が何を示すかはFieldGenerator.ChipTypeで調べます。
            if (FieldGenerator.ChipType.Wall == field[0, 0][0, 0])
                Console.WriteLine("壁です");
        }
Beispiel #12
0
    public void TestGenerateDelegateEvents()
    {
        var gen         = new CodeUnitGenerator("TestCodeGen");
        var classGen    = new ClassGenerator("TestClass");
        var delegateGen = new DelegateGenerator("MyEventHandler")
                          .AddParameter("TestClass", "myRef")
                          .AddReturnType(typeof(bool));

        var eventGen = new EventGenerator("OnSomeTrigger", delegateGen.delegateType);

        classGen.AddEvent(eventGen);
        var fireEventMethod = new MethodGenerator("FireEvent")
                              .AddStatement(new StatementBuilder()
                                            //.AddSnippetExpression("Debug.Log();DoMoreStuff();"));
                                            .InvokeEvent(eventGen, new ParamBuilder()
                                                         .AddPrimitiveExpression("new TestClass()")));

        classGen.AddMethod(fireEventMethod);

        gen.AddType(delegateGen);
        gen.AddType(classGen);

        var classSubscriber = new ClassGenerator("MySubscribeClass");
        var field           = new FieldGenerator("TestClass", "eventSource");

        classSubscriber.AddField(field);

        var constructor = new ConstructorGenerator(classSubscriber.classType);

        classSubscriber.AddMethod(constructor);

        var eventHandler = new MethodGenerator("OnSomeTrigger", delegateGen)
                           .AddStatement(new StatementBuilder()
                                         .AddSnippet("Debug.Log(\"Expression1\");")
                                         .AddSnippet("Debug.Log(\"Expression2\");"));

        var subscribeMethod = new MethodGenerator("AddListener")
                              .AddStatement(new StatementBuilder()
                                            .AttachEvent(eventHandler, new FieldTarget(field), eventGen));

        classSubscriber.AddMethod(
            new MethodGenerator("Unsubscribe").AddStatement(
                new StatementBuilder()
                .DetachEvent(eventHandler, new FieldTarget(field), eventGen)));
        classSubscriber.AddMethod(eventHandler);
        classSubscriber.AddMethod(subscribeMethod);
        gen.AddType(classSubscriber);

        var ccu = gen.GenerateCompileUnit();

        var output = StringCompiler.CompileToString(ccu);

        //Debug.Log(output);
        Assert.IsTrue(output.Contains("OnSomeTrigger"));
        Assert.IsTrue(output.Contains("FireEvent"));
        Assert.IsTrue(output.Contains("+="));
        Assert.IsTrue(output.Contains("-="));
        Assert.IsTrue(output.Contains("delegate"));
        Assert.IsTrue(output.Contains("event"));
    }
Beispiel #13
0
    public void TestGenerateAttributes()
    {
        var gen = new CodeUnitGenerator("TestCodeGen");

        var attributeGen = new ClassGenerator("MyAttribute")
                           .AddBaseType("Attribute");

        var classGen = new ClassGenerator("TestClass");

        classGen.SetCustomAttribute("MyAttribute", new ParamBuilder());

        var field = new FieldGenerator(typeof(int), "MyField");

        field.SetCustomAttribute("MyAttribute", new ParamBuilder());
        var property = new AutoPropertyGenerator("TestClass", "MyProp");

        property.SetCustomAttribute("MyAttribute", new ParamBuilder());


        classGen.AddAutoProperty(property);
        classGen.AddField(field);
        gen.AddType(attributeGen);
        gen.AddType(classGen);
        var ccu = gen.GenerateCompileUnit();

        var output = StringCompiler.CompileToString(ccu);

        Debug.Log(output);
        Assert.IsTrue(output.Contains("MyAttribute"));
    }
Beispiel #14
0
        static void Example()
        {
            // 乱数の設定をコンストラクタで行います。
            FieldGenerator gen = new FieldGenerator(5);

            // フィールドの生成方法
            // フィールドのw, hは2以上
            // ブロックのw, hは5以上かつ奇数という制限があります
            int fieldHeight = 3;
            int fieldWidth  = 3;
            int blockHeight = 5;
            int blockWidth  = 5;

            gen.SetSize(fieldHeight, fieldWidth, blockHeight, blockWidth);

            // フィールドを生成します
            // 各要素がブロックである2次元配列を生成します
            // したがって、ブロック(i,j)にはreturn_value[i,j]でアクセスし、
            // ブロック(i,j)内の要素(u,v)にはreturn_value[i,j][u,v]でアクセスします
            var field = gen.CreateField();

            gen.DebugPrint(field);

            // 生成したフィールドの1つの要素が何を示すかはFieldGenerator.ChipTypeで調べます。
            if (FieldGenerator.ChipType.Wall == field[0, 0][0, 0])
            {
                Console.WriteLine("壁です");
            }
        }
Beispiel #15
0
    public void TestGenerateClassImplementation()
    {
        var gen      = new CodeUnitGenerator("TestCodeGen");
        var classGen = new ClassGenerator("TestClass")
                       .SetIsPartial(true)
                       .SetIsAbstract(true)
                       .AddBaseType("IComponent");
        var field       = new FieldGenerator(typeof(int), "MyField");
        var property    = new AutoPropertyGenerator("TestClass", "MyProp");
        var constructor = new ConstructorGenerator()
                          .AddBaseCall("BaseArg")
                          .AddParameter(field.FieldType, field.Name)
                          .AddParameter(property.Name, property.PropertyType)
                          .AddStatement(new StatementBuilder()
                                        .AddConstructorFieldAssignement(field.Name, field.Name)
                                        .AddConstructorPropertyAssignement(property.Name, property.Name));

        classGen.AddAutoProperty(property);
        classGen.AddField(field);
        classGen.AddMethod(constructor);
        gen.AddType(classGen);
        var ccu = gen.GenerateCompileUnit();

        var output = StringCompiler.CompileToString(ccu);

        Debug.Log(output);
        Assert.IsTrue(output.Contains("base("));
        Assert.IsTrue(output.Contains("BaseArg"));
    }
Beispiel #16
0
        /// <inheritdoc />
        public override IHtmlContent GenerateFieldHtml(IReadonlyFieldConfiguration fieldConfiguration)
        {
            var model      = FieldGenerator.GetModel();
            var selectList = GetSelectList(model);

            return(GetSelectListHtml(selectList, fieldConfiguration));
        }
Beispiel #17
0
        public void Generate_EnterCertainSize_FieldCreatedWithCertainSize(int size)
        {
            var f = FieldGenerator.Generate(size);

            Assert.NotNull(f);
            Assert.AreEqual(size, f.Size);
        }
Beispiel #18
0
        public void Generate_PassNoParams_ReturnFieldWithSize10()
        {
            var f = FieldGenerator.Generate();

            Assert.NotNull(f);
            Assert.AreEqual(10, f.Size);
        }
Beispiel #19
0
        static void Game()
        {
            Console.Clear();
            Field fieldOne;
            Field fieldTwo;

            if (placementMode == "Automatic")
            {
                fieldOne = FieldGenerator.Generate(size);
                fieldTwo = FieldGenerator.Generate(size);
            }
            else
            {
                if (playMode == "PVE")
                {
                    fieldOne = CreateField("Player 1");
                    fieldTwo = FieldGenerator.Generate(size);
                }
                else
                {
                    fieldOne = CreateField("Player 1");
                    fieldTwo = CreateField("Player 2");
                }
            }

            Play(fieldOne, fieldTwo);
        }
Beispiel #20
0
        /// <summary>
        /// Begins writing the class. Usings, opening namespace, class definition
        /// </summary>
        /// <returns>Always <see langword="true"/></returns>
        public override bool Begin()
        {
            if (_usingGenerator.Make())
            {
                WriteLine();
            }

            _namespaceGenerator.Begin();

            _classDefinitionGenerator.Make();

            OpenBrackets();

            foreach (CSharpField field in _class.Fields)
            {
                var fieldGenerator = new FieldGenerator(field, _writer);
                fieldGenerator.Make();
            }

            // empty newline after fields
            if (_class.Fields.Length > 0)
            {
                WriteLine();
            }

            return(true);
        }
Beispiel #21
0
 // Use this for initialization
 void Start()
 {
     generator        = FindObjectOfType <FieldGenerator>();
     condition        = FindObjectOfType <Conditions>();
     manager          = FindObjectOfType <GameManager>();
     minesCount       = generator.GetMines();
     counterText.text = "Mines left: " + minesCount;
 }
Beispiel #22
0
        public void RandomizeShips_EnterCorrectData_ShipsRandomized()
        {
            var f = FieldGenerator.Generate(15);

            FieldGenerator.RandomizeShips(f);
            var ships = f.Ships.Where(x => x.Size == 3).ToList();

            Assert.AreNotEqual(ships[0].Points.ToList()[0], ships[1].Points.ToList()[0]);
        }
Beispiel #23
0
    void Awake()
    {
        current_phase = Phase.TeamAAct;

        field_generator = FindObjectOfType <FieldGenerator>();
        field_generator.GenerateField(0);
        StartCoroutine(StartRound());
        Utils.DehighlightTiles();
    }
Beispiel #24
0
 public LevelClass(int _winScore, int _turns, int _fieldSize, int ballTypes)
 {
     scoreForWin = _winScore;
     score       = 0;
     //turns = _turns;
     currentStep = _turns;
     fieldSize   = _fieldSize;
     field       = FieldGenerator.InitialFieldGeneration(fieldSize, ballTypes);
 }
Beispiel #25
0
 public Field InitializeSimpleGame(string token_1, string nick_1, string token_2, string nick_2)
 {
     playField = FieldGenerator.GenerateSimpleField(this);
     playField.AddCharacter(1, nick_1);
     playField.AddCharacter(2, nick_2);
     PlayersCharacters.Add(token_1, 1);
     PlayersCharacters.Add(token_2, 2);
     playField.PrepareFieldForStart();
     return(playField);
 }
Beispiel #26
0
    IEnumerator Escape(Collision2D collision)
    {
        yield return(new WaitForSeconds(1.2f));

        if (Math.Abs(gameObject.transform.position.x - collision.transform.position.x) <= 0.55f && _col && Math.Abs(gameObject.transform.position.y - collision.transform.position.y) <= 0.55f)
        {
            FieldGenerator.ChEnemy("Enemies: " + (GameObject.FindGameObjectsWithTag("Enemy").Length - 1));
            Destroy(gameObject);
        }
    }
Beispiel #27
0
        /// <summary>
        /// Set class fields.
        /// </summary>
        /// <param name="fields">A set of wanted fields.</param>
        /// <returns>The current class builder</returns>
        public ClassBuilder WithFields(params Field[] fields)
        {
            _fields.Clear();
            foreach (var field in fields)
            {
                _fields.Add(FieldGenerator.Create(field));
            }

            return(this);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Generator"/> class.
 /// </summary>
 /// <param name="generatorMode">The generator mode.</param>
 private Generator(GeneratorMode generatorMode)
 {
     GeneratorMode       = generatorMode;
     _fieldGenerator     = new FieldGenerator(this);
     _eventGenerator     = new EventGenerator(this);
     _methodGenerator    = new MethodGenerator(this);
     _parameterGenerator = new ParameterGenerator(this);
     _propertyGenerator  = new PropertyGenerator(this);
     _typeNameGenerator  = new TypeNameGenerator(this);
 }
Beispiel #29
0
 private IEnumerable <SelectListItem> GetSelectListUsingPropertyReflection(IEnumerable listValues, string nameProperty, string valueProperty)
 {
     foreach (var item in listValues)
     {
         var name  = item.GetType().GetProperty(nameProperty).GetValue(item, null);
         var value = item.GetType().GetProperty(valueProperty).GetValue(item, null);
         yield return(new SelectListItem {
             Selected = FieldGenerator.IsSelected(value), Value = value.ToString(), Text = name.ToString()
         });
     }
 }
Beispiel #30
0
    // Start is called before the first frame update
    void Start()
    {
        fieldGenerator = GameObject.Find("FieldGenerator").GetComponent <FieldGenerator>();
        yoko           = fieldGenerator.yoko;
        tate           = fieldGenerator.tate;
        width          = Screen.width / yoko;
        footer         = fieldGenerator.footer;

        Hero           = GameObject.Find("Hero");
        heroController = Hero.GetComponent <HeroController>();
    }
        private void RunFieldGeneratorTest(TestCase testCase)
        {
            var            fieldNode    = Helpers.GetFirstNodeOfType <FieldDeclarationSyntax>(testCase.Code);
            FieldGenerator generator    = new FieldGenerator(null);
            var            newFieldNode = generator.Generate(fieldNode, 0);

            foreach (var VarDec in newFieldNode.Declaration.Variables)
            {
                Assert.IsTrue(VarDec.Identifier.ToString().Contains(FieldGenerator.VAR_PREFIX));
            }
        }
Beispiel #32
0
        public void RandomGameTest()
        {
            Console.SetIn(new StringReader(
            @"5
            0 4
            3 1"));

            int expectedMoves = 2;

            int size = UserInterface.ReadSize();

            Field field = new Field(size, size);

            FieldGenerator generator = new FieldGenerator(field, new Random(0));
            generator.Generate();

            Engine engine = new Engine(field);

            engine.OnGameOver += (obj, numberOfMoves) =>
            {
                Assert.AreEqual(expectedMoves, numberOfMoves);
            };

            engine.Run();

            string[] expectedField =
            {
                "-",  "-", "X", "X", "X",
                "X",  "X", "X", "X", "X",
                "X",  "X", "X", "X", "X",
                "X",  "X", "X", "X", "-",
                "X",  "X", "X", "X", "-"
            };

            CollectionAssert.AreEquivalent(expectedField, field.Value);
        }
Beispiel #33
0
	// 레벨 생성 Kazuhisa Minato.
	public void		generateLevel(int seed)
	{
		if(this.levelGenerator == null) {

			this.random_plant = PseudoRandom.get().createPlant("MapCreator", 100);

			// ---------------------------------------------------------------- //

			// 난수 설정을 생성자에서 한다.
			this.levelGenerator = new FieldGenerator (seed);
			
			// 필드 생성방법.
			// 필드의 w, h는 2이상.
			// 블록의 w, h는 5이상 그리고 홀수라는 제한이 있다..
			// 홀수열의 그리드 폭은 제로로 해석할 필요가 있다.
			this.levelGenerator.SetSize (ROOM_ROWS_NUM, ROOM_COLUMNS_NUM, BLOCK_ROWS_NUM, BLOCK_COLUMNS_NUM);

			// 필드를 생성.
			// 각 요소가 블록인 2차원 배열을 생성한다.
			// 따라서 블록(i,j)에는 return_value[i,j]로 액세스 하고.
			// 블록(i,j)안의 요소(u,v)에는 return_value[i,j][u,v]로 액세스한다.
			var	levelData = levelGenerator.CreateField();


			// FieldGenerator 출력을 정렬한다.
			// ・[z, x]		->	[x, z].
			// ・위가 z = 0	->	아래가 z = 0.

			this.level_data = new FieldGenerator.ChipType[ROOM_COLUMNS_NUM, ROOM_ROWS_NUM][,];

			foreach(var ri in Map.RoomIndex.getRange(ROOM_COLUMNS_NUM, ROOM_ROWS_NUM)) {

				this.level_data[ri.x, ri.z] = new FieldGenerator.ChipType[BLOCK_COLUMNS_NUM, BLOCK_ROWS_NUM];

				foreach(var bi in Map.BlockIndex.getRange(this.block_columns_num, this.block_rows_num)) {

					this.level_data[ri.x, ri.z][bi.x, bi.z] = levelData[ROOM_ROWS_NUM - 1 - ri.z, ri.x][BLOCK_ROWS_NUM - 1 - bi.z, bi.x];
				}
			}

			// 시작, 목표.

			var ep = levelGenerator.GetEndPoints(levelData);

			this.start.room_index.x  = ep[0].fieldWidth;
			this.start.room_index.z  = ROOM_ROWS_NUM - 1 - ep[0].fieldHeight;
			this.start.block_index.x = (ep[0].blockWidth - 1)/2;
			this.start.block_index.z = this.block_grid_rows_num - 1 - (ep[0].blockHeight - 1)/2;

			this.goal.room_index.x  = ep[1].fieldWidth;
			this.goal.room_index.z  = ROOM_ROWS_NUM - 1 - ep[1].fieldHeight;
			this.goal.block_index.x = (ep[1].blockWidth - 1)/2;
			this.goal.block_index.z = this.block_grid_rows_num - 1 - (ep[1].blockHeight - 1)/2;

			//

			// ---------------------------------------------------------------- //

			// 방을 만든다.

			this.floor_root_go = new GameObject("Floor");

			foreach(var room_index in Map.RoomIndex.getRange(ROOM_COLUMNS_NUM, ROOM_ROWS_NUM)) {

				this.createRoom(room_index);
			}

			// 더미인 방.
			// (플로어의 가장 아래 열).
			for(int i = 0;i < ROOM_COLUMNS_NUM;i++) {

				this.createVacancy(new Map.RoomIndex(i, -1));
			}

			// 방 칸막이 생성.
			this.createRoomWall();

			this.createOuterWalls();


			// ---------------------------------------------------------------- //
			// 플로어 위에 둘 것(문, 아이템 등) 정보를 만들어 둔다.

			// 방 이동 문.
	
			this.block_infos = new MapCreator.BlockInfo[ROOM_COLUMNS_NUM, ROOM_ROWS_NUM][,];

			foreach(var ri in Map.RoomIndex.getRange(ROOM_COLUMNS_NUM, ROOM_ROWS_NUM)) {

				this.block_infos[ri.x, ri.z] = new BlockInfo[this.block_grid_columns_num, this.block_grid_rows_num];

				var		block_info_room = this.block_infos[ri.x, ri.z];
				var		level_data_room = this.level_data[ri.x, ri.z];

				foreach(var bi in Map.BlockIndex.getRange(this.block_grid_columns_num, this.block_grid_rows_num)) {

					block_info_room[bi.x, bi.z].chip = Map.CHIP.VACANT;

					if(level_data_room[bi.x*2 + 1 - 1, bi.z*2 + 1] == FieldGenerator.ChipType.Door) {

						block_info_room[bi.x, bi.z].chip    = Map.CHIP.DOOR;
						block_info_room[bi.x, bi.z].option0 = (int)Map.EWSN.WEST;

					} else if(level_data_room[bi.x*2 + 1 + 1, bi.z*2 + 1] == FieldGenerator.ChipType.Door) {

						block_info_room[bi.x, bi.z].chip    = Map.CHIP.DOOR;
						block_info_room[bi.x, bi.z].option0 = (int)Map.EWSN.EAST;

					} else if(level_data_room[bi.x*2 + 1, bi.z*2 + 1 - 1] == FieldGenerator.ChipType.Door) {

						block_info_room[bi.x, bi.z].chip    = Map.CHIP.DOOR;
						block_info_room[bi.x, bi.z].option0 = (int)Map.EWSN.SOUTH;

					} else if(level_data_room[bi.x*2 + 1, bi.z*2 + 1 + 1] == FieldGenerator.ChipType.Door) {

						block_info_room[bi.x, bi.z].chip    = Map.CHIP.DOOR;
						block_info_room[bi.x, bi.z].option0 = (int)Map.EWSN.NORTH;
					}
				}
			}

			// 플로어 이동 문.

			this.block_infos[this.start.room_index.x, this.start.room_index.z][this.start.block_index.x, this.start.block_index.z].chip    = Map.CHIP.STAIRS;
			this.block_infos[this.start.room_index.x, this.start.room_index.z][this.start.block_index.x, this.start.block_index.z].option0 = 0;
			this.block_infos[this.goal.room_index.x,   this.goal.room_index.z][this.goal.block_index.x,   this.goal.block_index.z].chip    = Map.CHIP.STAIRS;
			this.block_infos[this.goal.room_index.x,   this.goal.room_index.z][this.goal.block_index.x,   this.goal.block_index.z].option0 = 1;

			foreach(var ri in Map.RoomIndex.getRange(ROOM_COLUMNS_NUM, ROOM_ROWS_NUM)) {

				var		info_room = this.block_infos[ri.x, ri.z];

				RoomController	room = this.get_room_root_go(ri);

				List<Map.BlockIndex>	reserves = new List<Map.BlockIndex>();

				// ジェネレーター.
				for(int i = 0;i < 3;i++) {

					var		lair_places = this.allocateChipPlacesRoom(ri, Map.CHIP.LAIR, 1);

					if(lair_places.Count == 0) {

						break;
					}

					// 제네레이터가 이웃한 블록에 나오지 않게.
					// 주위 8블록을 예약해 둔다.

					Map.BlockIndex	bi = lair_places[0];

					foreach(var around in bi.getArounds8()) {

						if(this.allocateChipPlaceRoom(ri, around, Map.CHIP.LAIR)) {
	
							reserves.Add(around);
						}
					}
				}

				// 예약한 블록을 반환한다.
				foreach(var reserve in reserves) {

					this.putbackChipPlaceRoom(ri, reserve);
				}

				// 방 이동 열쇠.

				var		key_places = this.allocateChipPlacesRoom(ri, Map.CHIP.KEY, room.getDoorCount());

				for(int i = 0;i < key_places.Count;i++) {

					Map.BlockIndex	place = key_places[i];

					info_room[place.x, place.z].option0 = (int)room.getDoorByIndex(i).KeyType;
				}
			}

			// 플로어 이동 문의 열쇠.

			bool	floor_key_created = false;

			for(int i = 0;i < ROOM_COLUMNS_NUM*ROOM_ROWS_NUM;i++) {

				Map.RoomIndex	ri = new Map.RoomIndex();

				ri.x = this.random_plant.getRandomInt(ROOM_COLUMNS_NUM);
				ri.z = this.random_plant.getRandomInt(ROOM_ROWS_NUM);

				var floor_key_places = this.allocateChipPlacesRoom(ri, Map.CHIP.KEY, 1);

				if(floor_key_places.Count == 0) {

					continue;
				}

				this.block_infos[ri.x, ri.z][floor_key_places[0].x, floor_key_places[0].z].option0 = (int)Item.KEY_COLOR.PURPLE;

				floor_key_created = true;
				break;
			}
			if(!floor_key_created) {

				Debug.LogError("can't create floor key.");
			}

			// ---------------------------------------------------------------- //

		}
	}