Exemplo n.º 1
0
        public override void Initialize()
        {
            Board.ToggleObstaclesHolder(true);

            MinBoardEdgeDistance = Board.BoardIntoWorld(2 * Board.RANGE_1);
            MinObstaclesDistance = Board.BoardIntoWorld(Board.RANGE_1);

            RequiredPlayer = Roster.AnotherPlayer(RequiredPlayer);
            Next();
        }
Exemplo n.º 2
0
 private void HideAssignedManeuversInHotSeatGame()
 {
     if (Roster.GetPlayer(Roster.AnotherPlayer(RequiredPlayer)).UsesHotacAiRules == false)
     {
         foreach (var shipHolder in Roster.GetPlayer(RequiredPlayer).Ships)
         {
             Roster.ToggleManeuverVisibility(shipHolder.Value, false);
         }
     }
 }
Exemplo n.º 3
0
 private void HideAssignedManeuversInHotSeatGame()
 {
     if (Roster.GetPlayer(Roster.AnotherPlayer(RequiredPlayer)).GetType() != typeof(Players.HotacAiPlayer))
     {
         foreach (var shipHolder in Roster.GetPlayer(RequiredPlayer).Ships)
         {
             Roster.ToggelManeuverVisibility(shipHolder.Value, false);
         }
     }
 }
Exemplo n.º 4
0
        public override void Next()
        {
            IsLocked = true;
            HideSubphaseDescription();

            RequiredPlayer = Roster.AnotherPlayer(RequiredPlayer);
            if (!IsRandomSetupSelected[RequiredPlayer])
            {
                ShowSubphaseDescription(Name, "Obstacles cannot be placed at Range 1 of each other, or at Range 1-2 of an edge of the play area.");
            }
            Roster.GetPlayer(RequiredPlayer).PlaceObstacle();
        }
Exemplo n.º 5
0
 public static void ChangeActiveShip(string shipId)
 {
     DeselectThisShip();
     ThisShip = Roster.GetShipById(shipId);
     ThisShip.ToggleCollisionDetection(true);
     Roster.MarkShip(ThisShip, Color.green);
     ThisShip.HighlightThisSelected();
     if (Phases.CurrentSubPhase.GetType() == typeof(SubPhases.CombatSubPhase))
     {
         Roster.HighlightShipsFiltered(Roster.AnotherPlayer(Phases.CurrentPhasePlayer));
     }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public override void Initialize()
 {
     Players.PlayerNo playerNo = Players.PlayerNo.Player1;
     if (targetsAllowed.Contains(TargetTypes.OtherFriendly))
     {
         playerNo = Phases.CurrentPhasePlayer;
     }
     if (targetsAllowed.Contains(TargetTypes.Enemy))
     {
         playerNo = Roster.AnotherPlayer(Phases.CurrentPhasePlayer);
     }
     Roster.HighlightShipsFiltered(playerNo, -1, GenerateListOfExceptions());
 }
Exemplo n.º 8
0
    public static bool HasTarget(Ship.GenericShip thisShip)
    {
        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(thisShip, anotherShip.Value);
            if ((shotInfo.Range < 4) && (shotInfo.InArc))
            {
                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 9
0
 public override void Initialize()
 {
     Players.PlayerNo playerNo = Players.PlayerNo.Player1;
     if (isFriendlyAllowed)
     {
         playerNo = Phases.CurrentPhasePlayer;
     }
     if (isEnemyAllowed)
     {
         playerNo = Roster.AnotherPlayer(Phases.CurrentPhasePlayer);
     }
     Roster.HighlightShipsFiltered(playerNo, -1, GenerateListOfExceptions());
 }
Exemplo n.º 10
0
    public static bool HasTarget(GenericShip thisShip)
    {
        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            ShotInfo shotInfo = new ShotInfo(thisShip, anotherShip.Value, thisShip.PrimaryWeapon);
            if ((shotInfo.Range < 4) && (shotInfo.IsShotAvailable))
            {
                return(true);
            }
        }

        return(false);
    }
Exemplo n.º 11
0
    public static int CountEnemiesTargeting(Ship.GenericShip thisShip)
    {
        int result = 0;

        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            ShipShotDistanceInformation shotInfo = new ShipShotDistanceInformation(anotherShip.Value, thisShip, anotherShip.Value.PrimaryWeapon);
            if ((shotInfo.Range < 4) && (shotInfo.InShotAngle))
            {
                result++;
            }
        }

        return(result);
    }
Exemplo n.º 12
0
        public override void Next()
        {
            IsLocked = true;
            HideSubphaseDescription();

            RequiredPlayer = Roster.AnotherPlayer(RequiredPlayer);
            if (!IsRandomSetupSelected[RequiredPlayer])
            {
                Board.HighlightOfStartingZoneOn();
                ShowSubphaseDescription(Name, "Obstacles cannot be placed at Range 1 of each other, or at Range 1-2 of an edge of the play area.");
            }

            IsReadyForCommands = true;
            Roster.GetPlayer(RequiredPlayer).PlaceObstacle();
        }
Exemplo n.º 13
0
        private GenericShip GetEnemyPilotWithHighestSkill()
        {
            GenericShip bestAce       = null;
            int         maxPilotSkill = 0;

            foreach (var enemyShip in Roster.GetPlayer(Roster.AnotherPlayer(HostShip.Owner.PlayerNo)).Ships)
            {
                if (enemyShip.Value.State.Initiative > maxPilotSkill)
                {
                    bestAce       = enemyShip.Value;
                    maxPilotSkill = enemyShip.Value.State.Initiative;
                }
            }
            return(bestAce);
        }
Exemplo n.º 14
0
    public static bool HasTarget(GenericShip thisShip)
    {
        foreach (var anotherShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
        {
            foreach (IShipWeapon weapon in thisShip.GetAllWeapons())
            {
                ShotInfo shotInfo = new ShotInfo(thisShip, anotherShip.Value, weapon);
                if (shotInfo.IsShotAvailable)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
Exemplo n.º 15
0
        private bool SetupFilter()
        {
            bool result = true;

            foreach (GenericShip enemyShip in Roster.GetPlayer(Roster.AnotherPlayer(Host.Owner.PlayerNo)).Ships.Values)
            {
                DistanceInfo distInfo = new DistanceInfo(Host, enemyShip);
                if (distInfo.Range < 4)
                {
                    Messages.ShowErrorToHuman("Boba Fett: The range to the closest enemy is " + distInfo.Range + ", it must be beyond range 3");
                    return(false);
                }
            }

            return(result);
        }
Exemplo n.º 16
0
        public override void Next()
        {
            if (Roster.AllManuversAreAssigned(RequiredPlayer))
            {
                HideAssignedManeuversInHotSeatGame();

                if (RequiredPlayer == Phases.PlayerWithInitiative)
                {
                    RequiredPlayer = Roster.AnotherPlayer(RequiredPlayer);
                    PlayerAssignsManeuvers();
                }
                else
                {
                    FinishPhase();
                }
            }
        }
Exemplo n.º 17
0
        public override void Next()
        {
            if (Roster.AllManuersAreAssigned(RequiredPlayer))
            {
                if (RequiredPlayer == Phases.PlayerWithInitiative)
                {
                    RequiredPlayer = Roster.AnotherPlayer(RequiredPlayer);

                    UpdateHelpInfo();
                    HighlightShips();
                    Roster.GetPlayer(RequiredPlayer).AssignManeuver();
                }
                else
                {
                    FinishPhase();
                }
            }
        }
Exemplo n.º 18
0
        public void CheckWinConditions()
        {
            int eliminatedTeam = Roster.CheckIsAnyTeamIsEliminated();

            if (eliminatedTeam != 0)
            {
                if (eliminatedTeam < 3)
                {
                    Game.UI.AddTestLogEntry("Player " + Roster.AnotherPlayer(eliminatedTeam) + " Wins!");
                    Game.UI.ShowGameResults("Player " + Roster.AnotherPlayer(eliminatedTeam) + " Wins!");
                }
                else
                {
                    Game.UI.AddTestLogEntry("Draw!");
                    Game.UI.ShowGameResults("Draw!");
                }
            }
        }
Exemplo n.º 19
0
        // TODO: Remove, used in AI/HotAC/TargetForAttackSelector
        public Dictionary <GenericShip, float> GetEnemyShipsAndDistance(GenericShip thisShip, bool ignoreCollided = false, bool inArcAndRange = false)
        {
            Dictionary <GenericShip, float> results = new Dictionary <GenericShip, float>();

            foreach (var shipHolder in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships)
            {
                if (!shipHolder.Value.IsDestroyed)
                {
                    if (ignoreCollided)
                    {
                        if (thisShip.LastShipCollision != null)
                        {
                            if (thisShip.LastShipCollision.ShipId == shipHolder.Value.ShipId)
                            {
                                continue;
                            }
                        }
                        if (shipHolder.Value.LastShipCollision != null)
                        {
                            if (shipHolder.Value.LastShipCollision.ShipId == thisShip.ShipId)
                            {
                                continue;
                            }
                        }
                    }

                    if (inArcAndRange)
                    {
                        BoardTools.DistanceInfo distanceInfo = new BoardTools.DistanceInfo(thisShip, shipHolder.Value);
                        if ((distanceInfo.Range > 3))
                        {
                            continue;
                        }
                    }

                    float distance = Vector3.Distance(thisShip.GetCenter(), shipHolder.Value.GetCenter());
                    results.Add(shipHolder.Value, distance);
                }
            }
            results = results.OrderBy(n => n.Value).ToDictionary(n => n.Key, n => n.Value);

            return(results);
        }
Exemplo n.º 20
0
        private void CheckAbility(GenericShip shipChangedPosition)
        {
            //Only if host or enemy changed position;
            if (shipChangedPosition == HostShip || shipChangedPosition.Owner.PlayerNo != HostShip.Owner.PlayerNo)
            {
                foreach (GenericShip enemyShip in Roster.GetPlayer(Roster.AnotherPlayer(HostShip.Owner.PlayerNo)).Ships.Values)
                {
                    DistanceInfo distInfo = new DistanceInfo(HostShip, enemyShip);
                    if (distInfo.Range == 1)
                    {
                        TryActivateAbilityBonus();
                        return;
                    }
                }

                //If no range 1 enemy ships
                TryDeactivateAbilityBonus();
            }
        }
Exemplo n.º 21
0
        public override void Initialize()
        {
            Board.ToggleObstaclesHolder(true);

            MinBoardEdgeDistance = Board.BoardIntoWorld(2 * Board.RANGE_1);
            MinObstaclesDistance = Board.BoardIntoWorld(Board.RANGE_1);

            RequiredPlayer = Roster.AnotherPlayer(Phases.PlayerWithInitiative); // Will be changed in Next

            foreach (GenericPlayer player in Roster.Players)
            {
                if (player is HotacAiPlayer)
                {
                    IsRandomSetupSelected[player.PlayerNo] = true;
                }
            }

            Next();
        }
Exemplo n.º 22
0
        public override void PlaceObstacle()
        {
            base.PlaceObstacle();

            ObstaclesPlacementSubPhase subphase = Phases.CurrentSubPhase as ObstaclesPlacementSubPhase;

            if (subphase.IsRandomSetupSelected[Roster.AnotherPlayer(this.PlayerNo)] || DebugManager.BatchAiSquadTestingModeActive)
            {
                (Phases.CurrentSubPhase as ObstaclesPlacementSubPhase).PlaceRandom();
            }
            else
            {
                GameManagerScript.Wait(1, delegate
                {
                    (Phases.CurrentSubPhase as ObstaclesPlacementSubPhase).PlaceRandom();
                    Messages.ShowInfo("The AI has placed an obstacle");
                });
            }
        }
Exemplo n.º 23
0
        public override void PlaceObstacle()
        {
            base.PlaceObstacle();

            ObstaclesPlacementSubPhase subphase = Phases.CurrentSubPhase as ObstaclesPlacementSubPhase;

            if (subphase.IsRandomSetupSelected[Roster.AnotherPlayer(this.PlayerNo)])
            {
                (Phases.CurrentSubPhase as ObstaclesPlacementSubPhase).PlaceRandom();
            }
            else
            {
                GameManagerScript.Wait(1, delegate
                {
                    (Phases.CurrentSubPhase as ObstaclesPlacementSubPhase).PlaceRandom();
                    Messages.ShowInfo("AI: Obstacle was placed");
                });
            }
        }
Exemplo n.º 24
0
        private static List <GenericShip> GetEnemyShipsAndDistance(GenericShip thisShip, bool ignoreCollided = false, bool inArcAndRange = false)
        {
            Dictionary <GenericShip, float> results = new Dictionary <GenericShip, float>();

            foreach (GenericShip enemyShip in Roster.GetPlayer(Roster.AnotherPlayer(thisShip.Owner.PlayerNo)).Ships.Values)
            {
                if (!enemyShip.IsDestroyed && !enemyShip.IsReadyToBeDestroyed)
                {
                    if (ignoreCollided)
                    {
                        if (thisShip.LastShipCollision != null)
                        {
                            if (thisShip.LastShipCollision.ShipId == enemyShip.ShipId)
                            {
                                continue;
                            }
                        }
                        if (enemyShip.LastShipCollision != null)
                        {
                            if (enemyShip.LastShipCollision.ShipId == thisShip.ShipId)
                            {
                                continue;
                            }
                        }
                    }

                    if (inArcAndRange)
                    {
                        DistanceInfo distanceInfo = new DistanceInfo(thisShip, enemyShip);
                        if ((distanceInfo.Range > 3))
                        {
                            continue;
                        }
                    }

                    float distance = Vector3.Distance(thisShip.GetCenter(), enemyShip.GetCenter());
                    results.Add(enemyShip, distance);
                }
            }
            results = results.OrderBy(n => n.Value).ToDictionary(n => n.Key, n => n.Value);

            return(results.Select(n => n.Key).ToList());
        }
Exemplo n.º 25
0
        public override void OnTargetNotLegalForAttack()
        {
            // TODO: Better explanations
            if (!Rules.TargetIsLegalForShot.IsLegal())
            {
                //automatic error messages
            }
            else if (!Combat.ShotInfo.InShotAngle)
            {
                Messages.ShowErrorToHuman("Target is outside your firing arc");
            }
            else if (Combat.ShotInfo.Range > Combat.ChosenWeapon.MaxRange || Combat.ShotInfo.Distance < Combat.ChosenWeapon.MinRange)
            {
                Messages.ShowErrorToHuman("Target is outside your firing range");
            }

            //TODO: except non-legal targets, bupmed for example, biggs?
            Roster.HighlightShipsFiltered(Roster.AnotherPlayer(Phases.CurrentPhasePlayer));
            UI.HighlightNextButton();
        }
Exemplo n.º 26
0
        public override void Next()
        {
            if (Roster.AllManuversAreAssigned(RequiredPlayer))
            {
                HideAssignedManeuversInHotSeatGame();

                if (RequiredPlayer == Phases.PlayerWithInitiative)
                {
                    RequiredPlayer = Roster.AnotherPlayer(RequiredPlayer);

                    UpdateHelpInfo();
                    Roster.HighlightShipsFiltered(FilterShipsToAssignManeuver);
                    Roster.GetPlayer(RequiredPlayer).AssignManeuver();
                }
                else
                {
                    FinishPhase();
                }
            }
        }
Exemplo n.º 27
0
        private void TryRegisterAbility(object sender, System.EventArgs e)
        {
            Players.GenericPlayer opponent = Roster.GetPlayer(Roster.AnotherPlayer(HostShip.Owner.PlayerNo));
            foreach (GenericShip ship in opponent.Ships.Values)
            {
                if (HostShip.SectorsInfo.IsShipInSector(ship, ArcType.Bullseye))
                {
                    Triggers.RegisterTrigger(new Trigger()
                    {
                        Name         = ship.ShipId + ": " + Name,
                        TriggerType  = TriggerTypes.OnAbilityDirect,
                        TriggerOwner = opponent.PlayerNo,
                        EventHandler = ShowChooseEffect,
                        Sender       = ship
                    });
                }
            }

            Triggers.ResolveTriggers(TriggerTypes.OnAbilityDirect, Triggers.FinishTrigger);
        }
Exemplo n.º 28
0
        private void TryRegisterAbility(object sender, System.EventArgs e)
        {
            Players.GenericPlayer opponent = Roster.GetPlayer(Roster.AnotherPlayer(HostShip.Owner.PlayerNo));
            foreach (var ship in opponent.Ships)
            {
                ShotInfo shotInfo = new ShotInfo(HostShip, ship.Value, HostShip.PrimaryWeapon);
                if (shotInfo.InArcByType(ArcTypes.Bullseye))
                {
                    Triggers.RegisterTrigger(new Trigger()
                    {
                        Name         = ship.Value.ShipId + ": " + Name,
                        TriggerType  = TriggerTypes.OnAbilityDirect,
                        TriggerOwner = opponent.PlayerNo,
                        EventHandler = ShowChooseEffect,
                        Sender       = ship.Value
                    });
                }
            }

            Triggers.ResolveTriggers(TriggerTypes.OnAbilityDirect, Triggers.FinishTrigger);
        }
Exemplo n.º 29
0
    public static void TryPerformAttack()
    {
        Game.UI.HideContextMenu();
        MovementTemplates.ReturnRangeRuler();

        if (Rules.TargetIsLegalForShot.IsLegal() && ChosenWeapon.IsShotAvailable(Selection.AnotherShip))
        {
            Game.UI.HideSkipButton();
            ShotInfo = (ChosenWeapon.GetType() == typeof(Ship.PrimaryWeaponClass)) ? ShotInfo : new ShipShotDistanceInformation(Selection.ThisShip, Selection.AnotherShip, ChosenWeapon);
            ShotInfo.CheckFirelineCollisions(delegate { PerformAttack(Selection.ThisShip, Selection.AnotherShip); });
        }
        else
        {
            if (Roster.GetPlayer(Phases.CurrentPhasePlayer).GetType() == typeof(Players.HumanPlayer))
            {
                // TODO: Better explanations
                if (!Rules.TargetIsLegalForShot.IsLegal())
                {
                    Messages.ShowError("Attack is not legal (this ship cannot attack or target cannot be attacked)");
                }
                else if (!ShotInfo.InShotAngle)
                {
                    Messages.ShowError("Target is outside your firing arc");
                }
                else if (ShotInfo.Distance > ChosenWeapon.MaxRange || ShotInfo.Distance < ChosenWeapon.MinRange)
                {
                    Messages.ShowError("Target is outside your firing range");
                }

                //TODO: except non-legal targets, bupmed for example, biggs?
                Roster.HighlightShipsFiltered(Roster.AnotherPlayer(Phases.CurrentPhasePlayer));
                Game.UI.HighlightNextButton();
            }
            else
            {
                Selection.ThisShip.IsAttackPerformed = true;
                Phases.FinishSubPhase(typeof(SubPhases.CombatSubPhase));
            }
        }
    }
Exemplo n.º 30
0
        public override void Initialize()
        {
            ShowObstaclesHolder();

            MinBoardEdgeDistance = Board.BoardIntoWorld(2 * Board.RANGE_1);
            MinObstaclesDistance = Board.BoardIntoWorld(Board.RANGE_1);

            RequiredPlayer = Roster.AnotherPlayer(Phases.PlayerWithInitiative); // Will be changed in Next
            ChosenObstacle = null;

            foreach (GenericPlayer player in Roster.Players)
            {
                if (player.PlayerType == PlayerType.Ai)
                {
                    IsRandomSetupSelected[player.PlayerNo] = true;
                }
            }

            ObstaclesManager.SetObstaclesCollisionDetectionQuality(CollisionDetectionQuality.Low);

            Next();
        }