// Start is called before the first frame update void Start() { _timeNextLeftKey = Time.time + _timeRepeatRateLeftKey; _timeNextRightKey = Time.time + _timeRepeatRateRightKey; _timeNextDownKey = Time.time + _timeRepeatRateDownKey; _timeNextRotateKey = Time.time + _timeRepeatRateRotateKey; _dropTimeInterval = _timeInterval; _backgroundGrid = FindObjectOfType <BrickTetris_BackgroundGrid>(); if (!_backgroundGrid) { Debug.Log("not assign object"); } _spawner = FindObjectOfType <BrickTetris_Spawner>(); if (!_spawner) { Debug.Log("not assign object"); } else { _spawner.transform.position = BrickTetris_Vectorf.Round(_spawner.transform.position); if (!_activeShape) { _activeShape = _spawner.SpawnShape(); } } _audioManager = FindObjectOfType <BrickTetris_AudioManager>(); if (!_audioManager) { Debug.Log("not assign object"); } _scoreController = FindObjectOfType <BrickTetris_ScoreController>(); if (!_scoreController) { Debug.Log("not assign object"); } _animator = GetComponent <Animator>(); if (!_animator) { Debug.Log("not assign object"); } if (_pausePanel) { _pausePanel.SetActive(false); } }
public void StoreShapeInGrid(BrickTetris_BrickShape shape) { if (shape == null) { return; } foreach (Transform child in shape.transform) { Vector2 position = BrickTetris_Vectorf.Round(child.position); _grid[(int)position.x, (int)position.y] = child; } }
public bool IsValidPosition(BrickTetris_BrickShape shape) { foreach (Transform child in shape.transform) { Vector2 position = BrickTetris_Vectorf.Round(child.position); if (!IsInGrid((int)position.x, (int)position.y)) { return(false); } if (IsValidOccupied((int)position.x, (int)position.y, shape)) { return(false); } } return(true); }