private IRSResult GetSectorData(Region currentRegion, ICoordinate sector, Game game) { Sector sectorToScan = this.Sectors.GetNoError(sector); Coordinate xx = sectorToScan ?? new Coordinate(sector.X, sector.Y, false); ISector sectorToExamine = new Sector(new LocationDef(currentRegion, xx), false); var locationToExamine = new Location(currentRegion, sectorToExamine); Location divinedLocationOnMap = currentRegion.DivineSectorOnMap(locationToExamine, this.Map); if (divinedLocationOnMap.Region.Type != RegionType.GalacticBarrier) { int i; } else { } IRSResult sectorResult = ImmediateRangeScan.For(game.Map.Playership).Execute(divinedLocationOnMap); return(sectorResult); }
private void TravelThroughSectors(int distance, int direction, IShip travellingShip) { // 4 5 6 // \ ↑ / //3 ← <*> → 7 // / ↓ \ // 2 1 8 direction = -direction + 8; var currentRegion = travellingShip.GetRegion(); int currentSX = travellingShip.Sector.X; int currentSY = travellingShip.Sector.Y; for (int i = 0; i < distance; i++) { switch (Convert.ToInt32(direction)) { case 3: currentSX--; //left break; case 4: currentSX--; //left currentSY--; //up break; case 5: currentSY--; //up break; case 6: currentSX++; //right currentSY--; //up break; case 7: currentSX++; //right break; case 0: currentSX++; //right currentSY++; //down break; case 1: currentSY++; //down break; case 2: currentSX--; //left currentSY++; //down break; } //if on the edge of a Region, newSector will have negative numbers var newSectorCandidate = new Sector(new LocationDef(currentRegion.X, currentRegion.Y, Convert.ToInt32(currentSX), Convert.ToInt32(currentSY), false), false); var locationToScan = new Location(this.ShipConnectedTo.GetRegion(), newSectorCandidate); //run IRS on sector we are moving into IRSResult scanResult = ImmediateRangeScan.For(this.ShipConnectedTo).Scan(locationToScan); //If newSectorCandidate had negative numbers, then scanResult will have the newly updated region in it if (scanResult.GalacticBarrier) { this.Game.Write.Line("All Stop. Cannot cross Galactic Barrier."); return; } else { //throw new NotImplementedException(); //how we gonna check for obstacles if scanresult has bad numbers in it? //AdjustSectorToNewRegion may need to be called here bool obstacleEncountered = this.SublightObstacleCheck((Coordinate)travellingShip.Sector, newSectorCandidate, currentRegion.Sectors); if (obstacleEncountered) { this.Game.Write.Line("All Stop."); return; } //bool nebulaEncountered = Sectors.IsNebula(ShipConnectedTo.Map, new Coordinate(Convert.ToInt32(currentSX), Convert.ToInt32(currentSY))); //if (nebulaEncountered) //{ // this.Game.Write.Line("Nebula Encountered. Navigation stopped to manually recalibrate warp coil"); // return; //} } Location newLocation = locationToScan; newLocation.Region = this.Game.Map.Regions.Where(r => r.Name == scanResult.RegionName).Single(); //todo: finish this. var shipRegion = travellingShip.GetRegion(); if (newLocation.Region != shipRegion) { newLocation.Sector = this.AdjustSectorToNewRegion(newLocation, this.Game.Map, shipRegion); } this.Game.Map.SetPlayershipInLocation(travellingShip, this.Game.Map, newLocation); //todo: this.Game.MoveTimeForward(this.Game.Map, new Coordinate(lastRegionX, lastRegionY), newLocation); } }
//This needs to be a command method that the UI passes values into. //Readline is done in UI public void Prompt(Ship playerShip, string mapText, Game game) { this.Console.Write(mapText); var readLine = this.Console.ReadLine(); if (readLine == null) { return; } var command = readLine.Trim().ToLower(); switch (command) { case "wrp": case "imp": case "nto": Navigation.For(playerShip).Controls(command); break; case "irs": ImmediateRangeScan.For(playerShip).Controls(); break; case "srs": ShortRangeScan.For(playerShip).Controls(); break; case "lrs": LongRangeScan.For(playerShip).Controls(); break; case "crs": CombinedRangeScan.For(playerShip).Controls(); break; case "pha": Phasers.For(playerShip).Controls(playerShip); break; case "tor": Torpedoes.For(playerShip).Controls(); break; case "she": this.ShieldMenu(playerShip); break; case "com": this.ComputerMenu(playerShip); break; case "toq": Computer.For(playerShip).Controls(command); break; case "dmg": this.DamageControlMenu(playerShip); break; //Utility Commands case "dbg": this.DebugMenu(playerShip); break; case "ver": this.Console.WriteLine(this.Config.GetText("AppVersion").TrimStart(' ')); break; case "cls": this.Console.Clear(); break; default: //case "?": this.CreateCommandPanel(); this.Panel(this.GetPanelHead(playerShip.Name), ACTIVITY_PANEL); break; } }