private void Update()
 {
     if (Input.anyKey)
     {
         EventsObserver.Publish(new StopTimeEvent(false));
     }
 }
예제 #2
0
    private static void ChangeScore(int scoreValue)
    {
        score += scoreValue;

        SetHighestScore();

        EventsObserver.Publish(new ChangeScoreEvent(score, highestScore));
    }
예제 #3
0
    public void PlayerDamage()
    {
        _playerHealth -= 1;

        if (_playerHealth <= 0)
        {
            EventsObserver.Publish(new PlayerDeathEvent());
        }
    }
예제 #4
0
        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);
        }
예제 #5
0
    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);
        }
    }
예제 #6
0
    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));
    }
예제 #7
0
 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;
     }
 }
예제 #8
0
    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);
        }
    }
예제 #9
0
    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());
    }
예제 #10
0
    private static void AddAvoidedAsteroids()
    {
        avoidedAsteroids += 1;

        EventsObserver.Publish(new AvoidAsteroidEvent(avoidedAsteroids));
    }
예제 #11
0
 public void RestartGame()
 {
     EventsObserver.Publish(new IRestartGameEvent());
     EventsObserver.Publish(new IPlaySoundEvent("Newgame"));
 }
예제 #12
0
 private void StartGame()
 {
     EventsObserver.Publish(new IStartGameplayEvent());
     EventsObserver.Publish(new IPlaySoundEvent("Newgame"));
 }
예제 #13
0
    private void PublishBoostEvent()
    {
        _boosted = !_boosted;

        EventsObserver.Publish(new PlayerBoostEvent(_boosted));
    }
예제 #14
0
 private void EndGameSession(PlayerDeathEvent e)
 {
     DataSaver.SaveData();
     EventsObserver.Publish(new StopTimeEvent(true));
 }
예제 #15
0
 private void Start()
 {
     EventsObserver.Publish(new IPlaySoundEvent("Background"));
 }
예제 #16
0
 public void ResetScore()
 {
     _score = 0;
     _lines = 0;
     EventsObserver.Publish(new IUpdateScoreEvent(_score, _lines));
 }
    public void CalculateTime()
    {
        ScoreManager.ChangeGameTime();

        EventsObserver.Publish(new ChangeGameTimeEvent());
    }
예제 #18
0
 private void Unpause()
 {
     EventsObserver.Publish(new IPauseEvent(false));
     EventsObserver.Publish(new IPlaySoundEvent("Resume"));
 }
예제 #19
0
 private void StartGameListener(IStartGameplayEvent e)
 {
     SetState(_gameplayState);
     EventsObserver.Publish(new ISpawnEvent());
 }
예제 #20
0
 private void Start()
 {
     EventsObserver.Publish(new StopTimeEvent(true));
     StartCoroutine(ScoreAdder());
 }