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); }
/// <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)); }
/// <summary> /// 初始化该结构. /// </summary> /// <param name="attacker">技能效果等的发起者.</param> /// <param name="skillCommonID">发起者使用的技能ID(非技能发起填入uint.MaxValue).</param> /// <param name="structMadeByRandEvent">该结构是否由randevent创造(检测并避免randevent循环产生效果).</param> public AttackerAttrImpl(BattleUnit attacker, uint skillCommonID, bool structMadeByRandEvent) { mStructMadeByRandEvent = structMadeByRandEvent; mSkillCommonID = skillCommonID; if (attacker != null) { mAttackerID = attacker.InstanceID; mAttackerName = attacker.GetName(); mAttackerRadius = attacker.GetRadius(); mAttackerLeague = attacker.GetLeague(); mEffectStartPosition = mAttackerPosition = attacker.GetPosition(); mEffectStartDirection = mAttackerDirection = attacker.GetDirection(); mLevel = attacker.GetLevel(); mDamage = (uint)attacker.GetPropertyValue((int)PropertyTypeEnum.PropertyTypeDamage); mCriticalLevel = (uint)attacker.GetPropertyValue((int)PropertyTypeEnum.PropertyTypeCrticalLV); mSummonerID = attacker.SummonerID; mSummonerName = attacker.SummonerName; mSummonerLevel = attacker.SummonerLevel; } }
/// <summary> /// 阵营关系上, this和other是否是敌对. /// </summary> public bool IsRivalCamps(BattleUnit other) { return(other != null && LeagueManager.GetRelationship(GetLeague(), other.GetLeague()) == LeagueRelationship.Enemy); }