private ArcFacing ArcTypeToFacing(ArcType type) { ArcFacing facing = ArcFacing.None; switch (type) { case ArcType.Front: facing = ArcFacing.Front; break; case ArcType.Rear: facing = ArcFacing.Rear; break; case ArcType.Left: facing = ArcFacing.Left; break; case ArcType.Right: facing = ArcFacing.Right; break; default: break; } return(facing); }
public override bool ReinforcePostCombatEffectCanBeUsed(ArcFacing facing) { if (Combat.DiceRollAttack.Successes <= 1) { return(false); } bool result = false; List <GenericArc> savedArcs = Combat.Defender.ArcInfo.Arcs; Combat.Defender.ArcInfo.Arcs = new List <GenericArc>() { new ArcSpecial180(Combat.Defender.ShipBase) }; ShotInfo reverseShotInfo = new ShotInfo(Combat.Defender, Combat.Attacker, Combat.Defender.PrimaryWeapon); bool inForward180Arc = reverseShotInfo.InArc; Combat.Defender.ArcInfo.Arcs = new List <GenericArc>() { new ArcSpecial180Rear(Combat.Defender.ShipBase) }; reverseShotInfo = new ShotInfo(Combat.Defender, Combat.Attacker, Combat.Defender.PrimaryWeapon); bool inRear180Arc = reverseShotInfo.InArc; Combat.Defender.ArcInfo.Arcs = savedArcs; result = (facing == ArcFacing.Front180) ? inForward180Arc && !inRear180Arc : !inForward180Arc && inRear180Arc; return(result); }
private void ModifyRotateArcFacingPriority(ArcFacing facing, ref int priority) { if (facing == ArcFacing.Front && NoArcInFrontSector()) { priority += (IsEnemyInFrontSector()) ? 100 : 5; } }
public static bool IsShipInFacing(GenericShip from, GenericShip to, ArcFacing facing) { List <GenericArc> savedArcs = from.ArcsInfo.Arcs; if (facing == ArcFacing.FullFront) { from.ArcsInfo.Arcs = new List <GenericArc>() { new ArcFullFront(from.ShipBase) } } ; else { from.ArcsInfo.Arcs = new List <GenericArc>() { new ArcFullRear(from.ShipBase) } }; ShotInfo reverseShotInfo = new ShotInfo(from, to, from.PrimaryWeapons); from.ArcsInfo.Arcs = savedArcs; return(reverseShotInfo.InArc); }
public void RotateArc(ArcFacing facing) { Facing = facing; MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[facing], 0f); (Host.ArcsInfo.Arcs.Find(a => a is ArcDualTurretB) as ArcDualTurretB).RotateArc(OppositeArcFacing(facing)); Editions.Edition.Current.RotateMobileFiringArc(this, facing); }
private void AddSingleTurretRotationDecision(ArcFacing facing) { AddDecision( facing.ToString(), delegate { ChangeMobileArcFacing(facing); }, isCentered: (facing == ArcFacing.Front || facing == ArcFacing.Rear) ); }
public override bool ReinforceEffectCanBeUsed(ArcFacing facing) { bool result = false; ArcType arcType = (facing == ArcFacing.FullFront) ? ArcType.FullFront : ArcType.FullRear; result = Combat.Defender.SectorsInfo.IsShipInSector(Combat.Attacker, arcType); return(result); }
public override bool ReinforceEffectCanBeUsed(ArcFacing facing) { bool result = false; ShotInfo reverseShotInfo = new ShotInfo(Combat.Defender, Combat.Attacker, Combat.Defender.PrimaryWeapon); result = (facing == ArcFacing.Front180) ? reverseShotInfo.InArc : !reverseShotInfo.InArc; return(result); }
public void ShowMobileFiringArcAltHighlight(ArcFacing facing) { //Mobile arc alt string newTexture = "ShipStandInsert/Universal/SecondEdition/" + this.ShipInfo.BaseSize.ToString() + "/" + this.Faction.ToString() + "/" + facing.ToString(); Material newMaterial = CreateMaterial(newTexture); StandardShaderUtils.ChangeRenderMode(newMaterial, StandardShaderUtils.BlendMode.Fade); ShipAllParts.Find("ShipBase/ShipStandInsert/ShipStandInsertImage/ThirdArc").GetComponent <Renderer>().material = newMaterial; ShipAllParts.Find("ShipBase/ShipStandInsert/ShipStandInsertImage/ThirdArc").GetComponent <MeshRenderer>().enabled = true; }
public override bool ReinforcePostCombatEffectCanBeUsed(ArcFacing facing) { if (Combat.DiceRollAttack.Successes <= 1) { return(false); } bool result = false; bool inFullFrontArc = Combat.Defender.SectorsInfo.IsShipInSector(Combat.Attacker, ArcType.FullFront); bool inFullRearArc = Combat.Defender.SectorsInfo.IsShipInSector(Combat.Attacker, ArcType.FullRear); result = (facing == ArcFacing.FullFront) ? inFullFrontArc && !inFullRearArc : !inFullFrontArc && inFullRearArc; return(result); }
private void AddSingleTurretRotationDecision(ArcFacing facing, ArcFacing currentFacing) { if (facing == currentFacing) { return; } AddDecision( facing.ToString(), delegate { ChangeMobileArcFacing(facing); }, isCentered: (facing == ArcFacing.Front || facing == ArcFacing.Rear) || (facing == ArcFacing.Left && currentFacing == ArcFacing.Right) || (facing == ArcFacing.Right && currentFacing == ArcFacing.Left) ); }
public void RotateArc(ArcFacing facing) { Facing = facing; switch (facing) { case ArcFacing.Forward: MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[ArcFacing.Forward], 0f); (Host.ArcInfo.Arcs.Find(a => a is ArcMobileDualB) as ArcMobileDualB).RotateArc(ArcFacing.Rear); break; case ArcFacing.Left: MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[ArcFacing.Left], 0f); (Host.ArcInfo.Arcs.Find(a => a is ArcMobileDualB) as ArcMobileDualB).RotateArc(ArcFacing.Right); break; } RuleSets.RuleSet.Instance.RotateMobileFiringArc(facing); }
public void RotateArc(ArcFacing facing) { Facing = facing; switch (facing) { case ArcFacing.Front: MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[ArcFacing.Front], 0f); (Host.ArcsInfo.Arcs.Find(a => a is ArcDualTurretB) as ArcDualTurretB).RotateArc(ArcFacing.Rear); break; case ArcFacing.Left: MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[ArcFacing.Left], 0f); (Host.ArcsInfo.Arcs.Find(a => a is ArcDualTurretB) as ArcDualTurretB).RotateArc(ArcFacing.Right); break; } Editions.Edition.Current.RotateMobileFiringArc(facing); }
private ArcFacing OppositeArcFacing(ArcFacing facing) { switch (facing) { case ArcFacing.Front: return(ArcFacing.Rear); case ArcFacing.Left: return(ArcFacing.Right); case ArcFacing.Right: return(ArcFacing.Left); case ArcFacing.Rear: return(ArcFacing.Front); default: return(ArcFacing.None); } }
public static bool IsShipInFacingOnly(GenericShip from, GenericShip to, ArcFacing facing) { List <GenericArc> savedArcs = from.ArcsInfo.Arcs; from.ArcsInfo.Arcs = new List <GenericArc>() { new ArcFullFront(from.ShipBase) }; ShotInfo reverseShotInfo = new ShotInfo(from, to, from.PrimaryWeapons); bool inForward180Arc = reverseShotInfo.InArc; from.ArcsInfo.Arcs = new List <GenericArc>() { new ArcFullRear(from.ShipBase) }; reverseShotInfo = new ShotInfo(from, to, from.PrimaryWeapons); bool inRear180Arc = reverseShotInfo.InArc; from.ArcsInfo.Arcs = savedArcs; return((facing == ArcFacing.FullFront) ? inForward180Arc && !inRear180Arc : !inForward180Arc && inRear180Arc); }
public override void PrepareDecision(System.Action callBack) { DescriptionShort = "Rotate Arc"; if (Selection.ThisShip.ArcsInfo.Arcs.Any(a => a is ArcSingleTurret)) { ArcFacing currentFacing = Selection.ThisShip.ArcsInfo.GetArc <ArcSingleTurret>().Facing; foreach (ArcFacing facing in Selection.ThisShip.GetAvailableArcFacings()) { AddSingleTurretRotationDecision(facing, currentFacing); } } else if (Selection.ThisShip.ShipInfo.ArcInfo.Arcs.Any(a => a.ArcType == ArcType.DoubleTurret)) { ArcDualTurretA dualTurretArc = Selection.ThisShip.ArcsInfo.GetArc <ArcDualTurretA>(); if (dualTurretArc.Facing != ArcFacing.Front && dualTurretArc.Facing != ArcFacing.Rear) { AddDecision("Front-Rear", delegate { ChangeMobileDualArcFacing(ArcFacing.Front); }); AddDecision("Rear-Front", delegate { ChangeMobileDualArcFacing(ArcFacing.Rear); }); } if (dualTurretArc.Facing != ArcFacing.Left && dualTurretArc.Facing != ArcFacing.Right) { AddDecision("Left-Right", delegate { ChangeMobileDualArcFacing(ArcFacing.Left); }); AddDecision("Right-Left", delegate { ChangeMobileDualArcFacing(ArcFacing.Right); }); } } if (decisions.Count == 1) { IsForced = true; } DefaultDecisionName = GetDefaultDecision(); callBack(); }
public abstract bool ReinforceEffectCanBeUsed(ArcFacing facing);
private string GetDefaultDecision() { string chosenFacing = ""; Dictionary <ArcFacing, List <GenericShip> > enemiesInArcHolder = Selection.ThisShip.SectorsInfo.GetEnemiesInAllSectors(); Dictionary <ArcFacing, int> singleTurretPriorities = new Dictionary <ArcFacing, int>(); foreach (ArcFacing facing in Selection.ThisShip.GetAvailableArcFacings()) { int priority = 0; //Ignore static arcs with same facing if (!Selection.ThisShip.ArcsInfo.Arcs.Any(a => a.Facing == facing && (!(a is ArcSingleTurret)))) { priority = enemiesInArcHolder[facing].Count; } Selection.ThisShip.Ai.CallGetRotateArcFacingPriority(facing, ref priority); singleTurretPriorities.Add(facing, priority); } // For single turret if (Selection.ThisShip.ShipInfo.ArcInfo.Arcs.Any(a => a.ArcType == ArcType.SingleTurret)) { ArcFacing currentFacing = Selection.ThisShip.ArcsInfo.GetArc <ArcSingleTurret>().Facing; //if no enemies in all sectors, prioritize default values if (!singleTurretPriorities.Any(n => n.Value > 0)) { if (Selection.ThisShip.ShipInfo.ArcInfo.Arcs.Any(a => a.ArcType == ArcType.Front)) { singleTurretPriorities[ArcFacing.Rear] += 1; } else { singleTurretPriorities[ArcFacing.Front] += 1; } } //Get facing with highest priority that is not current facing singleTurretPriorities.Remove(currentFacing); ArcFacing bestFacing = singleTurretPriorities.FirstOrDefault(a => a.Value == singleTurretPriorities.Max(b => b.Value)).Key; chosenFacing = bestFacing.ToString(); } // For double turret else if (Selection.ThisShip.ShipInfo.ArcInfo.Arcs.Any(a => a.ArcType == ArcType.DoubleTurret)) { ArcFacing currentFacing = Selection.ThisShip.ArcsInfo.GetArc <ArcDualTurretA>().Facing; string currentFacingString = "None"; if (currentFacing == ArcFacing.Front || currentFacing == ArcFacing.Rear) { currentFacingString = "Front-Rear"; } else if (currentFacing == ArcFacing.Left || currentFacing == ArcFacing.Right) { currentFacingString = "Left-Right"; } Dictionary <string, int> doubleTurretPriorities = new Dictionary <string, int> { { "Front-Rear", singleTurretPriorities[ArcFacing.Front] + singleTurretPriorities[ArcFacing.Rear] }, { "Left-Right", singleTurretPriorities[ArcFacing.Left] + singleTurretPriorities[ArcFacing.Right] } }; if (!doubleTurretPriorities.Any(n => n.Value > 0)) { if (Selection.ThisShip.ShipInfo.ArcInfo.Arcs.Any(a => a.ArcType == ArcType.Front)) { doubleTurretPriorities["Left-Right"] += 1; } else { doubleTurretPriorities["Front-Rear"] += 1; } } doubleTurretPriorities.Remove(currentFacingString); chosenFacing = doubleTurretPriorities.FirstOrDefault(a => a.Value == doubleTurretPriorities.Max(b => b.Value)).Key; } return(chosenFacing); }
private void ChangeMobileArcFacing(ArcFacing facing) { Selection.ThisShip.ArcsInfo.GetArc <ArcSingleTurret>().RotateArc(facing); ConfirmDecision(); }
public override bool ReinforceEffectCanBeUsed(ArcFacing facing) { return(false); }
private void ChangeMobileArcFacing(ArcFacing facing) { (Selection.ThisShip.ArcInfo as ArcMobile).RotateArc(facing); ConfirmDecision(); }
public void RotateArc(ArcFacing facing) { Facing = facing; MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[facing], 0f); Editions.Edition.Current.RotateMobileFiringArc(facing); }
public MobileSubArc(ArcFacing facing, Dictionary <Vector3, float> limits, List <Vector3> edges) { Facing = facing; Limits = limits; Edges = edges; }
public virtual void RotateMobileFiringArcAlt(GenericArc arc, ArcFacing facing) { }
private void ChangeMobileDualArcFacing(ArcFacing facing) { Selection.ThisShip.ArcInfo.GetArc <ArcMobileDualA>().RotateArc(facing); ConfirmDecision(); }
public void CallGetRotateArcFacingPriority(ArcFacing facing, ref int priority) { OnGetRotateArcFacingPriority?.Invoke(facing, ref priority); }
public abstract bool DefenderIsReinforcedAgainstAttacker(ArcFacing facing, GenericShip defender, GenericShip attacker);
public virtual void RotateMobileFiringArcAlt(ArcFacing facing) { }
public override void RotateMobileFiringArc(ArcFacing facing) { Selection.ThisShip.ShowMobileFiringArcHighlight(facing); }
public abstract bool ReinforcePostCombatEffectCanBeUsed(ArcFacing facing);