static void Main(string[] args) { // Task 2.1.1 /*char[] arr = { 'd', 'e', 'f' }; * CustomString cs1 = new CustomString("abc"); * CustomString cs2 = new CustomString(arr); * cs1.Append(cs2); * cs1.Append("ghi"); * Console.WriteLine("ToString: {0}",cs1.ToString()); * Console.WriteLine("ConvertToArray[0]: {0}", cs1.ConvertToArray()[0]); * Console.WriteLine("Compare: {0}", cs1.Compare(cs2)); * Console.WriteLine("Length: {0}", cs1.Length); */ // Task 2.1.2 Figure[] figures = new Figure[100]; int count = 0; CreateFigure createfigure = new CreateFigure(); while (true) { string str; Console.WriteLine(" Выберите действие\n1.Добавить фигуру\n2.Вывести фигуры\n3.Очистить холст\n4.Выход"); str = Console.ReadLine(); if (str == "4") { break; } switch (str) { case "1": Console.WriteLine("\nВведите название фигуры\n"); Figure figure = createfigure.Create(ReadFigureType()); figures[count] = figure; count++; break; case "2": if (count == 0) { Console.WriteLine("\nФигур нет\n"); break; } for (int i = 0; i < count; i++) { Console.WriteLine('\n' + figures[i].ToString() + '\n'); } break; case "3": figures = new Figure[100]; count = 0; break; } } }
//спавнит фигуры public void SpawnFigure() { switch (_counter) { case 0: _columnNum = 1; _counter++; break; case 1: _columnNum = 3; _counter++; break; case 2: _columnNum = 5; _counter = 0; break; } CreateFigure RandomFigure = _blockPatterns[Random.Range(0, _blockPatterns.Length)]; for (int i = 0; i < RandomFigure.SingleBlocks.Length; i++) { for (int j = 0; j < _singleBlockPool.Length; j++) { if (_singleBlockPool[j] != null) { _blocksGameObjects[i] = _singleBlockPool[j]; _singleBlockPool[j] = null; break; } } _spawnPosition = _spawnPoints[RandomFigure.SingleBlocks[i].YCordinat, _columnNum + RandomFigure.SingleBlocks[i].XCordinat]; _blocksGameObjects[i].transform.position = _spawnPosition; _singleBlockForActivation = _blocksGameObjects[i].GetComponent <SingleBlock>(); _singleBlockForActivation.ActivateBlockForSpawn(); //_blocksGameObjects[i] = Instantiate(_singleBlockPrefab, _spawnPoints[RandomFigure.SingleBlocks[i].YCordinat, _columnNum + RandomFigure.SingleBlocks[i].XCordinat],Quaternion.identity); } }