public bool IsShipInSector(GenericShip anotherShip, ArcType arcType) { GenericArc arc = Arcs.First(n => n.ArcType == arcType); ShotInfoArc arcInfo = new ShotInfoArc(HostShip, anotherShip, arc); return(arcInfo.IsShotAvailable); }
public int RangeToShipBySector(GenericShip anotherShip, ArcType arcType) { GenericArc arc = Arcs.First(n => n.ArcType == arcType); ShotInfoArc arcInfo = new ShotInfoArc(HostShip, anotherShip, arc); return(arcInfo.Range); }
private bool IsPossibleRedirectTarget(GenericShip ship) { bool result = false; if (ship.ShipId == HostShip.ShipId) { return(false); } DistanceInfo distInfo = new DistanceInfo(HostShip, ship); if (distInfo.Range > 1) { return(false); } foreach (GenericArc arc in Combat.Attacker.ArcsInfo.Arcs) { ShotInfoArc shotInfoArcDefender = new ShotInfoArc(Combat.Attacker, HostShip, arc); if (shotInfoArcDefender.InArc && shotInfoArcDefender.IsShotAvailable) { ShotInfoArc shotInfoArcRedirect = new ShotInfoArc(Combat.Attacker, ship, arc); if (shotInfoArcRedirect.InArc && shotInfoArcDefender.IsShotAvailable) { return(true); } } } return(result); }
private void GetShipsInAllArcDirections() { ArcMobile temporaryArc = new ArcMobile(Selection.ThisShip.ShipBase); Selection.ThisShip.ArcInfo.Arcs.Add(temporaryArc); EnemiesInArcHolder = new Dictionary <ArcFacing, List <GenericShip> >(); foreach (var arc in ArcFacings) { EnemiesInArcHolder.Add(arc, new List <GenericShip>()); foreach (GenericShip enemyShip in Roster.GetPlayer(Roster.AnotherPlayer(Selection.ThisShip.Owner.PlayerNo)).Ships.Values) { temporaryArc.Facing = arc; if (Selection.ThisShip.ShipsBumped.Contains(enemyShip)) { continue; } if (Selection.ThisShip.ShipBaseArcsType == BaseArcsType.ArcMobileDual && (arc == ArcFacing.Right || arc == ArcFacing.Rear)) { continue; } ShotInfoArc arcShotInfo = new ShotInfoArc(Selection.ThisShip, enemyShip, temporaryArc); if (arcShotInfo.InArc && arcShotInfo.Range < 4) { EnemiesInArcHolder[arc].Add(enemyShip); } else if (Selection.ThisShip.ShipBaseArcsType == BaseArcsType.ArcMobile) // With primary firing arc { ShotInfoArc arcPrimaryShotInfo = new ShotInfoArc(Selection.ThisShip, enemyShip, Selection.ThisShip.ArcInfo.GetArc <ArcPrimary>()); if (arcPrimaryShotInfo.InArc && arcPrimaryShotInfo.Range < 4) { EnemiesInArcHolder[arc].Add(enemyShip); } } else if (Selection.ThisShip.ShipBaseArcsType == BaseArcsType.ArcMobileDual) { temporaryArc.Facing = DualPointerArcs[arc]; ShotInfoArc secondArcShotInfo = new ShotInfoArc(Selection.ThisShip, enemyShip, temporaryArc); if (secondArcShotInfo.InArc && secondArcShotInfo.Range < 4) { EnemiesInArcHolder[arc].Add(enemyShip); } } } } Selection.ThisShip.ArcInfo.Arcs.Remove(temporaryArc); }
public bool IsShipInSector(GenericShip anotherShip, ArcType arcType) { GenericArc arc = Arcs.First(n => n.ArcType == arcType); ShotInfoArc arcInfo = new ShotInfoArc(HostShip, anotherShip, arc); bool result = arcInfo.IsShotAvailable; if (arcType == ArcType.Bullseye) { HostShip.CallOnBullseyeArcCheck(anotherShip, ref result); } return(result); }
private int GetDiceCount() { List <GenericShip> shipsInAttackArc = new List <GenericShip>(); foreach (GenericShip ship in Roster.AllShips.Values) { ShotInfoArc inArcCheck = new ShotInfoArc(HostShip, ship, Combat.ArcForShot); if (inArcCheck.InArc) { shipsInAttackArc.Add(ship); } } return(shipsInAttackArc.Count); }
private bool HasTargetForWeapons(List <GenericArc> arcs) { foreach (GenericArc arc in arcs) { foreach (GenericShip enemyShip in HostShip.Owner.EnemyShips.Values) { ShotInfoArc shotInfoArc = new ShotInfoArc(HostShip, enemyShip, arc); if (shotInfoArc.IsShotAvailable) { return(true); } } } return(false); }
private bool IsAvailable() { int shipsInAttackArc = 0; foreach (GenericShip ship in Roster.AllShips.Values) { ShotInfoArc shotInfoArc = new ShotInfoArc(HostShip, ship, Combat.ArcForShot); if (shotInfoArc.InArc) { shipsInAttackArc++; } } return(Combat.AttackStep == CombatStep.Attack && shipsInAttackArc == 1 && Combat.DiceRollAttack.HasResult(DieSide.Focus)); }
protected virtual bool CheckInArcRequirements(GenericShip ship) { foreach (GenericArc arc in Combat.Attacker.ArcsInfo.Arcs) { ShotInfoArc shotInfoArcDefender = new ShotInfoArc(Combat.Attacker, HostShip, arc); if (shotInfoArcDefender.InArc && shotInfoArcDefender.IsShotAvailable) { ShotInfoArc shotInfoArcRedirect = new ShotInfoArc(Combat.Attacker, ship, arc); if (shotInfoArcRedirect.InArc && shotInfoArcDefender.IsShotAvailable) { return(true); } } } return(false); }
private static string ArcRangeInfoToText(ShotInfoArc info) { if (info.InArc) { if (info.Range < 4) { return(info.Range.ToString()); } else { return("Beyond range 3"); } } else { return("Not in arc"); } }
public Dictionary <ArcFacing, List <GenericShip> > GetEnemiesInAllSectors() { Dictionary <ArcFacing, List <GenericShip> > EnemiesInAllSectors = new Dictionary <ArcFacing, List <GenericShip> >(); foreach (GenericArc sector in Sectors) { EnemiesInAllSectors.Add(sector.Facing, new List <GenericShip>()); foreach (GenericShip enemyShip in HostShip.Owner.AnotherPlayer.Ships.Values) { ShotInfoArc sectorInfo = new ShotInfoArc(HostShip, enemyShip, sector); if (sectorInfo.InArc && sectorInfo.Range != 0) { EnemiesInAllSectors[sector.Facing].Add(enemyShip); } } } return(EnemiesInAllSectors); }
public int RangeToShipBySector(GenericShip anotherShip, ArcType arcType) { ShotInfoArc arcInfo = GetSectorInfo(anotherShip, arcType); if (arcInfo != null) { bool result = arcInfo.IsShotAvailable; if (arcType == ArcType.Bullseye) { HostShip.CallOnBullseyeArcCheck(anotherShip, ref result); } return(result ? arcInfo.Range : int.MaxValue); } else { return(int.MaxValue); } }
public bool IsShipInSector(GenericShip anotherShip, ArcType arcType) { ShotInfoArc arcInfo = GetSectorInfo(anotherShip, arcType); if (arcInfo != null) { bool result = arcInfo.IsShotAvailable; if (arcType == ArcType.Bullseye) { HostShip.CallOnBullseyeArcCheck(anotherShip, ref result); } return(result); } else { return(false); } }
private bool IsAvailable() { bool result = false; if (Combat.AttackStep == CombatStep.Defence && Combat.Attacker.Owner.PlayerNo != HostShip.Owner.PlayerNo) { ShotInfoArc arcInfo = new ShotInfoArc( HostShip, Combat.Attacker, HostShip.SectorsInfo.Arcs.First(n => n.Facing == Arcs.ArcFacing.Front) ); if (arcInfo.Range <= 1) { result = true; } } return(result); }