Ejemplo n.º 1
0
        private static void ShowAvailablePilots(Faction faction, string shipName)
        {
            availablePilotsCounter = 0;

            ShipRecord shipRecord = AllShips.Find(n => n.ShipName == shipName);

            List <PilotRecord> AllPilotsFiltered = AllPilots
                                                   .Where(n =>
                                                          n.PilotShip == shipRecord &&
                                                          n.PilotFaction == faction &&
                                                          n.Instance.GetType().ToString().Contains(Edition.Current.NameShort)
                                                          )
                                                   .OrderByDescending(n => n.PilotSkill).
                                                   OrderByDescending(n => n.Instance.PilotInfo.Cost).
                                                   ToList();
            int pilotsCount = AllPilotsFiltered.Count();

            Transform contentTransform = GameObject.Find("UI/Panels/SelectPilotPanel/Panel/Scroll View/Viewport/Content").transform;

            DestroyChildren(contentTransform);
            contentTransform.localPosition = new Vector3(0, contentTransform.localPosition.y, contentTransform.localPosition.z);
            contentTransform.GetComponent <RectTransform>().sizeDelta = new Vector2(pilotsCount * (PILOT_CARD_WIDTH + DISTANCE_MEDIUM) + 2 * DISTANCE_MEDIUM, 0);

            foreach (PilotRecord pilot in AllPilotsFiltered)
            {
                ShowAvailablePilot(pilot);
            }
        }
Ejemplo n.º 2
0
 public void CreateFleet()
 {
     for (int shipSize = 4; shipSize > 0; shipSize--)
     {
         for (int shipQuantity = 1; shipQuantity < 6 - shipSize; shipQuantity++)
         {
             AllShips.Add(new Ship(shipSize, this));
         }
     }
 }
Ejemplo n.º 3
0
        public void UpdateSearchResultsForSearchController(UISearchController searchController)
        {
            if (string.IsNullOrEmpty(searchController.SearchBar.Text))
            {
                SearchShips = null;
                TableView.ReloadData();
                return;
            }

            SearchShips = AllShips.Where(r => r.Title.Contains(searchController.SearchBar.Text)).ToList();
            TableView.ReloadData();
        }
Ejemplo n.º 4
0
 public void AskPlayerToPlaceShip(int shipSize)
 {
     if (shipSize > 1)
     {
         var doubleCoord = DoubleCoord.CreateBothCoords(shipSize, this);
         AllShips.Add(new Ship(doubleCoord, this));
     }
     else
     {
         var coord = Coord.CreateNewCoord(this, shipSize, "");
         AllShips.Add(new Ship(coord, this));
     }
 }
Ejemplo n.º 5
0
        public Ship Spawn(ShipSpecification spec, Position p)
        {
            var ship = new Ship();

            ship.Initialize(spec);
            ship.Position = p;
            ship.ShipId   = 1;
            if (AllShips.Any())
            {
                ship.ShipId = AllShips.Max(x => x.ShipId) + 1;
            }
            AllShips.Add(ship);
            return(ship);
        }
Ejemplo n.º 6
0
        private static void ShowAvailableShips(Faction faction)
        {
            DestroyChildren(GameObject.Find("UI/Panels/SelectShipPanel/Panel").transform);
            availableShipsCounter = 0;

            foreach (ShipRecord ship in AllShips.OrderBy(s => s.Instance.ShipInfo.ShipName))
            {
                if (ship.Instance.ShipInfo.FactionsAll.Contains(faction) && !ship.Instance.IsHidden)
                {
                    if (ship.Instance.GetType().ToString().Contains(Edition.Current.NameShort))
                    {
                        ShowAvailableShip(ship, faction);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private static void ShowAvailableShips(Faction faction)
        {
            DestroyChildren(GameObject.Find("UI/Panels/SelectShipPanel/Panel").transform);
            availableShipsCounter = 0;

            foreach (ShipRecord ship in AllShips.OrderBy(s => s.Instance.FullType))
            {
                if (ship.Instance.factions.Contains(faction) && !ship.Instance.IsHidden)
                {
                    if (RuleSet.Instance.ShipIsAllowed(ship.Instance))
                    {
                        ShowAvailableShip(ship);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public void ExecuteSimultaneousFireDeclarations(IReadOnlyCollection <OffensiveFireDeclaration> fireDeclarations)
        {
            var salvos = GenerateSalvos(fireDeclarations);

            foreach (var salvo in salvos)
            {
                var ship = AllShips.Single(x => x.ShipId == salvo.TargetShipId);

                var useTargeting           = salvo.Targeting;
                var damageRemainingToApply = salvo.TotalDamage;

                var applyDamageToFace = salvo.IncomingDamageDirection;
                for (int i = 0; i < ship.Position.Rotation; i++)
                {
                    applyDamageToFace = applyDamageToFace.RotateLeft();
                }

                ApplyDamage(damageRemainingToApply, applyDamageToFace, useTargeting, ship, DamageType.WeaponFire);
            }
        }
Ejemplo n.º 9
0
        public Universe Clone()
        {
            var ships = AllShips.Select(s => s.Clone()).ToArray();

            return(new Universe(Planet, ships, Tick));
        }
Ejemplo n.º 10
0
 private static string GetNameOfShip(SquadBuilderShip squadBuilderShip)
 {
     return(AllShips.Find(n => n.ShipName == squadBuilderShip.Panel.transform.Find("GroupShip/DropdownShip").GetComponent <Dropdown>().captionText.text).ShipNamespace);
 }
Ejemplo n.º 11
0
        public void AdvanceGame()
        {
            var turn = this.GetOrCreateTurn(this.SimulationTimeStamp.TurnNumber);

            if (this.SimulationTimeStamp.TurnStep == TurnStep.EnergyAllocation)
            {
                AllShips.ForEach(x =>
                {
                    if (turn.EnergyAllocations.ContainsKey(x.ShipId))
                    {
                        var energyAllocation = turn.EnergyAllocations[x.ShipId];
                        x.ExecuteDeclaredEnergyAllocation(energyAllocation);
                    }
                    else
                    {
                        var energyAllocation = x.CreateDefaultEnergyAllocation();
                        x.ExecuteDeclaredEnergyAllocation(energyAllocation);
                    }
                });

                this.SimulationTimeStamp = SimulationTimeStamp.Increment();

                return;
            }

            if (this.SimulationTimeStamp.TurnStep == TurnStep.ImpulseProcess)
            {
                if (this.SimulationTimeStamp.ImpulseStep == ImpulseStep.SpeedChange)
                {
                    this.SimulationTimeStamp = SimulationTimeStamp.Increment();
                    return;
                }

                if (this.SimulationTimeStamp.ImpulseStep == ImpulseStep.Movement)
                {
                    AllShips.ForEach(x =>
                    {
                        var declaredNavigation =
                            turn.ImpulseProcessActions.GetDeclaredNavigation(x.ShipId, this.SimulationTimeStamp);
                        ExecutePlottedNavigation(x, declaredNavigation);
                    });

                    this.SimulationTimeStamp = SimulationTimeStamp.Increment();
                    return;
                }

                if (this.SimulationTimeStamp.ImpulseStep == ImpulseStep.OffensiveFire)
                {
                    var fireDeclarations
                        = AllShips.Select(x => turn.ImpulseProcessActions.GetOffensiveFire(x.ShipId, this.SimulationTimeStamp))
                          .Where(x => x != null).ToList();


                    ExecuteSimultaneousFireDeclarations(fireDeclarations);

                    this.SimulationTimeStamp = SimulationTimeStamp.Increment();
                    return;
                }
            }

            if (this.SimulationTimeStamp.TurnStep == TurnStep.RepairPhase)
            {
                AllShips.ForEach(x => x.RolloverExcessEnergyIntoBatteries());
                AllShips.ForEach(x => x.RechargeWeapons());
                this.SimulationTimeStamp = SimulationTimeStamp.Increment();
                return;
            }
        }
Ejemplo n.º 12
0
        public virtual List <Tuple <char, int> > SetShip(List <Square> board)
        {
            List <Tuple <char, int> > Right(Tuple <char, int> selectedPoint)
            {
                char nextColumn = selectedPoint.Item1;

                nextColumn += (char)Size;
                var endPoint = new Tuple <char, int>(nextColumn, selectedPoint.Item2);

                List <Tuple <char, int> > tempList = new List <Tuple <char, int> >();

                for (char i = selectedPoint.Item1; i <= endPoint.Item1; i++)
                {
                    var square = new Tuple <char, int>(i, selectedPoint.Item2);
                    if (board.Any(r => r.Position.Equals(square) && r.ShipType is null && !AllShips.Any(r => r.Any(rr => rr.Equals(square)))))
                    {
                        tempList.Add(new Tuple <char, int>(i, selectedPoint.Item2));
                    }