void OnLvlLoaded(Lvl _, int __) { if (balls != null) { foreach (var item in balls) { Destroy(item.gameObject); } } balls = new Ball[players.Length]; int index = 0; foreach (var player in players) { Ball ball = Instantiate(ballPrefab); ball.ActivateBall(false); player.InitPlayer(ball); ball.RotationBarDisplay(false); if (player.GetType() == typeof(AiPlayer)) { ball.setOwner(true); } balls[index] = ball; index++; } if (players.Length > 1) { players[0].ball.transform.position = new Vector3(-2f, 0f, 0f); players[1].ball.transform.position = new Vector3(2f, 0f, 0f); } currentPlayer = players[0]; OnChangePlayer.Invoke(currentPlayer); currentPlayer.StartTurn(); }
public static void ChangePlayer() { if (!PlayerProfile.sounds) { return; } OnChangePlayer.Invoke(); }
void Start() { DamageSystem.instance.OnDeathPlayer += DamageSystem_OnDeathPlayer; _allPlayers = FindObjectsOfType <CreatureStats>().OrderBy(x => x.team).ToList(); _currentPlayer = _allPlayers[0]; StatesExecute(_currentPlayer); OnChangePlayer?.Invoke(_currentPlayer); }
private void ChangePlayer() { int index = _allPlayers.FindIndex(x => x == _currentPlayer); if (index + 1 >= _allPlayers.Count) { _currentPlayer = _allPlayers[0]; } else { _currentPlayer = _allPlayers[index + 1]; } _pastActions = 0; StatesExecute(_currentPlayer); OnChangePlayer?.Invoke(_currentPlayer); }
void OnBallStoped() { int index = 0; foreach (var item in players) { if (item == currentPlayer) { if (players.Length == (index + 1)) { currentPlayer = players[0]; } else { currentPlayer = players[index + 1]; } foreach (var oneBall in balls) { oneBall.ActivateBall(false); } SoundsAction.ChangePlayer(); OnChangePlayer.Invoke(currentPlayer); if (currentPlayer.GetType() == typeof(AiPlayer)) { StartCoroutine(BotWait(currentPlayer)); } else { currentPlayer.StartTurn(); } return; } index++; } }