示例#1
0
    public async void StartGame(Action completion)
    {
        var cubeManager = ToioCubeManagerService.Instance.CubeManager;

        karutaPlayers         = cubeManager.cubes.ConvertAll(_cube => new KarutaPlayer(_cube, OnTouchedSimpleCard));
        targetSimpleCardTypes = ListUtility.Shuffle(ToioSimpleCardUtility.AlphabetTypes);
        isWithinGame          = false;
        UpdateView(karutaPlayers);

        for (var endedGameCount = 0; endedGameCount < targetSimpleCardTypes.Count; endedGameCount++)
        {
            UpdateRemainingCountText(endedGameCount);
            await DoOneGame(endedGameCount);

            UpdateRemainingCountText(endedGameCount);
        }

        var highScore = karutaPlayers.ConvertAll(_player => _player.Score).Max();

        karutaPlayers.ForEach(_player => _player.IsWin = _player.Score == highScore);
        UpdateView(karutaPlayers);
        completion?.Invoke();
    }