Exemplo n.º 1
0
        public static SpaceShip CreateRandomModel(string modelName, Player player)
        {
            var    defaultModels = SpaceShip.GetDefaultModels();
            Random rand          = new Random();
            int    modelNum      = rand.Next(0, defaultModels.Count - 1);

            return(defaultModels.Values.ElementAt(modelNum).Clone(player));
        }
Exemplo n.º 2
0
        public static SpaceShip CreateModel(string modelName, Player player)
        {
            var defaultModels = SpaceShip.GetDefaultModels();

            if (defaultModels.ContainsKey(modelName))
            {
                SpaceShip    ship     = defaultModels[modelName].Clone(player);
                GameLocation location = player.Location;
                if (location.SystemBody != null)
                {
                    ship.Coords         = location.SystemBody.Coords;
                    ship.SystemLocation = location.SystemBody.SystemLocation;
                }
                else if (location.StarSystem != null)
                {
                    ship.Coords         = location.StarSystem.Coords;
                    ship.SystemLocation = new SystemLocation(0, 0, 0);
                    ship.SystemLocation.RandomizeInSystemCoords();
                }
                else if (location.Sector != null)
                {
                    ship.Coords         = location.Sector.Coords;
                    ship.SystemLocation = new SystemLocation(
                        Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity
                        );
                }
                else
                {
                    // this can't be possible
                    ship.Coords         = new Coords(new GalacticLocation(0, 0, 0));
                    ship.SystemLocation = new SystemLocation(
                        Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity
                        );
                }

                return(ship);
            }
            else
            {
                return(null);
            }
        }