Esempio n. 1
0
        public void AddShouldNotThrow()
        {
            StarportBuilder builder = new StarportBuilder(Guid.NewGuid().ToString(), SolarSystems.Daibara);
            Starport        random  = builder.Build();

            _repository.CommitChanges(random);
        }
Esempio n. 2
0
        private void LoadBaseDetailsPage()
        {
            var    data           = BaseService.GetPlayerTempData(GetPC());
            PCBase pcBase         = DataService.PCBase.GetByID(data.PCBaseID);
            Area   dbArea         = DataService.Area.GetByResref(pcBase.AreaResref);
            var    owner          = DataService.Player.GetByID(pcBase.PlayerID);
            bool   canExtendLease = BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanExtendLease);
            bool   canCancelLease = BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanCancelLease);

            int dailyUpkeep = dbArea.DailyUpkeep + (int)(dbArea.DailyUpkeep * (owner.LeaseRate * 0.01f));

            string header = ColorTokenService.Green("Location: ") + dbArea.Name + " (" + pcBase.Sector + ")\n\n";

            header += ColorTokenService.Green("Owned By: ") + owner.CharacterName + "\n";
            header += ColorTokenService.Green("Purchased: ") + pcBase.DateInitialPurchase + "\n";
            header += ColorTokenService.Green("Rent Due: ") + pcBase.DateRentDue + "\n";
            header += ColorTokenService.Green("Daily Upkeep: ") + dailyUpkeep + " credits\n\n";
            header += "Daily upkeep may be paid up to 30 days in advance.\n";

            // Starships have slightly different setups.  They only pay rent when in a public starport and
            // the cost is set by the starport.
            if (pcBase.PCBaseTypeID == (int)Enumeration.PCBaseType.Starship)
            {
                canCancelLease = false;

                if (SpaceService.IsLocationPublicStarport(pcBase.ShipLocation))
                {
                    var      shipLocationGuid = new Guid(pcBase.ShipLocation);
                    Starport starport         = DataService.Starport.GetByStarportID(shipLocationGuid);
                    header  = ColorTokenService.Green("Location: ") + starport.Name + " (" + starport.PlanetName + ")\n";
                    header += ColorTokenService.Green("Rent Due: ") + pcBase.DateRentDue + "\n";
                    header += ColorTokenService.Green("Daily Upkeep: ") + starport.Cost + " credits\n\n";
                }
                else
                {
                    header         = "This ship has no lease currently.  You only need to pay when in a starport.";
                    canExtendLease = false;
                }
            }

            SetPageHeader("BaseDetailsPage", header);

            const int MaxAdvancePay = 30;
            DateTime  newRentDate   = pcBase.DateRentDue.AddDays(1);
            TimeSpan  ts            = newRentDate - DateTime.UtcNow;
            bool      canPayRent    = ts.TotalDays < MaxAdvancePay;

            SetResponseVisible("BaseDetailsPage", 1, canPayRent && canExtendLease);

            newRentDate = pcBase.DateRentDue.AddDays(7);
            ts          = newRentDate - DateTime.UtcNow;
            canPayRent  = ts.TotalDays < MaxAdvancePay;

            SetResponseVisible("BaseDetailsPage", 2, canPayRent && canExtendLease);
            SetResponseVisible("BaseDetailsPage", 3, canCancelLease);
        }
Esempio n. 3
0
// END CUT HERE
// BEGIN CUT HERE
    public static void Main()
    {
        try {
            Starport ___test = new Starport();
            ___test.run_test(-1);
        } catch (Exception e) {
//Console.WriteLine(e.StackTrace);
            Console.WriteLine(e.ToString());
        }
    }
Esempio n. 4
0
 // END CUT HERE
 // BEGIN CUT HERE
 public static void Main()
 {
     try {
     Starport ___test = new Starport();
     ___test.run_test(-1);
     } catch(Exception e) {
     //Console.WriteLine(e.StackTrace);
     Console.WriteLine(e.ToString());
     }
 }
Esempio n. 5
0
        public void BuildShouldBuildNowStarport()
        {
            string          name    = "McKay Port";
            StarportBuilder builder = new StarportBuilder(name, SolarSystems.Daibara);

            Starport mcKayPort = builder.Build();

            Assert.AreEqual(name, mcKayPort.Name);
            Assert.AreEqual(SolarSystems.Daibara, mcKayPort.System);
            Assert.AreEqual(1, mcKayPort.Version);
        }
Esempio n. 6
0
        public static TradeRoute Create(Starport origin, Starport destination, Commodity commodity, int buy, int sell)
        {
            TradeRoute route = new TradeRoute();

            route.Commodity   = commodity;
            route.Origin      = origin;
            route.Destination = destination;
            route.Buy         = buy;
            route.Sell        = sell;

            return(route);
        }
Esempio n. 7
0
        public void GetByID_OneItem_ReturnsSpaceStarport()
        {
            // Arrange
            var      id     = 555;
            Starport entity = new Starport {
                ID = id, PlanetName = "My Planet"
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <Starport>(entity));

            // Assert
            Assert.AreNotSame(entity, _cache.GetByID(id));
        }
Esempio n. 8
0
        public void SaveToXML(XmlElement objWorld)
        {
            var xeInfo = objWorld.OwnerDocument.CreateElement("TravellerInfo");

            objWorld.AppendChild(xeInfo);

            Common.CreateTextNode(xeInfo, "Starport", Starport.ToString());
            Common.CreateTextNode(xeInfo, "Size", Size.Value.ToString());
            Common.CreateTextNode(xeInfo, "Atmosphere", Atmosphere.Value.ToString());
            Common.CreateTextNode(xeInfo, "Hydro", Hydro.Value.ToString());
            Common.CreateTextNode(xeInfo, "Pop", Pop.Value.ToString());
            Common.CreateTextNode(xeInfo, "Government", Government.Value.ToString());
            Common.CreateTextNode(xeInfo, "Law", Law.Value.ToString());
            Common.CreateTextNode(xeInfo, "TechLevel", TechLevel.Value.ToString());
            Common.CreateTextNode(xeInfo, "PopMult", PopMult.ToString());
            Common.CreateTextNode(xeInfo, "Remarks", Remarks);
            Common.CreateTextNode(xeInfo, "Bases", Bases);

            if (_configuration.CurrentCampaign == Campaign.HAMMERSSLAMMERS)
            {
                Common.CreateTextNode(xeInfo, "ConflictReason", ConflictReason);
            }

            var xeChild = objWorld.OwnerDocument.CreateElement("Factions");

            foreach (var faction in Factions)
            {
                var xeFactionChild = objWorld.OwnerDocument.CreateElement("Faction");
                var xeAttrib       = objWorld.OwnerDocument.CreateAttribute("Government");
                xeAttrib.Value = faction.GovernmentString;
                xeFactionChild.Attributes.Append(xeAttrib);
                xeAttrib       = objWorld.OwnerDocument.CreateAttribute("Strength");
                xeAttrib.Value = faction.StrengthString;
                xeFactionChild.Attributes.Append(xeAttrib);
                if (_configuration.CurrentCampaign == Campaign.HAMMERSSLAMMERS)
                {
                    xeAttrib       = objWorld.OwnerDocument.CreateAttribute("Origin");
                    xeAttrib.Value = faction.Origin;
                    xeFactionChild.Attributes.Append(xeAttrib);
                    xeAttrib       = objWorld.OwnerDocument.CreateAttribute("Name");
                    xeAttrib.Value = faction.Name;
                    xeFactionChild.Attributes.Append(xeAttrib);
                }
                xeFactionChild.AppendChild(objWorld.OwnerDocument.CreateTextNode(faction.DisplayString()));
                xeChild.AppendChild(xeFactionChild);
            }
            xeInfo.AppendChild(xeChild);
        }
Esempio n. 9
0
        public override void Execute(ImportStarports command)
        {
            Stopwatch stopwatch = new Stopwatch();

            IDictionary <int, SolarSystemDto> solarSystems = _solarsystems.Load().ToDictionary(x => x.id);

            _logger.InfoFormat("Loaded solar systems {0:N} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            IList <Station> stations = _source.Load();

            _logger.InfoFormat("Loaded stations {0:N} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();

            Parallel.ForEach(stations, (station, state, arg3) =>
            {
                SolarSystemDto solarSystemDto;

                if (solarSystems.TryGetValue(station.system_id, out solarSystemDto))
                {
                    Coordinate position;

                    if (solarSystemDto.x.HasValue && solarSystemDto.y.HasValue && solarSystemDto.z.HasValue)
                    {
                        position = new Coordinate(solarSystemDto.x.Value, solarSystemDto.y.Value, solarSystemDto.z.Value);
                    }
                    else
                    {
                        position = Coordinate.None;
                    }

                    SolarSystem system = new SolarSystem(solarSystemDto.name, position);

                    StarportBuilder builder = new StarportBuilder(station.name, system);

                    Starport starport = builder.Build();

                    _destination.CommitChanges(starport);
                }
                else
                {
                    _logger.WarnFormat("Can not create station {0} solar system with id {1} not found", station.name, station.system_id);
                }
            });

            _logger.InfoFormat("Saved Starports {0:N} ms", stopwatch.ElapsedMilliseconds);
            stopwatch.Restart();
        }
Esempio n. 10
0
        private void ExtendLease(int days, int responseID, string optionText)
        {
            var    data           = BaseService.GetPlayerTempData(GetPC());
            PCBase pcBase         = DataService.PCBase.GetByID(data.PCBaseID);
            Area   dbArea         = DataService.Area.GetByResref(pcBase.AreaResref);
            bool   canExtendLease = BasePermissionService.HasBasePermission(GetPC(), pcBase.ID, BasePermission.CanExtendLease);
            var    owner          = DataService.Player.GetByID(pcBase.PlayerID);

            if (!canExtendLease)
            {
                GetPC().FloatingText("You don't have permission to extend leases on this base.");
                return;
            }

            int dailyUpkeep = dbArea.DailyUpkeep + (int)(dbArea.DailyUpkeep * (owner.LeaseRate * 0.01f));

            // Starship override.
            if (pcBase.PCBaseTypeID == (int)Enumeration.PCBaseType.Starship)
            {
                Guid     shipLocationGuid = new Guid(pcBase.ShipLocation);
                Starport starport         = DataService.Starport.GetByStarportID(shipLocationGuid);
                dailyUpkeep = starport.Cost + (int)(starport.Cost * (owner.LeaseRate * 0.01f));
            }

            if (GetPC().Gold < dailyUpkeep * days)
            {
                GetPC().SendMessage("You don't have enough credits to extend your lease.");
                data.IsConfirming = false;
                SetResponseText("BaseDetailsPage", responseID, optionText);
                return;
            }

            if (data.IsConfirming)
            {
                _.TakeGoldFromCreature(dailyUpkeep * days, GetPC(), true);
                data.IsConfirming = false;
                SetResponseText("BaseDetailsPage", responseID, optionText);
                pcBase.DateRentDue = pcBase.DateRentDue.AddDays(days);
                DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);
                LoadBaseDetailsPage();
            }
            else
            {
                data.IsConfirming = true;
                SetResponseText("BaseDetailsPage", responseID, "CONFIRM " + optionText.ToUpper());
            }
        }
Esempio n. 11
0
        public void FindHAvingOnlyOneOtherStarportShouldCalculateProfit()
        {
            Starport origin = Starports.DrzewieckiGateway;

            Starport[] destinations = new[]
            {
                Starports.McKayPort,
                Starports.DrzewieckiGateway
            };

            TradeRouteCalculator finder = new TradeRouteCalculator(destinations);

            TradeRoute route = finder.Find(origin);

            Assert.AreEqual(5133, route.Buy);
            Assert.AreEqual(5818, route.Sell);
            Assert.AreEqual(685, route.Profit);
            Assert.AreNotEqual(Starports.DrzewieckiGateway, route.Destination);
        }
Esempio n. 12
0
        public void GetByID_TwoItems_ReturnsCorrectObject()
        {
            // Arrange
            var      id1     = 100;
            var      id2     = 500;
            Starport entity1 = new Starport {
                ID = id1, PlanetName = "My Planet"
            };
            Starport entity2 = new Starport {
                ID = id2, PlanetName = "My Planet 2"
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <Starport>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <Starport>(entity2));

            // Assert
            Assert.AreNotSame(entity1, _cache.GetByID(id1));
            Assert.AreNotSame(entity2, _cache.GetByID(id2));
        }
Esempio n. 13
0
        public void GetByID_RemovedItem_ReturnsCorrectObject()
        {
            // Arrange
            var      id1     = 100;
            var      id2     = 200;
            Starport entity1 = new Starport {
                ID = id1, PlanetName = "My Planet"
            };
            Starport entity2 = new Starport {
                ID = id2, PlanetName = "My Planet"
            };

            // Act
            MessageHub.Instance.Publish(new OnCacheObjectSet <Starport>(entity1));
            MessageHub.Instance.Publish(new OnCacheObjectSet <Starport>(entity2));
            MessageHub.Instance.Publish(new OnCacheObjectDeleted <Starport>(entity1));

            // Assert
            Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); });
            Assert.AreNotSame(entity2, _cache.GetByID(id2));
        }
Esempio n. 14
0
        public override void DoAction(NWPlayer player, string pageName, int responseID)
        {
            PlayerDialog    dialog      = DialogService.LoadPlayerDialog(GetPC().GlobalID);
            Guid            structureID = new Guid(_.GetLocalString(player.Area, "PC_BASE_STRUCTURE_ID"));
            PCBaseStructure structure   = DataService.PCBaseStructure.GetByID(structureID);
            PCBase          pcBase      = DataService.PCBase.GetByID(structure.PCBaseID);

            DialogPage     page     = dialog.GetPageByName(pageName);
            DialogResponse response = page.Responses[responseID - 1];

            bool carefulPilot = PerkService.GetCreaturePerkLevel(player, PerkType.CarefulPilot) > 0;

            if (pageName == "MainPage")
            {
                // The number of dialog options available can vary.  So query based on the actual text of the response.
                if (response.Text == "Land")
                {
                    ChangePage("LandingDestPage");
                }
                else if (response.Text == "Pilot Ship")
                {
                    SpaceService.CreateShipInSpace(player.Area); // In case we logged in here.
                    SpaceService.DoFlyShip(GetPC(), GetPC().Area);
                    EndConversation();
                }
                else if (response.Text == "Hyperspace Jump")
                {
                    // Build the list of destinations.
                    ChangePage("HyperDestPage");
                }
                else if (response.Text == "Take Off")
                {
                    // Check fuel
                    if (pcBase.Fuel < 1)
                    {
                        GetPC().SendMessage("You don't have enough fuel! You need 1 fuel to take off.");
                        dialog.ResetPage();
                    }
                    else
                    {
                        // Fuel is good - we have liftoff.
                        if (!SpaceService.DoPilotingSkillCheck(GetPC(), 2, carefulPilot))
                        {
                            // Failed our skill check.  Deduct fuel but don't do anything else.
                            GetPC().FloatingText("The ship shudders a bit, but your awkwardness on the throttle shows, and it doesn't make it off the dock.  Try again.");
                            pcBase.Fuel -= 1;
                            DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);
                            return;
                        }

                        EndConversation();

                        // Save details of the current dock for later.
                        Guid            shipPCBaseID = new Guid(pcBase.ShipLocation);
                        PCBaseStructure dock         = DataService.PCBaseStructure.GetByIDOrDefault(shipPCBaseID);

                        pcBase.Fuel        -= 1;
                        pcBase.DateRentDue  = DateTime.UtcNow.AddDays(99);
                        pcBase.ShipLocation = SpaceService.GetPlanetFromLocation(pcBase.ShipLocation) + " - Orbit";
                        DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);

                        SpaceService.CreateShipInSpace(player.Area);

                        // Give the impression of movement
                        foreach (var creature in player.Area.Objects)
                        {
                            if (creature.IsPC || creature.IsDM)
                            {
                                _.FloatingTextStringOnCreature("The ship is taking off", creature);
                            }
                        }

                        _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Screen_Shake), player);

                        // Clean up the base structure, if we were in a PC dock not public starport.
                        // Get a reference to our placeable (and door), and delete them with some VFX.
                        if (dock != null)
                        {
                            PCBase dockBase = DataService.PCBase.GetByID(dock.PCBaseID);

                            IEnumerable <NWArea> areas = NWModule.Get().Areas;
                            NWArea landingArea         = new NWArea(_.GetFirstArea());

                            foreach (var area in areas)
                            {
                                if (_.GetResRef(area) == dockBase.AreaResref)
                                {
                                    landingArea = area;
                                }
                            }

                            List <AreaStructure> areaStructures = landingArea.Data["BASE_SERVICE_STRUCTURES"];
                            foreach (var plc in areaStructures)
                            {
                                if (plc.PCBaseStructureID == dock.ID)
                                {
                                    // Found our dock.  Clear its variable and play some VFX.
                                    plc.Structure.SetLocalInt("DOCKED_STARSHIP", 0);
                                    DoDustClouds(plc.Structure.Location);
                                    _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Screen_Shake), plc.Structure);
                                }
                                else if (plc.PCBaseStructureID == structure.ID)
                                {
                                    // found either our ship or our entrance (both are saved with our structure ID).  Delete them.
                                    // Dp NOT remove the PC base structure object from the database.  We still need that.
                                    plc.Structure.Destroy();
                                }
                            }
                        }
                    }
                }
                else if (response.Text == "Access Fuel Bay")
                {
                    OpenFuelBay(false);
                    EndConversation();
                }
                else if (response.Text == "Access Stronidium Bay")
                {
                    OpenFuelBay(true);
                    EndConversation();
                }
                else if (response.Text == "Access Resource Bay")
                {
                    NWPlaceable bay = SpaceService.GetCargoBay(player.Area, GetPC());
                    if (bay != null)
                    {
                        GetPC().AssignCommand(() => _.ActionInteractObject(bay.Object));
                    }
                    EndConversation();
                }
                else if (response.Text == "Export Starcharts")
                {
                    NWItem item = _.CreateItemOnObject("starcharts", player, 1, _.Random(10000).ToString());

                    // Initialise the list, in case it hasn't been populated yet.
                    SpaceService.GetHyperspaceDestinationList(pcBase);

                    item.SetLocalInt("Starcharts", (int)pcBase.Starcharts);
                }
            }
            else if (pageName == "HyperDestPage")
            {
                // Check fuel
                if (pcBase.Fuel < 50)
                {
                    GetPC().SendMessage("You don't have enough fuel! You need 50 fuel to make a hyperspace jump.");
                    dialog.ResetPage();
                }
                else
                {
                    // Fuel is good - make the jump
                    if (!SpaceService.DoPilotingSkillCheck(GetPC(), 13, carefulPilot))
                    {
                        // Failed our skill check.  Deduct fuel but don't do anything else.
                        GetPC().FloatingText("Jump failed!  You forgot to whatsit the thingummyjig.");
                        pcBase.Fuel -= 50;
                        DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);
                        EndConversation();
                        return;
                    }

                    // Move the ship out of the old orbit.
                    SpaceService.RemoveShipInSpace(player.Area);

                    // Fade to black for hyperspace.
                    EndConversation();
                    pcBase.Fuel        -= 50;
                    pcBase.ShipLocation = response.Text + " - Orbit";
                    DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);

                    // Put the ship in its new orbit.
                    SpaceService.CreateShipInSpace(player.Area);

                    // Give the impression of movement - would be great to have the actual hyperspace jump graphics here.
                    foreach (var creature in player.Area.Objects)
                    {
                        if (creature.IsPC || creature.IsDM)
                        {
                            _.FloatingTextStringOnCreature("Making a hyperspace jump!", creature);
                            _.FadeToBlack(creature, 0.5f);
                            _.DelayCommand(1.0f, () => { _.FadeFromBlack(creature, 0.5f); });
                        }
                    }
                }
            }
            else if (pageName == "LandingDestPage")
            {
                // Skill check.
                if (!SpaceService.DoPilotingSkillCheck(GetPC(), 5, carefulPilot))
                {
                    // Failed our skill check.  Land anyway but burn more fuel.
                    if (pcBase.Fuel > 0)
                    {
                        GetPC().FloatingText("You overshoot the landing spot, burning extra fuel getting your ship into position.");
                        pcBase.Fuel -= 1;
                        DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);
                    }
                }

                // Get the response, then find the structure ID.
                Guid dockStructureID = dialog.CustomData["LAND_" + response.Text];

                // This could be a public startport ID or a private dock base structure ID.
                Starport starport = DataService.Starport.GetByStarportIDOrDefault(dockStructureID);
                if (starport != null)
                {
                    // We have a public starport.
                    if (player.Gold < starport.Cost)
                    {
                        player.SendMessage("You do not have enough credits to land here.");
                        return;
                    }
                    else
                    {
                        _.TakeGoldFromCreature(starport.Cost, player, true);

                        // Land.
                        pcBase.ShipLocation = starport.StarportID.ToString();
                        pcBase.DateRentDue  = DateTime.UtcNow.AddDays(1);
                        DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);

                        // Notify PC.
                        player.SendMessage("You have paid your first day's berthing fees. Use the Base Management System to extend your lease if you plan to stay longer, or your ship will be impounded.");

                        EndConversation();
                    }
                }
                else
                {
                    LoggingService.Trace(TraceComponent.Space, "Landing in PC base dock, ID: " + dockStructureID.ToString());
                    PCBaseStructure dock = DataService.PCBaseStructure.GetByIDOrDefault(dockStructureID);

                    if (dock == null)
                    {
                        player.SendMessage("ERROR: Could not find landing dock by ID.  Please report this.");
                        LoggingService.Trace(TraceComponent.Space, "Could not find landing dock ID " + dockStructureID.ToString());
                        return;
                    }

                    NWPlaceable plc = BaseService.FindPlaceableFromStructureID(dock.ID.ToString());

                    if (plc == null)
                    {
                        LoggingService.Trace(TraceComponent.Space, "Failed to find dock placeable.");
                        player.SendMessage("ERROR: Could not find landing dock placeable.  Please report this.");
                        return;
                    }

                    LoggingService.Trace(TraceComponent.Space, "Found dock, landing ship.");

                    // We've found our dock. Update our record of where the ship's exterior should spawn.
                    NWLocation loc = plc.Location;

                    structure.LocationX           = loc.X;
                    structure.LocationY           = loc.Y;
                    structure.LocationZ           = loc.Z;
                    structure.LocationOrientation = _.GetFacingFromLocation(loc);

                    DataService.SubmitDataChange(structure, DatabaseActionType.Update);

                    // And update the base to mark the parent dock as the location.
                    pcBase.ShipLocation = dock.ID.ToString();
                    DataService.SubmitDataChange(pcBase, DatabaseActionType.Update);

                    // Now use the Base Service to spawn the ship exterior.
                    BaseService.SpawnStructure(plc.Area, structure.ID);

                    // Mark the dock as occupied.
                    plc.SetLocalInt("DOCKED_STARSHIP", 1);

                    // Notify PCs in the landing area.
                    foreach (var creature in plc.Area.Objects)
                    {
                        if (creature.IsPC || creature.IsDM)
                        {
                            _.FloatingTextStringOnCreature("A ship has just landed!", creature);
                        }
                    }

                    // And shake the screen, because stuff.
                    _.ApplyEffectAtLocation(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Screen_Shake), loc);
                    DoDustClouds(loc);
                }

                // We're landing.  Make sure any pilot or gunner get out of flight mode.
                SpaceService.LandCrew(player.Area);

                // If we are still here, we landed successfully.  Shake the screen about and notify PCs on the ship.
                // Give the impression of movement
                foreach (var creature in player.Area.Objects)
                {
                    if (creature.IsPC || creature.IsDM)
                    {
                        _.FloatingTextStringOnCreature("The ship is landing.", creature);
                    }
                }

                _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Screen_Shake), player);
                SpaceService.RemoveShipInSpace(player.Area);

                EndConversation();
            }
        }
Esempio n. 15
0
    public bool Select(Player player)
    {
        if (hasShip && owner == player.netId)
        {
            if (player.isBuyingBoosterUpgrade)
            {
                if (player.Purchase(PurchaseManager.UpgradeBooster))
                {
                    NetworkServer.FindLocalObject(associatedShip).GetComponent <Ship>().Boosters++;
                }
            }
            else if (player.isBuyingBlasterUpgrade && hasLocalPlayerFleetVessel)
            {
                if (player.Purchase(PurchaseManager.UpgradeBlaster))
                {
                    NetworkServer.FindLocalObject(associatedShip).GetComponent <FleetVessel>().Blasters++;
                }
            }
            else if (player.isBuyingTractorBeamUpgrade && hasLocalPlayerFleetVessel)
            {
                if (player.Purchase(PurchaseManager.UpgradeTractorBeam))
                {
                    NetworkServer.FindLocalObject(associatedShip).GetComponent <FleetVessel>().TractorBeams++;
                }
            }
            else
            {
                if (NetworkServer.FindLocalObject(associatedShip).GetComponent <Ship>().IsDisabled)
                {
                    return(false);
                }

                //clicking on my ship space, select it
                selected = !selected;
                GameManager.singleton.selectedCell = selected ? this : null;

                if (selected)
                {
                    foreach (GameCell cell in NetworkServer.FindLocalObject(associatedShip).GetComponent <Ship>().nearbyCells)
                    {
                        if (cell.state == GameCellState.Empty || cell.state == GameCellState.ShipBuildArea ||
                            (cell.state == GameCellState.TempusSpace && player.reputation >= GameManager.singleton.tempusReputation))
                        {
                            cell.SetCell(player, GameCellState.MovementArea);
                        }
                    }
                }
                else
                {
                    foreach (GameCell cell in NetworkServer.FindLocalObject(associatedShip).GetComponent <Ship>().nearbyCells)
                    {
                        if (cell.state == GameCellState.MovementArea)
                        {
                            cell.Revert();
                        }
                    }
                }
            }
        }
        else if (state == GameCellState.ShipBuildArea && owner == player.netId)
        {
            if (player.isBuyingFleetVessel && player.Purchase(PurchaseManager.FleetVessel))
            {
                GameObject objShip = (GameObject)Instantiate(prefabFleetVessel, transform.position, Quaternion.identity);
                NetworkServer.Spawn(objShip);
                FleetVessel ship = objShip.GetComponent <FleetVessel>();
                ship.Color          = player.color;
                ship.ownerId        = player.netId;
                ship.associatedCell = this.netId;
                player.fleetVessels.Add(ship);

                SetCell(player, GameCellState.Empty, true, ship.netId);
                return(true);
            }
            else if (player.isBuyingColonyShip && player.Purchase(PurchaseManager.ColonyShip))
            {
                GameObject objShip = (GameObject)Instantiate(prefabColonyShip, transform.position, Quaternion.identity);
                NetworkServer.Spawn(objShip);
                ColonyShip ship = objShip.GetComponent <ColonyShip>();
                ship.Color          = player.color;
                ship.ownerId        = player.netId;
                ship.associatedCell = this.netId;

                SetCell(player, GameCellState.Empty, true, ship.netId);
                return(true);
            }
        }
        else if (state == GameCellState.MovementArea && owner == player.netId)
        {
            foreach (GameCell cell in NetworkServer.FindLocalObject(GameManager.singleton.selectedCell.associatedShip).GetComponent <Ship>().nearbyCells)
            {
                if (cell.state == GameCellState.MovementArea)
                {
                    cell.Revert();
                }
            }
            //move the ship
            SetCell(player, true, GameManager.singleton.selectedCell.associatedShip);
            GameManager.singleton.selectedCell.SetCell(false, NetworkInstanceId.Invalid);
            GameManager.singleton.selectedCell = null;
            NetworkServer.FindLocalObject(associatedShip).GetComponent <Ship>().MoveTo(this.netId);
            return(true);
        }
        else if (state == GameCellState.Depot && owner == player.netId)
        {
            if (player.isBuyingStarport && player.Purchase(PurchaseManager.Starport))
            {
                SetCell(player, GameCellState.Starport);
                NetworkServer.Destroy(NetworkServer.FindLocalObject(associatedStation));
                GameObject obj      = (GameObject)Instantiate(prefabStarport, transform.position, Quaternion.identity);
                Starport   starport = obj.GetComponent <Starport>();
                starport.color = player.color;
                starport.owner = player;
                NetworkServer.Spawn(obj);
                associatedStation = starport.netId;
                //player.depots.Add(depot);
                return(true);
            }
        }
        else if (state == GameCellState.DepotBuildArea && owner == player.netId)
        {
            if (player.isBuyingDepot && player.Purchase(PurchaseManager.Depot))
            {
                SetCell(player, GameCellState.Depot);
                GameObject objDepot = (GameObject)Instantiate(prefabDepot, transform.position, Quaternion.identity);
                Depot      depot    = objDepot.GetComponent <Depot>();
                depot.color = player.color;
                depot.owner = player;
                NetworkServer.Spawn(objDepot);
                associatedStation = depot.netId;
                //player.depots.Add(depot);
                return(true);
            }
        }

        return(false);
    }
Esempio n. 16
0
 void Starport_OnStarportStarted(Starport starport)
 {
     ToggleBuildStarport(false);
 }
Esempio n. 17
0
 void Starport_OnStarportStarted(Starport starport)
 {
     isBuyingStarport = false;
 }