private void SetExplodeState() { _tetrominoState = TetrominoState.Exploding; //first start fall, then explode after some time rb2D.constraints = RigidbodyConstraints2D.FreezeRotation; rb2D.gravityScale = 1f; Explode(); }
public void SetTetrominoState(TetrominoState state) { switch (state) { case TetrominoState.FallingClassic: SetFalingClassicState(); break; case TetrominoState.FallingPhysics: SetFallingPhysicsState(); break; case TetrominoState.PernamentlySnapped: SetPernamentlySnappedState(); break; case TetrominoState.Exploding: SetExplodeState(); break; case TetrominoState.Frozen: SetFrozenState(); break; default: throw new ArgumentOutOfRangeException(nameof(state), state, null); } }
void FixedUpdate() { // Checking current spawn interval time //Debug.Log("Current spawn time: " + _tetrinoSpawnTimer.IntervalBetweenSpawn); // Should we pop the next tetromino from the queue? if (_tetrinoSpawnTimer.ShouldPop) { GameObject go = _tetrinoSelector.Pop(); // I think we should :) tetrominoState = go.GetComponent<TetrominoState>(); tetrominoState.setState(TetrominoState.states.ACTIVE); Instantiate(go, transform.position, transform.rotation); // Pop goes the weasle! _tetrinoSpawnTimer.ShouldPop = false; // Stop da pop } // Apply modifier to rate if the interval between spawn is longer than 1 second, we have not lost yet, and if its time to update... // 1 second is the minimum amount of time between spawns // Afterwhich, we no longer decrease time if (_tetrinoSpawnTimer.CurrentTime > _nextIntervalDecreaseTime && _tetrinoSpawnTimer.IntervalBetweenSpawn > _minTimeBetweenSpawns && !_classicModeState.InLoseState) { ApplyDifficultyModifierToTimer(); _scoreManager.SetScoreToAdd(_scoreManager.ScoreToAdd + 100f); //Debug.Log("Spawn timer current time: " + _tetrinoSpawnTimer.CurrentTime); //Debug.Log ("Spawn timer interval between spawn: " + _tetrinoSpawnTimer.IntervalBetweenSpawn); } // We can do something similar here for applying a faster falling speed for the tetrominoes }
public void MoveInvalid(MoveInvalidEvent e) { if (e.Direction == MoveDirection.Down) { State = TetrominoState.landed; Destroy(PlayerInputListener); StopListeningForMovementEvents(); EventManager.Instance.TriggerEvent(new TetrominoLandedEvent()); } }
// Use this for initialization void Awake() { SetRandomColor(); State = TetrominoState.falling; GridManager = FindObjectOfType <GridManager> (); // Setup Input Listener PlayerInputListener = gameObject.AddComponent <PlayerInputListener> (); StartListeningForMovementEvents(); }
// Update is called once per frame void FixedUpdate() { if (tetrominoState == null) { tetrominoState = transform.gameObject.GetComponent<TetrominoState>(); } float rotateDirection = 0.0f; if (tetrominoState.getState() == TetrominoState.states.GRABBED) { if (Input.GetKey(KeyCode.LeftArrow)) rotateDirection = -1.0f; else if (Input.GetKey(KeyCode.RightArrow)) rotateDirection = 1.0f; transform.RotateAround(curPosition, Vector3.back, rotateSpeed * Time.deltaTime * rotateDirection); } if (isLeapMenuTet && transform.position.y < -10F) { transform.position = initPosition; transform.localEulerAngles = initRotation; } }
/** * @method setState * @param {TetrominoState.states} newState - The state that the tetromino should be set to. Possible values are: * TetrominoState.ACTIVE * TetrominoState.INACTIVE * TetrominoState.QUEUED * TetrominoState.GRABBED */ public void setState(TetrominoState.states newState) { state = newState; }
private void SetFrozenState() { _tetrominoState = TetrominoState.Frozen; rb2D.constraints = RigidbodyConstraints2D.FreezeAll; }
private void SetPernamentlySnappedState() { SnapTetrominoToGrid(true); _tetrominoState = TetrominoState.PernamentlySnapped; rb2D.constraints = RigidbodyConstraints2D.FreezeAll; }
private void SetFallingPhysicsState() { _tetrominoState = TetrominoState.FallingPhysics; rb2D.constraints = RigidbodyConstraints2D.FreezeRotation; rb2D.gravityScale = 1f; }
private void SetFalingClassicState() { _tetrominoState = TetrominoState.FallingClassic; rb2D.gravityScale = 0f; }