/// <summary> /// 获取攻击单位 /// </summary> /// <param name="position">攻击方的位置</param> /// <param name="attackType">攻击方式</param> /// <param name="attackTaget">攻击目标</param> /// <param name="targetEmbattle"></param> private static CombatGeneral[] GetTargetUnit(int position, AttackUnit attackType, AttackTaget attackTaget, EmbattleQueue targetEmbattle) { IGeneral[] generalList = new IGeneral[0]; List <CombatGeneral> targetGeneralList = new List <CombatGeneral>(); switch (attackType) { case AttackUnit.Single: CombatGeneral cg = null; if (attackTaget == AttackTaget.Self) { cg = (CombatGeneral)targetEmbattle.GetGeneral(position); } else { cg = (CombatGeneral)targetEmbattle.FindGeneral(position); } if (cg != null) { generalList = new IGeneral[] { cg }; } break; case AttackUnit.Horizontal: generalList = targetEmbattle.FindHorizontal(position); break; case AttackUnit.Vertical: generalList = targetEmbattle.FindVertical(position); break; case AttackUnit.All: generalList = targetEmbattle.FindAll(); break; default: break; } foreach (IGeneral general in generalList) { targetGeneralList.Add((CombatGeneral)general); } return(targetGeneralList.ToArray()); }