Beispiel #1
0
        public void SetupPlayerShipInSectors(SectorDefs sectorDefs)
        {
            //if we have > 0 friendlies with XYs, then we will place them.
            //if we have at least 1 friendly with no XY, then config will be used to generate that type of ship.

            if (sectorDefs.PlayerShips().Any())
            {
                try
                {
                    this.SetUpPlayerShip(sectorDefs.PlayerShips().Single());

                    var sectorToPlaceShip = Sector.Get(this.Regions.GetActive().Sectors, this.Playership.Sector.X, this.Playership.Sector.Y);

                    //This places our newly created ship into our newly created List of Regions.
                    sectorToPlaceShip.Item = SectorItem.PlayerShip;
                }
                catch (InvalidOperationException ex)
                {
                    throw new GameConfigException(this.Config.GetSetting <string>("InvalidPlayershipSetup") + ex.Message);
                }
                catch (Exception ex)
                {
                    throw new GameConfigException(this.Config.GetSetting <string>("ErrorPlayershipSetup") + ex.Message);
                }
            }
            else
            {
                //this.Regions[0].Active = true;
                this.Regions[0].SetActive();
            }
        }
Beispiel #2
0
        public void Initialize(SectorDefs sectorDefs, bool generateWithNebulae)
        {
            this.GetGlobalInfo();

            //This list should match baddie type that is created
            List <string> RegionNames = this.Config.GetStarSystems();

            this.Write.DebugLine("Got Starsystems");

            //TODO: if there are less than 64 Region names then there will be problems..

            var names = new Stack <string>(RegionNames.Shuffle());

            var klingonShipNames = this.Config.FactionShips(this.DefaultHostile);

            this.Write.DebugLine("Got Baddies");

            //todo: modify this to populate with multiple faction types..
            var klingonBaddieNames = new Stack <string>(klingonShipNames.Shuffle());

            //todo: this just set up a "friendly"
            this.InitializeRegionsWithBaddies(names, klingonBaddieNames, this.DefaultHostile, sectorDefs, generateWithNebulae);

            this.Write.DebugLine("Intialized Regions with Baddies");

            if (sectorDefs != null)
            {
                this.SetupPlayerShipInSectors(sectorDefs);
            }

            //Modify this to output everything
            if (Constants.DEBUG_MODE)
            {
                //TODO: write a hidden command that displays everything. (for debug purposes)

                this.Write.DisplayPropertiesOf(this.Playership); //This line may go away as it should be rolled out with a new Region
                this.Write.Line(this.Config.GetSetting <string>("DebugModeEnd"));
                this.Write.Line("");
            }

            this.Playership.UpdateDivinedSectors();
        }
Beispiel #3
0
        //Creates a 2D array of Regions.  This is how all of our game pieces will be moving around.
        public void InitializeRegionsWithBaddies(Stack <string> names, Stack <string> baddieNames, FactionName stockBaddieFaction, SectorDefs sectorDefs, bool generateWithNebulae)
        {
            this.Regions = new Regions(this, this.Write);

            //Friendlies are added separately
            List <Sector> itemsToPopulateThatAreNotPlayerShip = sectorDefs.ToSectors(this.Regions).Where(q => q.Item != SectorItem.PlayerShip).ToList();

            this.Write.DebugLine("ItemsToPopulate: " + itemsToPopulateThatAreNotPlayerShip.Count + " Regions: " + this.Regions.Count);

            //todo: this can be done with a single loop populating a list of XYs
            this.GenerateSquareGalaxy(names, baddieNames, stockBaddieFaction, itemsToPopulateThatAreNotPlayerShip, generateWithNebulae);
        }