Inheritance: SpaceBuilding
Exemplo n.º 1
0
        public void ShouldReadSpaceStationInfo()
        {
            var station = new SpaceStation()
            {
                Name = "MyStation",
                ManufacturedItems = new List <CommodityType>(),
                ItemsInDemand     = new List <CommodityType>()
            };

            var otherSystem = new SolarSystem()
            {
                Name = "Foo"
            };

            var system = new SolarSystem();

            system.Name = "MySystem";
            system.Stations.Add(station);
            system.Neighbors.Add(otherSystem);

            SolarSystem[] expectedModel = new[] { system };

            var json = JsonConvert.SerializeObject(expectedModel);

            var rgoModelReader = new RgoModelReader();

            SolarSystem[] actualModel = rgoModelReader.LoadFrom(json);
            Assert.Contains(actualModel, currentSystem => currentSystem.Stations.Any(s => s.Name == station.Name));
            Assert.Contains(actualModel, currentSystem => currentSystem.Neighbors.Any(n => n.Name == "Foo"));
        }
Exemplo n.º 2
0
    public void HireCrewMember(PlayerShip player, SpaceStation fromStation, CrewMember crewMember)
    {
        Debug.Assert(fromStation.AvailableCrew.Contains(crewMember), "can't buy crew who aren't available to buy");

        var ship = player.Ship;
        Debug.Assert(ship != null, "can't buy stuff without a ship");

        //check ship has space
        var passengerCount = ship.GetPassengers().Count();
        if (passengerCount == ship.CurrentStats.PassengerCapacity)
        {
            throw new InvalidOperationException("no room for more passengers");
        }

        //check player has enough money
        var price = GetHirePrice(crewMember);
        if (player.Money < price)
        {
            throw new InvalidOperationException("player can't afford price of " +price);
        }

        player.AddMoney(-price);
        crewMember.Assign(ship, CrewAssignment.Passenger);
        fromStation.AvailableCrew.Remove(crewMember);
    }
 void Start()
 {
     stationObj   = GetComponent <SpaceStation>();
     station_afil = stationObj.spaceStation_affil;
     aiActive     = false;
     flockTimer   = 0;
 }
    void Start()
    {
        station = GetComponent<SpaceStation>();
        spawned = new List<Ship>();

        RandomSpawnTimer();
    }
Exemplo n.º 5
0
    void Awake()
    {
        SpaceStation    spaceStation        = GetComponentInParent <MenuStationLevel>().spaceStation;
        TextMeshProUGUI cargosCount         = GetComponent <TextMeshProUGUI>();
        int             totalCargosToUnlock = spaceStation.cargosToUnlock - Storage.Instance.getTotalCargos();

        cargosCount.SetText(totalCargosToUnlock.ToString());
    }
Exemplo n.º 6
0
    void Start()
    {
        SpaceStation    spaceStation  = GetComponentInParent <MenuStationLevel>().spaceStation;
        TextMeshProUGUI highScoreText = GetComponent <TextMeshProUGUI>();
        int             highScore     = Storage.Instance.getHighScore(spaceStation.name);

        highScoreText.SetText(highScore.ToString());
    }
Exemplo n.º 7
0
        private void ShowSpaceDock(SpaceStation station)
        {
            PauseWorld();

            spaceDock.ShipDocking(_ship, station);

            spaceDock.Visibility = Visibility.Visible;
        }
Exemplo n.º 8
0
    public void play()
    {
        SimpleScrollSnap menuScrollSnap       = transform.Find("ScrollSnap").GetComponent <SimpleScrollSnap>();
        Transform        menuItemSelected     = menuScrollSnap.Content.GetChild(menuScrollSnap.CurrentPanel);
        SpaceStation     spaceStationSelected = menuItemSelected.GetComponent <MenuStationLevel>().spaceStation;

        SceneLoader.Instance.goToGame(spaceStationSelected.name);
    }
Exemplo n.º 9
0
 public void destroyStations()
 {
     selectedStation = null;
     for (int i = 0; i < spaceStations.Count; i++)
     {
         Destroy(spaceStations[i].gameObject);
     }
     spaceStations = new List <SpaceStation>();
 }
Exemplo n.º 10
0
    public void FireCrewMember(PlayerShip player, SpaceStation atStation, CrewMember crewMember)
    {
        var ship = player.Ship;
        Debug.Assert(ship != null, "can't sell stuff without a ship");
        Debug.Assert(crewMember == ship.GetCaptain() || ship.GetPassengers().Contains(crewMember), "can't fire someone who doesn't work for you");

        atStation.AvailableCrew.Add(crewMember);
        crewMember.Unassign();
    }
Exemplo n.º 11
0
        private void Collision_SpaceStation(object sender, MaterialCollisionArgs e)
        {
            SpaceStation station = _map.GetItem <SpaceStation>(e.GetBody(_material_SpaceStation));

            if (station != null)
            {
                station.Collided(e);
            }
        }
Exemplo n.º 12
0
        private void CreateSpaceStationsSprtBuild(Point3D position)
        {
            SpaceStation spaceStation = new SpaceStation();

            spaceStation.SpinDegreesPerSecond = Math1D.GetNearZeroValue(10d);
            spaceStation.HullColor            = UtilityWPF.AlphaBlend(UtilityWPF.GetRandomColor(108, 148), Colors.Gray, .25);
            spaceStation.CreateStation(_map, position);

            _spaceStations.Add(spaceStation);
        }
Exemplo n.º 13
0
    public void prev()
    {
        int prevIndex = selectedIndex - 1;

        if (prevIndex < 0)
        {
            return;
        }
        selectedStation = spaceStations[prevIndex];
        moveToSelected();
    }
Exemplo n.º 14
0
    private void instantiateStation()
    {
        string stationName = SceneLoader.Instance.getStationNameToLoad();

        spaceStation = spaceStations.Find((spaceStationItem) => spaceStationItem.name == stationName);
        if (spaceStation == null)
        {
            spaceStation = defaultSpaceStation;
        }
        Instantiate(spaceStation);
    }
Exemplo n.º 15
0
    void Start()
    {
        station = FindObjectOfType <SpaceStation>();
        Assert.IsNotNull(station);
        lootParent = FindObjectOfType <LootParent>();
        Assert.IsNotNull(lootParent);
        Vector2 det = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f));

        rb = GetComponent <Rigidbody2D>();
        Assert.IsNotNull(rb);
    }
Exemplo n.º 16
0
    public void next()
    {
        int nextIndex = selectedIndex + 1;

        if (nextIndex > spaceStations.Count - 1)
        {
            return;
        }
        selectedStation = spaceStations[nextIndex];
        moveToSelected();
    }
Exemplo n.º 17
0
    void OnTriggerExit(Collider collider)
    {
        if (State != DockingState.InSpace)
        {
            return;
        }

        if (localStation && localStation.MooringTrigger.Collider == collider)
        {
            localStation = null;
        }
    }
Exemplo n.º 18
0
    protected void Start()
    {
        mat = GetComponent <MeshRenderer>().material;
        og  = mat.color;

        timer = Time.timeSinceLevelLoad;
        if (!friendly)
        {
            sp     = transform.parent.GetComponentInChildren <SpaceStation>();
            target = PlayerMovement.player.gameObject;
        }
    }
Exemplo n.º 19
0
        //create
        //test
        public bool CreateSpaceStation(SpaceStationCreate model)
        {
            SpaceStation entity = new SpaceStation
            {
                Name             = model.Name,
                MaximumOccupancy = model.MaximumOccupancy,
                CreatedUtc       = DateTimeOffset.Now
            };

            _context.SpaceStations.Add(entity);
            return(_context.SaveChanges() == 1);
        }
Exemplo n.º 20
0
    public static Quest Create(Quest template, SpaceStation station)
    {
        var quest = Instantiate(template);
        quest.name = template.name;
        quest.location = new LocationID
        {
            Area = SpaceTraderConfig.WorldMap.GetCurrentArea().name,
            Station = station.name
        };

        return quest;
    }
Exemplo n.º 21
0
    public void DockedUpdate(SpaceStation dockedAtStation)
    {
        Debug.Assert(dockedAtStation && ai.Ship && ai.Ship.Moorable);

        if (Time.time > dockedTime + 5)
        {
            dockedAtStation.Unmoor(ai.Ship.Moorable);

            //just to make sure..
            ai.ClearTasks();
        }
    }
        public void TestAlert(String elements, long oxygen, double battery, Alert expectedAlert)
        {
            SpaceStation testObject = new SpaceStation();

            parseElements(elements, testObject.Elements);
            testObject.Oxygen             = oxygen;
            testObject.BatteryAmpereHours = battery;

            testObject.LogStatus();

            Assert.AreEqual(expectedAlert, testObject.Check4Problem());
        }
Exemplo n.º 23
0
    void OnTriggerStay(Collider collider)
    {
        if (State != DockingState.InSpace)
        {
            return;
        }

        var mooringTrigger = collider.GetComponent<MooringTrigger>();
        if (mooringTrigger)
        {
            localStation = mooringTrigger.SpaceStation;
        }
    }
Exemplo n.º 24
0
    public void SetDestinationStation(SpaceStation station)
    {
        spaceStation = station;

        ai.AssignTask(ActivateTask.Create(spaceStation));

        //use the undock points to find our docking vector
        var undock = ai.transform.Closest(spaceStation.UndockPoints);
        if (undock)
        {
            ai.AssignTask(NavigateTask.Create(undock.transform.position + undock.transform.forward * Moorable.DOCK_DISTANCE));
        }
    }
Exemplo n.º 25
0
    public IEnumerable<Quest> QuestsAtStation(SpaceStation station)
    {
        var area = SpaceTraderConfig.WorldMap.GetCurrentArea().name;

        if (station == null)
        {
            return Enumerable.Empty<Quest>();
        }

        return quests.Where(q => q.Quest.Location.Area == area
                && q.Quest.Location.Station == station.name)
            .Select(q => q.Quest);
    }
Exemplo n.º 26
0
        public void GetBestSpaceStation_MapOfAsteroids_ReturnsSpaceStationData(string asteroidMap, int expectedCount, string expectedLocation)
        {
            // Arrange
            var coordinates = expectedLocation.Split(',');
            var location    = new Point(int.Parse(coordinates[0]), int.Parse(coordinates[1]));
            var rows        = asteroidMap.Split(Environment.NewLine).ToList();

            // Act
            var(spaceStationLocation, asteroidCount, _) = SpaceStation.GetBestSpaceStation(rows);

            // Assert
            spaceStationLocation.ShouldBeEquivalentTo(location);
            asteroidCount.Should().Be(expectedCount);
        }
Exemplo n.º 27
0
    public void createSpaceStations()
    {
        for (int i = 0; i < spaceStationsPrefabs.Length; i++)
        {
            SpaceStation spaceStationPrefab = spaceStationsPrefabs[i];

            SpaceStation spaceStation = Instantiate(spaceStationPrefab, transform);
            float        stationPosX  = screenSize.x * 2 * i;
            spaceStation.transform.localPosition = new Vector3(stationPosX, 0, 0);
            spaceStations.Add(spaceStation);
        }
        selectedStation = spaceStations[0];
        moveToSelectedNoAnimation();
    }
Exemplo n.º 28
0
        private void CreateSpaceStationsSprtBuild(Point3D position, List <SpaceStation> allStations)
        {
            SpaceStation spaceStation = new SpaceStation(position, _world, _material_SpaceStation, Math3D.GetRandomRotation());

            spaceStation.SpinDegreesPerSecond = Math1D.GetNearZeroValue(.33, 1.1);

            //double angularSpeed = Math3D.GetNearZeroValue(.33d, .66d);
            //spaceStation.PhysicsBody.AngularVelocity = spaceStation.PhysicsBody.DirectionToWorld(new Vector3D(0, 0, angularSpeed));

            //spaceStation.PhysicsBody.ApplyForceAndTorque += new EventHandler<BodyApplyForceAndTorqueArgs>(Body_ApplyForceAndTorque);

            _map.AddItem(spaceStation);

            allStations.Add(spaceStation);
        }
Exemplo n.º 29
0
    void OnToggleSwitch(bool val)
    {
        ToggleAllButtons(val);
        mainCam.isBuildMode = val;
        isBuildMode         = val;
        ((RunBehaviour)GameObject.FindGameObjectWithTag("GameController").GetComponent <RunBehaviour>()).SetBuildMode(val);

        if (isBuildMode)
        {
            SwitchCamToBuildMode();
            SpaceStation ss = ((SpaceStation)GameObject.FindGameObjectWithTag("SpaceStation").GetComponent <SpaceStation>());
            ss.InitializeButtons();
            ss.stationMan.ReportStationStatsToHUD();
        }
    }
Exemplo n.º 30
0
    public Vector3 GetBridgePosFromPort(Direction dir, HorizontalBuildingType btype)
    {
        float bridgeLen = GetBridgeLenByType(btype);

        if (bridgeLen == 0)
        {
            return(Vector3.zero);
        }

        Vector3 ans = Vector3.zero;

        ans    = selectedHub.pos + SpaceStation.GetDisplacementVector(dir, bridgeLen / 2);
        ans.y -= SpaceStation.buildingHeightTable[BuildingType.MainConnector] / 2;
        return(ans);
    }
Exemplo n.º 31
0
        public void InitializeGame()
        {
            RNG.Initialize();
            ZConsoleMain.ClearScreen();
            DrawUI();

            SpaceStation = MapGenerator.CreateSpaceStation();

            Teams = new List<Team>();
            var playerTeam = TeamGenerator.CreateTeam(PlayerTeamName, true);
            Teams.Add(playerTeam);

            TeamGenerator.LocateTeamInStation(playerTeam, SpaceStation, 0);
            StartTurn(PlayerTeamName);
            CurrentUnit.Draw();
        }
Exemplo n.º 32
0
 void Start()
 {
     lootParent = FindObjectOfType <LootParent>();
     if (lootParent == null)
     {
         Instantiate(lootParentPrefab);
         lootParent = FindObjectOfType <LootParent>();
     }
     Assert.IsNotNull(lootParent);
     sHome = FindObjectOfType <SpaceStation>();
     Assert.IsNotNull(sHome);
     pState = GetComponent <PlayerState>();
     Assert.IsNotNull(pState);
     pAnim = GetComponent <PlayerAnimation>();
     Assert.IsNotNull(pAnim);
 }
Exemplo n.º 33
0
        public Space DeployDebris(Debris debris)
        {
            if (allDebrisInSpace.Contains(debris))
            {
                throw new ArgumentException();
            }

            if (debris is SpaceStation)
            {
                this.station = (SpaceStation)debris;
            }

            allDebrisInSpace.Add(debris);

            return(this);
        }
Exemplo n.º 34
0
        public static void LocateTeamInStation(Team team, SpaceStation station, int levelId)
        {
            var level = station.Levels[levelId];
            var corner = (Corner)RNG.GetNumber(0, 3, (int)level.StairsDownLocation);

            var coordX = corner == Corner.TopLeft  ||  corner == Corner.BottomLeft ? 3 : MapConfig.LevelSize.Width - 6;
            var coordY = corner == Corner.TopLeft  ||  corner == Corner.TopRight ? 3 : MapConfig.LevelSize.Height - 6;

            for (var i = 0; i < 2; i++)
                for (var j = 0; j < 2; j++)
                {
                    var unit = team.Units[i*2 + j];
                    unit.Position = new Position(levelId, coordX + j*2, coordY + i*2);
                    unit.View.Direction = corner == Corner.TopLeft ? 4 : corner == Corner.TopRight ? 6 : corner == Corner.BottomLeft ? 2 : 0;
                    level.Map[coordY + i*2, coordX + j*2] = new Tile("Empty");
                }
        }
        public void TestApproAndCollision()
        {
            Space space = new Space();

            Debris asteroid1 = space.DeployDebris(1000, -1000, 1000, 25);
            Debris asteroid2 = space.DeployDebris(1000, 1000, 1000, 50);

            SpaceStation station = new SpaceStation(space, 0, 0, 0);

            for (int i = 0; i < 850; i++)
            {
                space.MoveDebris(asteroid1, -1, 1, -1);
                Assert.IsNull(station.CurrentAlert, "There should not be an alert yet!");
            }

            for (int i = 0; i < 100; i++)
            {
                space.MoveDebris(asteroid1, -1, 1, -1);
            }
            Assert.IsNotNull(station.CurrentAlert, "There should be an alert now!");
            Assert.AreEqual(Alert.Yellow, station.CurrentAlert, "There should be a yellow alert now! asteroid 1 is close to our station");

            // lets move station out of the way
            for (int i = 0; i < 850; i++)
            {
                space.MoveDebris(station, 1, 1, 1);
            }
            Assert.IsNull(station.CurrentAlert, "There should not be an alert any more, we have moved!");

            for (int i = 0; i < 100; i++)
            {
                space.MoveDebris(station, 1, 1, 1);
            }
            Assert.IsNotNull(station.CurrentAlert, "There should be an alert now!");
            Assert.AreEqual(Alert.Yellow, station.CurrentAlert, "There should be a yellow alert now! asteroid 2 is close to our station");

            for (int i = 0; i < 21; i++)
            {
                space.MoveDebris(station, 1, 1, 1);
            }
            Assert.IsNotNull(station.CurrentAlert, "There should be an alert now!");
            Assert.AreEqual(Alert.Red, station.CurrentAlert, "Collision with asteroid2 - RED ALERT!!");
        }
Exemplo n.º 36
0
        public static SpaceStation CreateSpaceStation()
        {
            var station = new SpaceStation();
            for (var i = 0; i < RNG.GetNumber(MapConfig.LevelCount); i++)
            {
                var level = CreateLevel(i);
                if (LevelValidator.IsLevelPassable(level))
                {
                    station.Levels.Add(level);
                    continue;
                }
                i--;
            }

            LocateStairs(station);
            LocateFinalTarget(station);
            CreateItemsOnFloor(station);
            return station;
        }
Exemplo n.º 37
0
    // Start is called before the first frame update
    void Start()
    {
        // randomly assign a color
        mySpriteRenderer.color = new Color(
            rando.Next(0, 255) / 255f,
            rando.Next(0, 255) / 255f,
            rando.Next(0, 255) / 255f
            );
        suitcolor = mySpriteRenderer.color;

        // resize to the correct size (relative to parent space station)
        transform.localScale = new Vector3(5.243802f, 5.243802f, 5.243802f);

        // set hit points
        currentHitPoints = maxHitPoints;

        // give home
        home = SpaceStation.Single;
    }
Exemplo n.º 38
0
        static void Main(string[] args)
        {
            var express   = new TransportShip("Planet Express", 10);
            var droneship = new DroneShip("Drone ship #0001", 10);

            var station = new SpaceStation("Solaris");

            droneship.AddCargo(new Cargo("Item A from drone", 1));
            droneship.AddCargo(new Cargo("Item B from drone", 1));
            droneship.AddCargo(new Cargo("Item C from drone", 1));

            // The drone ship dropping off cargo to the station
            station.DropOff("key", droneship);

            // The Planet Express picking it up
            station.PickUp("key", express);

            Console.WriteLine("-- Planet Express --");
            express.ListCargo();
        }
Exemplo n.º 39
0
    private int getAmountCargos()
    {
        // 50% chance of 2 cargos
        // 25% and 25% for 1 and 2 cargos;
        // if less than 3, the amount that is left is added
        float        cargoChance      = Random.Range(0, 100);
        SpaceStation spaceStation     = SpaceStation.Instance;
        float        cargoPercentage1 = spaceStation.cargoPercentage1;
        float        cargoPercentage2 = spaceStation.cargoPercentage2;

        if (cargoChance < cargoPercentage1)
        {
            return(1);
        }
        else if (cargoChance < (cargoPercentage1 + cargoPercentage2))
        {
            return(2);
        }
        return(3);
    }
Exemplo n.º 40
0
        private void btnLaunch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.LaunchShip == null)
                {
                    MessageBox.Show("There is no event listener for the launch button", "Launch Button", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                // This panel is about to close, so forget my reference to the ship and station
                _ship    = null;
                _station = null;

                this.LaunchShip(this, new EventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Space Dock", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 41
0
    public bool AddBuilding(bool top, BuildingType btype)
    {
        float newBuildingHeight = SpaceStation.buildingHeightTable[btype];

        if (top)
        {
            Vector3 buildingPos = buildings.First.Value.pos;
            if (!CanAddBuilding(top, btype, buildingPos, newBuildingHeight))
            {
                return(false);
            }
            buildingPos.y += newBuildingHeight + SpaceStation.buildingHeightTable[buildings.First.Value.type] / 2;
            StationBuilding newBuilding = new StationBuilding(btype, buildingPos, this);
            newBuilding.buildingMesh = MakeGameObjectInstance(btype);
            newBuilding.buildingMesh.transform.position = buildingPos;
            buildings.AddFirst(newBuilding);
            if (SpaceStation.IsHub(btype))
            {
                hubBuildings.AddFirst(newBuilding);
            }
        }
        else
        {
            Vector3 buildingPos = buildings.Last.Value.pos;
            if (!CanAddBuilding(top, btype, buildingPos, newBuildingHeight))
            {
                return(false);
            }
            buildingPos.y -= newBuildingHeight + SpaceStation.buildingHeightTable[buildings.Last.Value.type] / 2;
            StationBuilding newBuilding = new StationBuilding(btype, buildingPos, this);
            newBuilding.buildingMesh = MakeGameObjectInstance(btype);
            newBuilding.buildingMesh.transform.position = buildingPos;
            buildings.AddLast(newBuilding);
            if (SpaceStation.IsHub(btype))
            {
                hubBuildings.AddLast(newBuilding);
            }
        }
        return(true);
    }
Exemplo n.º 42
0
        public void ShipDocking(Ship ship, SpaceStation station)
        {
            _ship    = ship;
            _station = station;

            //NOTE:  The credits can be non integer, but I will just round down (actual purchaces may be portions of a dollar though)
            lblCredits.Content       = _ship.Credits.ToString("N0");
            lblRefuelCredits.Content = (Convert.ToDecimal(_ship.FuelQuantityMax - _ship.FuelQuantityCurrent) * _station.GetFuelValue()).ToString("N0");

            LoadResourcePanel();

            _programaticallySettingSwarmSettings = true;

            #region Set swarmbot formation

            string currentFormation = SWARMRADIOPREFIX + _ship.Swarmbots.ToString();

            foreach (UIElement child in pnlSwarmBots.Children)
            {
                RadioButton radio = child as RadioButton;
                if (radio == null)
                {
                    continue;
                }

                if (radio.Name == currentFormation)
                {
                    radio.IsChecked = true;
                    break;
                }
            }

            #endregion

            trkNumSwarmBots.Value = _ship.NumSwarmbots;

            _programaticallySettingSwarmSettings = false;
        }
Exemplo n.º 43
0
        public void ShipDocking(Ship ship, SpaceStation station)
        {
            _ship = ship;
            _station = station;

            //NOTE:  The credits can be non integer, but I will just round down (actual purchaces may be portions of a dollar though)
            lblCredits.Content = _ship.Credits.ToString("N0");
            lblRefuelCredits.Content = (Convert.ToDecimal(_ship.FuelQuantityMax - _ship.FuelQuantityCurrent) * _station.GetFuelValue()).ToString("N0");

            LoadResourcePanel();

            _programaticallySettingSwarmSettings = true;

            #region Set swarmbot formation

            string currentFormation = SWARMRADIOPREFIX + _ship.Swarmbots.ToString();

            foreach (UIElement child in pnlSwarmBots.Children)
            {
                RadioButton radio = child as RadioButton;
                if (radio == null)
                {
                    continue;
                }

                if (radio.Name == currentFormation)
                {
                    radio.IsChecked = true;
                    break;
                }
            }

            #endregion

            trkNumSwarmBots.Value = _ship.NumSwarmbots;

            _programaticallySettingSwarmSettings = false;
        }
Exemplo n.º 44
0
 public override void Deserialize(SpaceStation.Util.IntVector3 position, SerializedObject serializedObject)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 45
0
        private static void LocateFinalTarget(SpaceStation station)
        {
            var level = station.Levels[station.Levels.Count-1];
            var previousCorner = station.Levels[station.Levels.Count-2].StairsDownLocation;
            var corner = (Corner)RNG.GetNumber(0, 3, (int)previousCorner);

            var coordX = corner == Corner.TopLeft  ||  corner == Corner.BottomLeft ? 3 : MapConfig.LevelSize.Width - 4;
            var coordY = corner == Corner.TopLeft  ||  corner == Corner.TopRight ? 3 : MapConfig.LevelSize.Height - 4;

            for (var k = 0; k <= 1; k++)
                for (var j = 0; j <= 1; j++)
                    level.Map[coordY+k, coordX+j] = new Tile("FinalTarget");
        }
Exemplo n.º 46
0
    public void BuyShip(PlayerShip player, ShipType shipType, SpaceStation atStation)
    {
        var shipForSale = GetShipForSale(shipType);
        var oldShip = player.Ship;

        //check price
        Debug.Assert(player.Money >= shipForSale.Price, 
            "player can't afford to buy ship");

        var passengers = oldShip.GetPassengers();
        var captain = oldShip.GetCaptain();

        //check crew space
        Debug.Assert(shipForSale.ShipType.Stats.PassengerCapacity < passengers.Count(),
            "ship being bought doesn't have enough room for existing passengers");

        var newShip = shipType.CreateShip(player.transform.position, player.transform.rotation);
        
        //copy player
        var newPlayer = newShip.gameObject.AddComponent<PlayerShip>();
        newPlayer.AddMoney(player.Money - shipForSale.Price);

        //copy crew
        captain.Assign(newShip, CrewAssignment.Captain);
        foreach (var passenger in passengers)
        {
            passenger.Assign(newShip, CrewAssignment.Passenger);
        }
            
        Destroy(player.gameObject);
        SpaceTraderConfig.LocalPlayer = newPlayer;
    }
Exemplo n.º 47
0
 void OnUnmoored(SpaceStation station)
 {
     localStation = null;
     BeginAutoUndocking(station);
 }
Exemplo n.º 48
0
    private IEnumerator AutoUndockingRoutine(SpaceStation station)
    {
        //station should undock us in a safe place pointing the right way
        var dest = transform.position + transform.forward * DOCK_DISTANCE;
        var proximity = GetDockProximity();

        while ((ship.transform.position - dest).sqrMagnitude > proximity)
        {
            ship.ResetControls(thrust: 1);
            ship.RotateToPoint(dest);

            yield return null;
        }

        state = DockingState.InSpace;
        localStation = null;

        var shipAi = ship.GetComponent<AITaskFollower>();
        if (shipAi)
        {
            shipAi.ClearTasks();
        }
    }
Exemplo n.º 49
0
    private IEnumerator AutoDockingRoutine(SpaceStation spaceStation)
    {
        var points = spaceStation.UndockPoints.ToList();
        var pointIndex = UnityEngine.Random.Range(0, points.Count);

        var endPoint = points[pointIndex];
        var startPoint = points[pointIndex].position + (endPoint.position - spaceStation.transform.position).normalized * DOCK_DISTANCE; //TODO

        var proximity = GetDockProximity();

        //TODO
        var shipAi = ship.GetComponent<AITaskFollower>();
        if (!shipAi)
        {
            shipAi = ship.gameObject.AddComponent<AITaskFollower>();
            yield return null; //Start() needs to run
        }

        var goToEnd = FlyToPointTask.Create(endPoint.position, proximity);

        shipAi.AssignTask(goToEnd);

        if (!ship.CanSee(endPoint.position) && !goToEnd.Done)
        {
            var goToStart = FlyToPointTask.Create(startPoint, proximity);
            shipAi.AssignTask(goToStart);

            while (!goToStart.Done)
            {
                yield return null;
            }
        }
        
        while (!goToEnd.Done)
        {
            yield return null;
        }

        state = DockingState.Docked;
        spaceStation.AddDockedShip(this);
        
        shipAi.ClearTasks();
    }
Exemplo n.º 50
0
 public override void Update(SpaceStation.Util.IntVector3 position)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 51
0
        private void btnLaunch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.LaunchShip == null)
                {
                    MessageBox.Show("There is no event listener for the launch button", "Launch Button", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                // This panel is about to close, so forget my reference to the ship and station
                _ship = null;
                _station = null;

                this.LaunchShip(this, new EventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Space Dock", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 52
0
        private void ShowSpaceDock(SpaceStation station)
        {
            PauseWorld();

            spaceDock.ShipDocking(_ship, station);

            spaceDock.Visibility = Visibility.Visible;
        }
Exemplo n.º 53
0
 void OnMoored(SpaceStation station)
 {
     localStation = station;
     state = DockingState.Docked;
 }
Exemplo n.º 54
0
 private static void CreateItemsOnFloor(SpaceStation station)
 {
 }
Exemplo n.º 55
0
    private void BeginAutoUndocking(SpaceStation station)
    {
        state = DockingState.AutoDocking;

        //make sure our local station is set, so AutoDockingStation points to it
        localStation = station;

        StartCoroutine(AutoUndockingRoutine(station));
    }
Exemplo n.º 56
0
        private static void LocateStairs(SpaceStation station)
        {
            var previousCorner = -1;
            for (var i = 0; i < station.Levels.Count-1; i++)
            {
                var corner = (Corner)RNG.GetNumber(0, 3, previousCorner);
                previousCorner = (int)corner;

                var stairsCoordX = corner == Corner.TopLeft  ||  corner == Corner.BottomLeft ? 3 : MapConfig.LevelSize.Width - 4;
                var stairsCoordY = corner == Corner.TopLeft  ||  corner == Corner.TopRight ? 3 : MapConfig.LevelSize.Height - 4;

                station.Levels[i].StairsDownLocation = corner;
                for (var k = 0; k < 2; k++)
                for (var j = 0; j < 2; j++)
                    {
                        station.Levels[i].Map[stairsCoordY+k, stairsCoordX+j]   = new Tile("StairsDown");
                        station.Levels[i+1].Map[stairsCoordY+k, stairsCoordX+j] = new Tile("StairsUp");
                    }
            }
        }
Exemplo n.º 57
0
        private void CreateSpaceStationsSprtBuild(Point3D position)
        {
            SpaceStation spaceStation = new SpaceStation();
            spaceStation.SpinDegreesPerSecond = Math1D.GetNearZeroValue(10d);
            spaceStation.HullColor = UtilityWPF.AlphaBlend(UtilityWPF.GetRandomColor(108, 148), Colors.Gray, .25);
            spaceStation.CreateStation(_map, position);

            _spaceStations.Add(spaceStation);
        }
Exemplo n.º 58
0
 public int GetBuyingItemPrice(ItemType itemType, SpaceStation atStation)
 {
     return itemType.BaseValue;
 }
Exemplo n.º 59
0
    public void BeginAutoDocking(SpaceStation station)
    {
        if (LocalStation != station)
        {
            return;
        }

        state = DockingState.AutoDocking;

        StartCoroutine(AutoDockingRoutine(station));
    }
Exemplo n.º 60
0
 void Start()
 {
     ship = GetComponent<Ship>();
     localStation = null;
     state = DockingState.InSpace;
 }