void Update() { Vector2Int objectPosition = VectorTransformer.Vector3ToVector2Int(transform.position); Vector2Int downPosition = VectorTransformer.Vector2IntDown(objectPosition); if (!_fallControl) { _fallControl = true; StartCoroutine(WaitFall(objectPosition, downPosition)); } if (!_gridController.CellIsEmptyWithoutCharacter(downPosition)) { _startFallFrom = objectPosition; } //Se o objeto abaixo deste é Slider e na posição do lado e lado baixo estão vazias a pedra escorrega if (_gridController.HasGridObjectAt(downPosition)) { Transform downObject = _gridController.GetObject(downPosition); if (downObject.CompareTag("SlideObject") || downObject.CompareTag("Rock"))//verifica se o de baixo é slider { if (!_gridController.HasNextFreeSpace(objectPosition, Direction.Down)) { Vector2Int leftPosition = VectorTransformer.Vector2IntLeft(objectPosition); if (_gridController.CellIsEmpty(leftPosition)) //Verifica lado esquerdo { if (_gridController.CellIsEmpty(VectorTransformer.Vector2IntDown(leftPosition))) //Verifica esquerdo baixo { //Desliza StartCoroutine(WaitSlide(objectPosition, leftPosition)); return; } } Vector2Int rightPosition = VectorTransformer.Vector2IntRight(objectPosition); //Verifica lado direito if (_gridController.CellIsEmpty(rightPosition)) { if (_gridController.CellIsEmpty(VectorTransformer.Vector2IntDown(rightPosition))) //Verifica direita baixo { //Desliza StartCoroutine(WaitSlide(objectPosition, rightPosition)); return; } } } } } if (_gridController.characterPosition.Equals(downPosition)) { if (!_startFallFrom.Equals(VectorTransformer.NullPoint) & _startFallFrom.y > _gridController.characterPosition.y + 1) { _gridController.character.GetComponent <Lose>().StageLose(); } } }
// Update is called once per frame void Update() { Vector2Int objectPosition = VectorTransformer.Vector3ToVector2Int(transform.position); Debug.Log(objectPosition + "-" + Time.frameCount); Vector2Int downPosition = VectorTransformer.Vector2IntDown(objectPosition); if (_gridController.CellIsEmpty(downPosition)) { if (!_isFalling & _downReallyFree) { if (!AlreadyFallTo(downPosition)) { _isFalling = true; Debug.Log("Fall" + "-" + Time.frameCount); //Debug.Log(transform.name + ": " + "_isFalling: " + _isFalling); StartCoroutine(WaitFall(objectPosition, downPosition)); //Debug.Log(_gridController.HasGridObjectAt(downPosition)); //Debug.Log("Fall" + "-" + Time.frameCount); _startFallFrom = objectPosition; } } } //Se o objeto abaixo deste é Slider e na posição do lado e lado baixo estão vazias a pedra escorrega else if (_gridController.HasGridObjectAt(downPosition)) { //verifica se o de baixo é slider Transform downObject = _gridController.GetObject(downPosition); if (downObject.tag.Equals("SlideObject")) { if (_gridController.CellIsEmpty(VectorTransformer.Vector2IntDown(downPosition))) { _downReallyFree = false; StartCoroutine(WaitHalfSecond()); return; } //Verifica lado esquerdo Vector2Int leftPosition = VectorTransformer.Vector2IntLeft(objectPosition); if (_gridController.CellIsEmpty(leftPosition)) { //Verifica esquerdo baixo if (_gridController.CellIsEmpty(VectorTransformer.Vector2IntDown(leftPosition))) { //Desliza StartCoroutine(WaitSlide(objectPosition, leftPosition)); return; } } //Verifica lado direito Vector2Int rightPosition = VectorTransformer.Vector2IntRight(objectPosition); if (_gridController.CellIsEmpty(rightPosition)) { //Verifica direita baixo if (_gridController.CellIsEmpty(VectorTransformer.Vector2IntDown(rightPosition))) { //Desliza StartCoroutine(WaitSlide(objectPosition, rightPosition)); return; } } } } }