Beispiel #1
0
    private static bool IsTarget(AttackerAttr attackerAttr, BattleUnit target, LeagueSelection selection)
    {
        // 自身不是Ally关系!
        if (attackerAttr.AttackerID == target.InstanceID)
        {
            return((selection & LeagueSelection.Self) != 0);
        }

        // 此时, 攻守双方不相同.
        LeagueRelationship r = GetRelationship(attackerAttr.AttackerLeague, target.GetLeague());

        switch (r)
        {
        case LeagueRelationship.Ally:
            return((selection & LeagueSelection.Ally) != 0);

        case LeagueRelationship.Enemy:
            return((selection & LeagueSelection.Enemy) != 0 && !target.IsInviolable());

        default:
            break;
        }

        return(false);
    }
Beispiel #2
0
    /// <summary>
    /// 返回target是否是attackerAttr标识的攻击者者所要寻找的目标.
    /// selection表示攻击者要寻找什么类型的目标.
    /// </summary>
    public static bool IsDisiredTarget(AttackerAttr attackerAttr, BattleUnit target, LeagueSelection selection)
    {
        if (target == null || target.IsDead() || selection == LeagueSelection.None)
        {
            return(false);
        }

        if (attackerAttr.AttackerLeague == LeagueDef.InvalidLeague || target.GetLeague() == LeagueDef.InvalidLeague)
        {
            return(ErrorHandler.Parse(ErrorCode.ConfigError, "invalid league"));
        }

        if (selection >= LeagueSelection.Count)
        {
            return(ErrorHandler.Parse(ErrorCode.ConfigError, "invalid league selection " + (uint)selection));
        }

        return(IsTarget(attackerAttr, target, selection));
    }