private void Update() { if (Input.anyKey) { EventsObserver.Publish(new StopTimeEvent(false)); } }
private static void ChangeScore(int scoreValue) { score += scoreValue; SetHighestScore(); EventsObserver.Publish(new ChangeScoreEvent(score, highestScore)); }
public void PlayerDamage() { _playerHealth -= 1; if (_playerHealth <= 0) { EventsObserver.Publish(new PlayerDeathEvent()); } }
public void ChangeScoreTest(int lineCount, string expectedResult) { EventsObserver.Publish(new IStartGameplayEvent()); var scoremanager = Container.Resolve <IScoreManager>(); var settings = Container.Resolve <ScoreManager.Settings>(); var scoreValueLabel = GameObject.Find("ScoreValueText").GetComponent <TextMeshProUGUI>(); settings._lineScore = 100; settings._lineScoreMultiplier = 1.2f; scoremanager.AddLineScore(lineCount); Assert.AreEqual(expectedResult, scoreValueLabel.text); }
public void SetTarget(GameObject shape, float normalSpeed, float fastSpeed) { _normalTransitionInterval = normalSpeed; _fastTransitionInterval = fastSpeed; _shape = shape; currentTransitionInterval = _normalTransitionInterval; _rotationPivot = _shape.transform.Find("Pivot"); if (!_gridManager.IsValidGridPosition(_shape.transform)) { EventsObserver.Publish(new IEndGameEvent()); GameObject.Destroy(_shape.gameObject); } }
public void AddLineScore(int linesCount) { if (linesCount == 1) { _score += _settings._lineScore; } else { _score += (int)(_settings._lineScore * linesCount * _settings._lineScoreMultiplier); } _lines += linesCount; EventsObserver.Publish(new IUpdateScoreEvent(_score, _lines)); }
public void MoveHorizontal(Vector3 direction) { if (_shape == null) { return; } _shape.transform.position += direction; if (_gridManager.IsValidGridPosition(_shape.transform)) { _gridManager.UpdateGrid(_shape.transform); EventsObserver.Publish(new IPlaySoundEvent("Move")); } else { _shape.transform.position -= direction; } }
public void RotateShape(bool isClockwise) { if (_shape == null) { return; } float rotationDegree = isClockwise ? 90.0f : -90.0f; _shape.transform.RotateAround(_rotationPivot.position, Vector3.forward, rotationDegree); if (_gridManager.IsValidGridPosition(_shape.transform)) { _gridManager.UpdateGrid(_shape.transform); EventsObserver.Publish(new IPlaySoundEvent("Rotate")); } else { _shape.transform.RotateAround(_rotationPivot.position, Vector3.forward, -rotationDegree); } }
private void DeleteRows() { var fullRowsCount = 0; for (int y = 0; y < _settings.TransformsYCount; y++) { if (IsRowFull(y)) { DeleteRow(y); DecreaseRowsAbove(y + 1); y--; fullRowsCount++; } } if (fullRowsCount > 0) { _scoreManager.AddLineScore(fullRowsCount); EventsObserver.Publish(new IPlaySoundEvent("Drop")); } EventsObserver.Publish(new ISpawnEvent()); }
private static void AddAvoidedAsteroids() { avoidedAsteroids += 1; EventsObserver.Publish(new AvoidAsteroidEvent(avoidedAsteroids)); }
public void RestartGame() { EventsObserver.Publish(new IRestartGameEvent()); EventsObserver.Publish(new IPlaySoundEvent("Newgame")); }
private void StartGame() { EventsObserver.Publish(new IStartGameplayEvent()); EventsObserver.Publish(new IPlaySoundEvent("Newgame")); }
private void PublishBoostEvent() { _boosted = !_boosted; EventsObserver.Publish(new PlayerBoostEvent(_boosted)); }
private void EndGameSession(PlayerDeathEvent e) { DataSaver.SaveData(); EventsObserver.Publish(new StopTimeEvent(true)); }
private void Start() { EventsObserver.Publish(new IPlaySoundEvent("Background")); }
public void ResetScore() { _score = 0; _lines = 0; EventsObserver.Publish(new IUpdateScoreEvent(_score, _lines)); }
public void CalculateTime() { ScoreManager.ChangeGameTime(); EventsObserver.Publish(new ChangeGameTimeEvent()); }
private void Unpause() { EventsObserver.Publish(new IPauseEvent(false)); EventsObserver.Publish(new IPlaySoundEvent("Resume")); }
private void StartGameListener(IStartGameplayEvent e) { SetState(_gameplayState); EventsObserver.Publish(new ISpawnEvent()); }
private void Start() { EventsObserver.Publish(new StopTimeEvent(true)); StartCoroutine(ScoreAdder()); }