コード例 #1
0
    // private


    private IEnumerator CheckClaim()
    {
        // TODO: we may want to alter the amount units boost or reduce the claim

        while (true)
        {
            SetAttackAndDefense();

            int net_offense = Attackers.Count - Defenders.Count;   // Attackers and Defenders lists are managed by trigger stay/exit

            if (net_offense != 0)
            {
                Faction attacking_faction = Attackers.Any() ? Attackers.First().CurrentFaction : null;
                Faction defending_faction = Defenders.Any() ? Defenders.First().CurrentFaction : null;

                if (net_offense > 0)
                {
                    if (Claimed && NodeFaction != attacking_faction)
                    {
                        ReduceClaim(net_offense);
                    }
                    else if (!Claimed)
                    {
                        BoostClaim(net_offense, attacking_faction);
                    }
                }
                else if (net_offense < 0)
                {
                    if (Claimed && NodeFaction == defending_faction)
                    {
                        BoostClaim(Mathf.Abs(net_offense), defending_faction);
                    }
                }

                UpdateClaimBar();
            }
            yield return(new WaitForSeconds(Turn.ActionThreshold));
        }
    }