GameObject GenerateNextBlock(int index, GameObject currentBlock) { GameBlock block = MessageSystemGameBlock.ReturnDisactiveGameObject(index); GameObject newBlock = block.GetGameObject(); BoxCollider2D curBox = currentBlock.GetComponent <BoxCollider2D>(); float offset = 0; if (newBlock.name == "Barrier_Grey" || newBlock.name == "Portal_Grey") { Storage.CountTripleBlock = 3; } if (block.Extents != -1) { offset = curBox.bounds.extents.x + block.Extents; } else { GenerateNextEarth(currentBlock); Storage.CountBlockEarth++; } newBlock.transform.position = new Vector3(curBox.bounds.center.x + offset, newBlock.transform.position.y, newBlock.transform.position.z); MessageSystemGameBlock.SetupParent(newBlock, false); block.SetActiveFull(true); if (Storage.CountTripleBlock != 0) { Storage.CountTripleBlock--; } return(newBlock); }
void GenerateNextBlock(GameObject currentBlock, out GameObject returnBlock) { int i = groupBlock[numberGroup].Length - countRemainingBlock; int blockValue = groupBlock[numberGroup][i]; int indexNextBlock = blockValue / 100; Storage.CountBlockEarth = blockValue % 10; int index = (blockValue / 10) % 10; GameBlock block = MessageSystemGameBlock.ReturnBlockFromGroup(indexNextBlock, index); GameObject newBlock = block.GetGameObject(); BoxCollider2D curBox = currentBlock.GetComponent <BoxCollider2D>(); float offset = 0; if (block.Extents != -1) { offset = curBox.bounds.extents.x + block.Extents; } else { GenerateNextEarth(currentBlock); Storage.CountBlockEarth++; } newBlock.transform.position = new Vector3(curBox.bounds.center.x + offset, newBlock.transform.position.y, newBlock.transform.position.z); MessageSystemGameBlock.SetupParent(newBlock, false); block.SetActiveFull(true); returnBlock = newBlock; }
protected GameObject GenerateNextEarth(GameObject currentBlock) { Storage.CountBlockEarth--; GameBlock block = MessageSystemGameBlock.ReturnDisactiveDownEarth(); GameObject newBlock = block.GetGameObject(); block.SetActiveFull(true); float deltaMinus = -0.065f; BoxCollider2D curBox = currentBlock.GetComponent <BoxCollider2D>(); BoxCollider2D newBox = newBlock.GetComponent <BoxCollider2D>(); float delta = curBox.bounds.extents.x + newBox.bounds.extents.x + deltaMinus; newBlock.transform.position = new Vector3(curBox.bounds.center.x + delta, newBlock.transform.position.y, newBlock.transform.position.z); MessageSystemGameBlock.SetupParent(newBlock, false); return(newBlock); }
void GenerateNextBlock(GameObject currentBlock, out GameObject returnBlock) { int index = 1; GameBlock block = new GameBlock(); for (int i = 0; i < 3; i++) { Randomizer(ref index); block = MessageSystemGameBlock.ReturnUnusedGameBlock(index); if (block.GetGameObject() != null) { selectedBlock[index - 1] = true; StartCoroutine(PreparingPercent(index)); break; } if (i == 2) { returnBlock = GenerateNextEarth(currentBlock); Storage.CountBlockEarth = 0; return; } } block.CountUsing++; GameObject newBlock = block.GetGameObject(); BoxCollider2D curBox = currentBlock.GetComponent <BoxCollider2D>(); float offset = 0; if (block.Extents != -1) { offset = curBox.bounds.extents.x + block.Extents; } else { GenerateNextEarth(currentBlock); Storage.CountBlockEarth++; } newBlock.transform.position = new Vector3(curBox.bounds.center.x + offset, newBlock.transform.position.y, newBlock.transform.position.z); MessageSystemGameBlock.SetupParent(newBlock, false); block.SetActiveFull(true); returnBlock = newBlock; }
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); }