private void PlaceCooledContainersOnBoat(Selection selection)
        {
            bool _hasCooledContainer = DockedContainers.Exists(c => c.Cooled);

            if (_hasCooledContainer && (selection.Place == 1 || selection.Place == 2))
            {
                List <Container> _tempCooledContainers = DockedContainers.FindAll(c => c.Cooled);

                foreach (Container container in _tempCooledContainers.ToList())
                {
                    if (selection.AddContainer(container))
                    {
                        _tempCooledContainers.Remove(container);
                        DockedContainers.Remove(container);
                    }
                }
            }
        }
        private void PlaceDefualtContainersOnBoat(Selection selection)
        {
            bool _hasDefualtContainer = DockedContainers.Exists(c => c.Standard);

            if (_hasDefualtContainer)
            {
                List <Container> _tempDefaultContainers = DockedContainers.FindAll(c => c.Standard);

                foreach (Container container in _tempDefaultContainers.ToList())
                {
                    if (selection.AddContainer(container))
                    {
                        _tempDefaultContainers.Remove(container);
                        DockedContainers.Remove(container);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Places the docked containers to the right selections.
        /// </summary>
        private void PlaceContainers()
        {
            //Loops through every selection of the ship and try to fit the containers
            for (int i = 0; i < 8; i++)
            {
                //Check if there are containers in the docking list and returns true or false
                bool _containsValue   = DockedContainers.Exists(c => c.Valuable);
                bool _containsCooled  = DockedContainers.Exists(c => c.Cooled);
                bool _containsdefault = DockedContainers.Exists(c => c.Standard);

                //select the current selection by the for loop Index
                Selection selection = ship.Selections[i];

                //Check if there are valuable containers and if the selection places are met
                if (_containsValue && (selection.Place == 1 || selection.Place == 2 || selection.Place == 7 ||
                                       selection.Place == 8))
                {
                    //Find all the valuable containers
                    List <Container> _tempValueContainers = DockedContainers.FindAll(c => c.Valuable);

                    //Foreach through the valuable container list
                    foreach (Container container in _tempValueContainers.ToList())
                    {
                        //Send the container too the selection class and try's to add the container to the list of the selection.
                        //if result is true then the placed container can be deleted.
                        if (selection.AddContainer(container))
                        {
                            _tempValueContainers.Remove(container);
                            DockedContainers.Remove(container);
                        }
                    }
                }

                //Check if there are cooled containers and if the selection places are met
                if (_containsCooled && (selection.Place == 1 || selection.Place == 2))
                {
                    //Find all the cooled containers
                    List <Container> _tempCooledContainers = DockedContainers.FindAll(c => c.Cooled);

                    //Foreach through the cooled container list
                    foreach (Container container in _tempCooledContainers.ToList())
                    {
                        //Send the container too the selection class and try's to add the container to the list of the selection.
                        //if result is true then the placed container can be deleted.
                        if (selection.AddContainer(container))
                        {
                            _tempCooledContainers.Remove(container);
                            DockedContainers.Remove(container);
                        }
                    }
                }

                //Check if there are default containers
                if (_containsdefault)
                {
                    //Find all the default containers
                    List <Container> _tempDefaultContainers = DockedContainers.FindAll(c => c.Standard);

                    //Foreach through the default container list
                    foreach (Container container in _tempDefaultContainers.ToList())
                    {
                        //Send the container too the selection class and try's to add the container to the list of the selection.
                        //if result is true then the placed container can be deleted.
                        if (selection.AddContainer(container))
                        {
                            _tempDefaultContainers.Remove(container);
                            DockedContainers.Remove(container);
                        }
                    }
                }
            }
        }