public IEnumerable <FamilyMember> FindRelations(FamilyMember memberInCurrentContext, eRelationType relationType)
        {
            if (memberInCurrentContext == null)
            {
                throw new ArgumentNullException("memberInCurrentContext");
            }

            switch (relationType)
            {
            case eRelationType.Son:
                return(memberInCurrentContext.Children.Where(a => a.IsMale));

            case eRelationType.Daughter:
                return(memberInCurrentContext.Children.Where(a => !a.IsMale));

            case eRelationType.Father:
                if (memberInCurrentContext.Father == null)
                {
                    throw new InvalidOperationException("Reached the zeroth node. Cannot traverse any further");
                }
                return(new FamilyMember[] { memberInCurrentContext.Father });

            case eRelationType.Mother:
                if (memberInCurrentContext.Mother == null)
                {
                    throw new InvalidOperationException("Reached the zeroth node. Cannot traverse any further");
                }
                return(new FamilyMember[] { memberInCurrentContext.Mother });

            case eRelationType.Sibling:
                return(GetSiblings(memberInCurrentContext, null));

            case eRelationType.PaternalUncle:
                return(GetPaternalUncles(memberInCurrentContext));

            case eRelationType.MaternalUncle:
                return(GetMaternalUncles(memberInCurrentContext));

            case eRelationType.PaternalAunt:
                return(GetPaternalAunts(memberInCurrentContext));

            case eRelationType.MaternalAunt:
                return(GetMaternalAunts(memberInCurrentContext));

            case eRelationType.SisterInLaw:
                return(GetSisterInLaws(memberInCurrentContext));

            case eRelationType.BrotherInLaw:
                return(GetBrotherInLaws(memberInCurrentContext));

            default:
                throw new InvalidOperationException(relationType + "- This relationship type is not supported yet.");
            }
        }
示例#2
0
        /// <summary>
        /// 检查目标是否有效
        /// </summary>
        public override bool TargetFilter(RoleActor caster, SkillActive skill, RoleActor target, eRelationType relation)
        {
            if (!base.TargetFilter(caster, skill, target, relation))
            {
                return(false);
            }

            return(true);
        }
示例#3
0
        /// <summary>
        /// 检查目标是否有效
        /// </summary>
        public virtual bool TargetFilter(RoleActor caster, SkillActive skill, RoleActor target, eRelationType relation)
        {
            if (null == caster || null == skill || null == target)
            {
                return(false);
            }

            return(true);
        }