private void OnMouseDown() { if (!_flag) { _flag = true; GetComponent <Text>().text = ""; StartButton.GetComponent <ScrollButtons>().Speed = -1f; StartButton.GetComponent <ScrollButtons>().CheckPos = -160f; Sphere.GetComponent <Animation>().Play("StartGame"); StartCoroutine(RespawnFigure()); StartCoroutine(SphereAddRigidbody()); InvokeRepeating("ScoreIncrement", 0, 1f); } IEnumerator RespawnFigure() { yield return(new WaitForSeconds(1f)); SpawnBlocks.GetComponent <SpawnBlocks>().enabled = true; } IEnumerator SphereAddRigidbody() { yield return(new WaitForSeconds(Sphere.GetComponent <Animation>().clip.length + 1f)); Sphere.AddComponent <Rigidbody>(); Sphere.GetComponent <Rigidbody>().drag = 6f; ControlButtons.SetActive(true); //Делаем активными кнопки управления Sphere.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionZ; //Добавляем Rigidbody здесь чтобы отыграла анимация подъема Sphere.GetComponent <SphereMove>().enabled = true; //включаем управление чтобы не ругался на отсутствие Rigidbody } }
// Use this for initialization void Start() { gameManagerGO = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>(); sb = GameObject.Find("Blocks Spawner").GetComponent <SpawnBlocks>(); shieldHitCount = 0; timeSinceLastCollision = Time.time; }
private IEnumerator GetFirstBlockDelay() { yield return(new WaitForSeconds(0.05f)); spawnBlocks = GameObject.Find("Spawn").GetComponent <SpawnBlocks>(); tetris_block = spawnBlocks.newBlock; movement = tetris_block.GetComponent <Movement>(); rotation = tetris_block.GetComponent <Rotation>(); block = tetris_block.GetComponent <Block>(); }
private void Start() { EventManager.AddPointsListener(AddPoints); //initial number of blocks instantiated spawnBlocks = GetComponent <SpawnBlocks>(); currentNumberOfBlocks = spawnBlocks.NumberOfBlocksInGame; //register as block reduce blocks left event EventManager.AddReduceBlockListener(ReduceBlockFromCurrentNumberOfBlocks); }
IEnumerator DeleteCubes() { for (int i = 0; i < 3; i++) { yield return(new WaitForSeconds(0.3f)); AllCubes[i].GetComponent <DestroyCubeInStartGame>().enabled = true; } SpawnBlocks.GetComponent <SpawnBlocks>().enabled = true; GetComponent <CubeJump>().enabled = true; }
// void Start() { //Mobile dragDistance = Screen.height * 5 / 100; //dragDistance is 5% height of the screen // scoreAndLevel = GameObject.FindGameObjectWithTag("Level").GetComponent <ScoreAndLevel>(); level = GameObject.FindGameObjectWithTag("Level").GetComponent <TetrisLevel>(); spawn = transform.parent.GetComponent <SpawnBlocks>(); moveSpeed = level.moveTime; }
public void destroyAllBlocks() { lefthand.StopGrabbing(); righthand.StopGrabbing(); blocks = SpawnBlocks.GetSpawnedBlocks(); foreach (GameObject i in blocks) { if (i != null) { i.layer = 0; } } InvokeRepeating("destroyBlock", 0, 0.1f); }
private void OnMouseDown() { if (clicked) { return; } clicked = true; playTxt.gameObject.SetActive(false); gameName.text = "0"; buttons.GetComponent <ScrollObjects>().speed = -5f; buttons.GetComponent <ScrollObjects>().checkPos = -150f; m_cube.GetComponent <Animation>().Play("StartGameCube"); block.GetComponent <Animation>().Play("ReturnBLock"); SpawnBlocks.GetComponent <SpawnBlocks>().enabled = true; m_cube.AddComponent <Rigidbody>(); }
void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.tag == "Ball" && !isHitted) { SpawnBlocks.BlockHit(); collision.gameObject.GetComponent <BallPhysics>().Bounce(isMetal, transform.position.x, GetComponent <SpriteRenderer>().bounds.size.x / 2); ScoreController.incrementScore(score); isHitted = true; // Kill block only if its not metal if (!isMetal) { Kill(); } else { StartCoroutine(ResetHit(0.2f)); } } }
void OnTriggerEnter(Collider collider) { //if block hits the divider and drops, destroy it if (collider.gameObject == spawnblocks && hitDivider) { blocks = SpawnBlocks.GetSpawnedBlocks(); GameObject block = gameObject; Destroy(block); blocks.Remove(block); } //if block hits the goal side, change color and increment score else if (collider.gameObject == goalSide) { gameObject.GetComponent <MeshRenderer>().material = startMat; //Debug.Log("sta" + startMat.name); if (startMat.name == "BlueMat (Instance)") { achievement.GetComponent <Achievements>().blue++; } else if (startMat == colors[1]) { achievement.GetComponent <Achievements>().red++; } else { achievement.GetComponent <Achievements>().green++; } counttext.GetComponent <CountUp>().incrementCount(); //spawnblocks.GetComponent<SpawnBlocks>().DecrementBlocks(); } //if block drops back into start side, reset its layer to left/right grabbable else if (collider.gameObject == spawnblocks) { gameObject.layer = startLayer; gameObject.GetComponent <MeshRenderer>().material = startMat; } }
// Use this for initialization void Start() { laser = Instantiate(laserPrefab); laserTransform = laser.transform; spawnBlocks = blockSpawner.GetComponent <SpawnBlocks>(); }
// Start is called before the first frame update void Start() { sb = GameObject.FindGameObjectWithTag("Player").GetComponent <SpawnBlocks>(); }
void Start() { spawnBlocks = BlockSpawner.GetComponent <SpawnBlocks>(); }