Beispiel #1
0
 private void Update()
 {
     if (HasGameFinished)
     {
         return;
     }
     HasGameFinished = _playerHealth?.GetHealth() <= 0.0f || _enemyHealth?.GetHealth() <= 0.0f;
     if (HasGameFinished)
     {
         Player.SetWinLoseState(_playerHealth.GetHealth() >= _enemyHealth.GetHealth());
         Enemy.SetWinLoseState(_enemyHealth.GetHealth() >= _playerHealth.GetHealth());
         return;
     }
     if (_canDamageBeCalculated && _currentStateNumber < Enemy.DummyStatesArray.Length)
     {
         _canDamageBeCalculated = false;
         var damageMultipliers = _damageMultipliersMatrix[(int)Enemy.DummyStatesArray[_currentStateNumber], (int)Player.DummyStatesArray[_currentStateNumber]];
         _enemyHealth.ApplyDamage(damageMultipliers.Enemy);
         _playerHealth.ApplyDamage(damageMultipliers.Player);
         _currentStateNumber++;
     }
     else if (Enemy != null && _currentStateNumber == Enemy.DummyStatesArray.Length && Enemy.CurrentStateNumber == Enemy.DummyStatesArray.Length && Player.CurrentStateNumber == Player.DummyStatesArray.Length)
     {
         Player.SetWinLoseState(_playerHealth.GetHealth() >= _enemyHealth.GetHealth());
         Enemy.SetWinLoseState(_enemyHealth.GetHealth() >= _playerHealth.GetHealth());
         _currentStateNumber++;
         HasGameFinished = true;
     }
     if (!_startCoroutine || !HasGameStarted)
     {
         return;
     }
     _startCoroutine = false;
     StartCoroutine(Timer(1.0f));
 }