예제 #1
0
        public List <KeyValuePair <int, Sector> > ListObjectsInRegion()
        {
            var list = new List <KeyValuePair <int, Sector> >();

            if (this.Damaged())
            {
                Game.Write.Line("Unable to List Objects in Region");
                return(list);
            }

            var sectorsWithObjects = ShortRangeScan.For(this.ShipConnectedTo).ObjectFinder().ToList();

            if (sectorsWithObjects.Any())
            {
                int objectNumber = 1;
                foreach (var sector in sectorsWithObjects)
                {
                    string objectName = sector.Object != null ? sector.Object.Name : "Unknown";

                    this.Game.Write.SingleLine(string.Format(objectNumber + ": {0}  [{1},{2}].", objectName, (sector.X + 1),
                                                             (sector.Y + 1)));

                    list.Add(new KeyValuePair <int, Sector>(objectNumber, sector));

                    objectNumber++;
                }
            }
            else
            {
                this.Game.Write.Line("No Sectors with Objects found (this is an error)");
            }

            return(list);
        }
예제 #2
0
        public void Controls()
        {
            if (this.Damaged())
            {
                return;
            }

            if (ShortRangeScan.For(this.ShipConnectedTo).Damaged())
            {
                this.Game.Write.Line("Combined Scan needs SRS Subsystem in order to run.");
            }

            this.Game.Write.RenderSectors(SectorScanType.CombinedRange, this);
        }
예제 #3
0
        public IEnumerable <Sector> ObjectFinder()
        {
            var objects = new List <Sector>();

            if (ShortRangeScan.For(this.ShipConnectedTo).Damaged())
            {
                this.Game.Write.Line("Cannot locate Objects for calculations");
                return(objects);
            }

            var thisRegion = this.ShipConnectedTo.GetRegion();

            IEnumerable <Sector> sectorsWithObjects = thisRegion.Sectors.Where(s => s.Item != SectorItem.Empty);

            return(sectorsWithObjects);
        }
예제 #4
0
        public void WarpControls()
        {
            if (this.Damaged())
            {
                this.SetMaxWarpFactor();
            }

            int distance;
            int direction;

            if (this.Movement.InvalidCourseCheck(out direction))
            {
                return;
            }


            if (this.Warp.InvalidWarpFactorCheck(this.MaxWarpFactor, out distance))
            {
                return;
            }

            int lastRegionY;
            int lastRegionX;

            if (!Warp.Engage(direction, distance, out lastRegionY, out lastRegionX, this.Game.Map))
            {
                return;
            }

            this.RepairOrTakeDamage(lastRegionX, lastRegionY);

            var crs = CombinedRangeScan.For(this.ShipConnectedTo);

            if (crs.Damaged())
            {
                ShortRangeScan.For(this.ShipConnectedTo).Controls();
            }
            else
            {
                crs.Controls();
            }

            //todo: upon arriving in Region, all damaged controls need to be enumerated
            //this.Game.Write.OutputConditionAndWarnings(this.ShipConnectedTo, this.Game.Config.GetSetting<int>("ShieldsDownLevel"));
        }
예제 #5
0
        public void SublightControls()
        {
            int distance;
            int direction;

            if (this.Movement.InvalidCourseCheck(out direction))
            {
                return;
            }

            if (this.Impulse.InvalidSublightFactorCheck(this.MaxWarpFactor, out distance))
            {
                return;
            }

            int lastRegionY;
            int lastRegionX;

            if (!Impulse.Engage(direction, distance, out lastRegionY, out lastRegionX, this.Game.Map))
            {
                return;
            }

            this.RepairOrTakeDamage(lastRegionX, lastRegionY);

            var crs = CombinedRangeScan.For(this.ShipConnectedTo);

            if (crs.Damaged())
            {
                ShortRangeScan.For(this.ShipConnectedTo).Controls();
            }
            else
            {
                crs.Controls();
            }
        }
예제 #6
0
        //output this as KeyValueCollection that the UI can display as it likes.

        public void PrintCurrentStatus(IMap map, int computerDamage, Ship ship, Region currentRegion)
        {
            if (this.Damaged())
            {
                return;
            }

            //todo: completely redo this

            this.Game.Write.Console.WriteLine("");
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSTimeRemaining"), map.timeRemaining);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSHostilesRemaining"), map.Regions.GetHostileCount());
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSHostilesInRegion"), currentRegion.GetHostiles().Count);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSStarbases"), map.starbases);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSWarpEngineDamage"), Navigation.For(ship).Damage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSSRSDamage"), ShortRangeScan.For(ship).Damage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSLRSDamage"), LongRangeScan.For(ship).Damage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSCRSDamage"), CombinedRangeScan.For(ship).Damage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSShieldsDamage"), Shields.For(ship).Damage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSComputerDamage"), computerDamage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSPhotonDamage"), Torpedoes.For(ship).Damage);
            this.Game.Write.Console.WriteLine(this.Game.Config.GetText("CSPhaserDamage"), Phasers.For(ship).Damage);
            this.Game.Write.Console.WriteLine();

            //foreach (var badGuy in currentRegion.Hostiles)
            //{
            //
            //}

            this.Game.Write.Console.WriteLine();

            //todo: Display all baddie names in Region when encountered.
        }