Exemple #1
0
        private void DamageBadGuy(IShip badGuyShip, Actors.System badGuyShields)
        {
            string badGuyShipName     = badGuyShip.Name;
            string badguyShieldEnergy = badGuyShields.Energy.ToString();

            if (badGuyShip.GetRegion().Type == RegionType.Nebulae)
            {
                badGuyShipName     = "Unknown Hostile Ship";
                badguyShieldEnergy = "Unknown level";
            }

            var badGuy = Utility.Utility.HideXorYIfNebula(badGuyShip.GetRegion(), badGuyShip.Sector.X.ToString(), badGuyShip.Sector.Y.ToString());

            this.Game.Write.Line(
                string.Format(
                    "Hit " + badGuyShipName + " at sector [{0},{1}], shield strength now at {2}.",
                    badGuy.X, badGuy.Y, badguyShieldEnergy));
        }
Exemple #2
0
        /// <summary>
        /// Removes all friendlies fromevery sector in the entire map.  Sets down a friendly
        /// </summary>
        /// <param name="map"></param>
        /// <param name="newLocation"></param>
        public void SetPlayershipInLocation(IShip shipToSet, IMap map, Location newLocation)
        {
            this.RemovePlayership(map);

            newLocation.Region.SetActive();

            var foundSector = this.LookupSector(shipToSet.GetRegion(), newLocation);

            foundSector.Item = SectorItem.PlayerShip;

            shipToSet.Coordinate = newLocation.Region;
            shipToSet.Sector     = foundSector;
        }
Exemple #3
0
        public static string MisfireMessage(IShip attacker)
        {
            var attackerRegion = attacker.GetRegion();
            var attackerSector = Utility.Utility.HideXorYIfNebula(attackerRegion, attacker.Sector.X.ToString(), attacker.Sector.Y.ToString());

            string attackerName = attackerRegion.Type == RegionType.Nebulae ? "Unknown Ship" : attacker.Name;

            if (attacker.Faction == FactionName.Federation)
            {
                attackerName = attacker.Name;
            }

            //HACK: until starbases become real objects.. getting tired of this.
            if (attackerName == "Enterprise")
            {
                attackerName = "Hostile Starbase";
            }

            return(String.Format("Misfire by " + attackerName + " at sector [{0},{1}].", attackerSector.X, attackerSector.Y));
        }
Exemple #4
0
        private void AttackNonDockedPlayership(IMap map, IShip badGuy, int randomFactor)
        {
            var playerShipLocation = map.Playership.GetLocation();
            var distance           = Utility.Utility.Distance(playerShipLocation.Sector.X,
                                                              playerShipLocation.Sector.Y,
                                                              badGuy.Sector.X,
                                                              badGuy.Sector.Y);

            int seedEnergyToPowerWeapon = this.Config.GetSetting <int>("DisruptorShotSeed") * randomFactor;

            var inNebula = badGuy.GetRegion().Type == RegionType.Nebulae;

            //Todo: this should be Disruptors.For(this.ShipConnectedTo).Shoot()
            //todo: the -1 should be the ship energy you want to allocate
            var attackingEnergy = (int)Utility.Utility.ShootBeamWeapon(seedEnergyToPowerWeapon, distance, "DisruptorShotDeprecationLevel", "DisruptorEnergyAdjustment", inNebula);

            var shieldsValueBeforeHit = Shields.For(map.Playership).Energy;

            map.Playership.AbsorbHitFrom(badGuy, attackingEnergy);

            this.ReportShieldsStatus(map, shieldsValueBeforeHit);
        }
Exemple #5
0
        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);
            }
        }
Exemple #6
0
        private Region TravelThroughRegions(int distance, int direction, IShip playership)
        {
            // 4   5   6
            //   \ ↑ /
            //3 ← <*> → 7
            //   / ↓ \
            // 2   1   8

            //todo: get rid of this double-stuff. I'm only doing this so that IsGalacticBarrier can be used by both Region and Sector Navigation.
            int currentQX = playership.GetRegion().X;
            int currentQY = playership.GetRegion().Y;

            for (int i = 0; i < distance; i++)
            {
                switch (direction)
                {
                case 3:
                    currentQX--;     //left
                    break;

                case 4:
                    currentQX--;     //left
                    currentQY--;     //up
                    break;

                case 5:
                    currentQY--;     //up
                    break;

                case 6:
                    currentQX++;     //right
                    currentQY--;     //up
                    break;

                case 7:
                    currentQX++;     //right
                    break;

                case 8:
                    currentQX++;     //right
                    currentQY++;     //down
                    break;

                case 1:
                    currentQY++;     //down
                    break;

                case 2:
                    currentQX--;     //left
                    currentQY++;     //down
                    break;
                }

                //todo: check if Region is nebula or out of bounds

                var barrierHit = this.IsGalacticBarrier(ref currentQX, ref currentQY);  //XY will be set to safe value in here
                if (barrierHit)
                {
                    break;
                }
                else
                {
                    bool nebulaEncountered = Regions.IsNebula(ShipConnectedTo.Map, new Coordinate(Convert.ToInt32(currentQX), Convert.ToInt32(currentQY)));
                    if (nebulaEncountered)
                    {
                        this.Game.Write.Line("Nebula Encountered. Navigation stopped to manually recalibrate warp coil");
                        break;
                    }
                }
            }

            return(Regions.Get(ShipConnectedTo.Map, new Coordinate(Convert.ToInt32(currentQX), Convert.ToInt32(currentQY))));

            //todo: once we have found Region..
            //is target location blocked?
            //if true, then output that expected location was blocked, and ship's computers have picked a new spot

            //while loop
            //   pick a random sector
            //   check it for obstacle
            //if good then jump out of loop
        }