private void GetEnemyShot(ResponseMessage msg) { if (IsPlayerGoing) { return; } var result = _serializer.DeserializeDynamic(msg.Text); switch ((string)result["message_type"]) { case "get_enemy_shot": var enemyShot = _serializer.DeserializeObject <GetEnemyShot>(result); OnGetEnemyShot?.Invoke(this, new(enemyShot)); break; case "get_enemy_answer": var enemyAnswer = _serializer.DeserializeObject <GetEnemyAnswer>(result); OnGetEnemyAnswer?.Invoke(this, new(enemyAnswer)); break; case "player_turn": IsPlayerGoing = true; OnPlayerTurn?.Invoke(this, EventArgs.Empty); break; default: throw new("Unexpected message type"); } }
public void SetBattleStage(EBattleStage nextStage, RythmMove move = null) { _currentBattleStage = nextStage; if (move != null) { currentMove = move; } switch (_currentBattleStage) { case EBattleStage.Intro: SetCharacterValues(); pauseController.CanPause = false; OnIntro?.Invoke(); break; case EBattleStage.PlayerTurn: SetEnemyAnimation(enemy.IdleAnimation); pauseController.CanPause = true; OnPlayerTurn?.Invoke(); break; case EBattleStage.PlayerMove: _lastToMoveIsPlayer = true; OnPlayerMove?.Invoke(); break; case EBattleStage.EnemyTurn: SetPlayerAnimation(player.IdleAnimation); pauseController.CanPause = true; OnEnemyTurn?.Invoke(); StartCoroutine(WaitToEnemyMove()); break; case EBattleStage.EnemyMove: _lastToMoveIsPlayer = false; OnEnemyMove?.Invoke(); break; case EBattleStage.DamageStep: OnDamage?.Invoke(); StartCoroutine(DelayedDamage()); break; case EBattleStage.Conclusion: pauseController.CanPause = false; OnConclusion?.Invoke(); break; } }