static int IncreezeDinamicGameBlock(int index, GameObject gameBlock) { GameBlock[] block = DinamicGameBlock[index]; if (block[block.Length - 1].GetGameObject() != null) { int lenght = DinamicGameBlock[index].Length; DinamicGameBlock[index] = new GameBlock[lenght * 2]; block.CopyTo(DinamicGameBlock[index], 0); for (int i = block.Length; i < DinamicGameBlock[index].Length; i++) { DinamicGameBlock[index][i] = new GameBlock(); } } if (gameBlock == null) { gameBlock = reserve; } GameObject obj = Instantiate(gameBlock, gameBlock.transform) as GameObject; int j; for (j = 0; j < DinamicGameBlock[index].Length; j++) { if (DinamicGameBlock[index][j].GetGameObject() == null) { break; } } GameBlock newBlock = DinamicGameBlock[index][j]; newBlock.SetValue(obj, index); newBlock.CalculateDelta(); newBlock.SetActiveFull(false); newBlock.Name = gameBlock.name; newBlock.GetGameObject().transform.SetParent(canvasGameBlock.transform); CopyRecTransform(newBlock.GetGameObject().GetComponent <RectTransform>(), DinamicGameBlock[index][0].GetGameObject().GetComponent <RectTransform>()); return(j); }
private void Start() { indexWatch = 1; reserve = GameObject.Find("Game'sBlock/Reserve/Portal_Grey"); backgroundParent = GameObject.Find("Background/BackgroundParent"); parentUp = GameObject.Find("Game'sBlock/MainParent/ParentUp"); parentDown = GameObject.Find("Game'sBlock/MainParent/ParentDown"); canvasGameBlock = GameObject.Find("Game'sBlock"); mainRigid = mainParent.GetComponent <Rigidbody2D>(); backRigid = backgroundParent.GetComponent <Rigidbody2D>(); DinamicGameBlock[0] = new GameBlock[countBlocks[0]]; //Earth DinamicGameBlock[1] = new GameBlock[countBlocks[3]]; //Cube DinamicGameBlock[2] = new GameBlock[countBlocks[1]]; //Barrier DinamicGameBlock[3] = new GameBlock[countBlocks[1]]; //Portal DinamicGameBlock[4] = new GameBlock[countBlocks[3]]; //Abyss DinamicGameBlock[5] = new GameBlock[countBlocks[3]]; //Blade DinamicGameBlock[6] = new GameBlock[countBlocks[3]]; //Speedy DinamicGameBlock[7] = new GameBlock[countBlocks[3]]; //Saw DinamicGameBlock[8] = new GameBlock[countBlocks[3]]; //Needles DinamicGameBlock[9] = new GameBlock[countBlocks[2]]; //Enemy#1 DinamicGameBlock[10] = new GameBlock[countBlocks[2]]; //Robot for (int i = 0; i < size; i++) { for (int j = 0; j < DinamicGameBlock[i].Length; j++) { DinamicGameBlock[i][j] = new GameBlock(); } } for (int i = 0; i < Earth.Length; i++) { DinamicGameBlock[0][i].SetValue(Earth[i], 0); DinamicGameBlock[0][i].SetActive(true); } for (int i = 1, j = 0; i < size; i++, j++) { Instance(i, 0, j, StaticGameBlock); } for (int i = 0; i < 8; i++) { Earth[i].transform.SetParent(parentUp.transform); } for (int i = 8; i < Earth.Length; i++)// без 8 блока { Earth[i].transform.SetParent(parentDown.transform); } for (int i = 16; i < Earth.Length; i++) { DinamicGameBlock[0][i].SetActiveFull(false); } Instance(3, 1, 0, Buffer); Instance(3, 2, 1, Buffer); Instance(2, 1, 2, Buffer); Instance(2, 2, 3, Buffer); Instance(1, 1, 4, Buffer); for (int i = 5; i < 10; i++) { Instance(i - 1, 1, i, Buffer); } reserveBlock.SetValue(reserve, 0); reserveBlock.CalculateDelta(); property = new Property[5]; property[0] = new Property(ReturnDisactiveGameObject); property[1] = new Property(Any); property[2] = new Property(SamePrevious); property[3] = new Property(AnyBesidePrevious); property[4] = new Property(SamePreviousTwo); stopWatch[0] = () => { gameTime += Time.deltaTime; }; stopWatch[1] = () => { }; }