Example #1
0
    void RemoveDieFromTeam(BattleTeam team, Die die)
    {
        var battleDie = team.TryRemoveDie(die);

        if (battleDie != null)
        {
            battleDie.LandedOnFace -= OnDieLandedOnFace;

            Debug.Log($"<color=blue>{team.Name} lost a member: {die.name} of type {die.dieType} ({team.Dice.Count}/{BattleTeam.RequiredNumberOfDices})</color>");
            CancelBattle(BattleCancelledReason.DieLeft);

            var pendingDie = _dice.FirstOrDefault(d => _team1.Dice.Concat(_team2.Dice).All(bd => bd.Die != d));
            if (pendingDie != null)
            {
                AddDieToTeam(team, pendingDie);
            }
        }
    }