コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private void ModifyRotateArcFacingPriority(ArcFacing facing, ref int priority)
 {
     if (facing == ArcFacing.Front && NoArcInFrontSector())
     {
         priority += (IsEnemyInFrontSector()) ? 100 : 5;
     }
 }
コード例 #4
0
ファイル: Board.cs プロジェクト: vitreuz/FlyCasual
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 private void AddSingleTurretRotationDecision(ArcFacing facing)
 {
     AddDecision(
         facing.ToString(),
         delegate {
         ChangeMobileArcFacing(facing);
     },
         isCentered: (facing == ArcFacing.Front || facing == ArcFacing.Rear)
         );
 }
コード例 #7
0
ファイル: FirstEdition.cs プロジェクト: qbasicjed/FlyCasual
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: GenericShip.cs プロジェクト: qbasicjed/FlyCasual
        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;
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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)
                );
        }
コード例 #12
0
        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);
        }
コード例 #13
0
ファイル: ArcDualTurretA.cs プロジェクト: jychuah/FlyCasual
        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);
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
ファイル: Board.cs プロジェクト: vitreuz/FlyCasual
        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);
        }
コード例 #16
0
        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();
        }
コード例 #17
0
ファイル: RuleSet.cs プロジェクト: xNyer/FlyCasual
 public abstract bool ReinforceEffectCanBeUsed(ArcFacing facing);
コード例 #18
0
        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);
        }
コード例 #19
0
 private void ChangeMobileArcFacing(ArcFacing facing)
 {
     Selection.ThisShip.ArcsInfo.GetArc <ArcSingleTurret>().RotateArc(facing);
     ConfirmDecision();
 }
コード例 #20
0
 public override bool ReinforceEffectCanBeUsed(ArcFacing facing)
 {
     return(false);
 }
コード例 #21
0
 private void ChangeMobileArcFacing(ArcFacing facing)
 {
     (Selection.ThisShip.ArcInfo as ArcMobile).RotateArc(facing);
     ConfirmDecision();
 }
コード例 #22
0
 public void RotateArc(ArcFacing facing)
 {
     Facing = facing;
     MobileArcPointer.localEulerAngles = new Vector3(0f, MobileArcRotationValues[facing], 0f);
     Editions.Edition.Current.RotateMobileFiringArc(facing);
 }
コード例 #23
0
 public MobileSubArc(ArcFacing facing, Dictionary <Vector3, float> limits, List <Vector3> edges)
 {
     Facing = facing;
     Limits = limits;
     Edges  = edges;
 }
コード例 #24
0
ファイル: Edition.cs プロジェクト: JeffSkyrunner/FlyCasual
 public virtual void RotateMobileFiringArcAlt(GenericArc arc, ArcFacing facing)
 {
 }
コード例 #25
0
 private void ChangeMobileDualArcFacing(ArcFacing facing)
 {
     Selection.ThisShip.ArcInfo.GetArc <ArcMobileDualA>().RotateArc(facing);
     ConfirmDecision();
 }
コード例 #26
0
 public void CallGetRotateArcFacingPriority(ArcFacing facing, ref int priority)
 {
     OnGetRotateArcFacingPriority?.Invoke(facing, ref priority);
 }
コード例 #27
0
ファイル: Edition.cs プロジェクト: JeffSkyrunner/FlyCasual
 public abstract bool DefenderIsReinforcedAgainstAttacker(ArcFacing facing, GenericShip defender, GenericShip attacker);
コード例 #28
0
ファイル: RuleSet.cs プロジェクト: xNyer/FlyCasual
 public virtual void RotateMobileFiringArcAlt(ArcFacing facing)
 {
 }
コード例 #29
0
ファイル: SecondEdition.cs プロジェクト: borkin8r/FlyCasual
 public override void RotateMobileFiringArc(ArcFacing facing)
 {
     Selection.ThisShip.ShowMobileFiringArcHighlight(facing);
 }
コード例 #30
0
ファイル: RuleSet.cs プロジェクト: xNyer/FlyCasual
 public abstract bool ReinforcePostCombatEffectCanBeUsed(ArcFacing facing);