Exemplo n.º 1
0
    /// <summary>
    /// Checks whether the given formation is a valid target.
    /// </summary>
    private bool IsTargetFormationValid(Pawn actor, Formation formation)
    {
        // Check for all or nothing cases first to see
        // if we can skip the other checks.
        if (Formations == TargetableFormation.All)
        {
            return(true);
        }
        if (Formations == TargetableFormation.None)
        {
            return(false);
        }

        // Assume the formation is invalid and then include
        // cases as it meets their requirements
        bool valid           = false;
        bool isSelfFormation = formation == actor.Formation;

        // Can target own formation.
        if (Formations.HasFlag(TargetableFormation.Self) &&
            isSelfFormation)
        {
            valid = true;
        }

        // Can target other formations.
        else if (Formations.HasFlag(TargetableFormation.Other) &&
                 !isSelfFormation)
        {
            valid = true;
        }

        return(valid);
    }
Exemplo n.º 2
0
    public override void Setup(IBattleActionElement element)
    {
        FormationRestriction formationRestriction = element as FormationRestriction;
        TargetableFormation  formations           = formationRestriction.Formations;

        if (formations.HasFlag(TargetableFormation.Other) &&
            !formations.HasFlag(TargetableFormation.Self))
        {
            image.color = otherColour;
        }

        else if (formations.HasFlag(TargetableFormation.Self) &&
                 !formations.HasFlag(TargetableFormation.Other))
        {
            image.color = selfColour;
        }
    }