private void Start()
    {
        Application.runInBackground = true;

        Universe = new OSTData.Universe(0);
        Universe.Build();

        PlayerCorp = Universe.CreateCorp(1);
        PlayerCorp.AddICU(200, "starting");

        OSTData.Station city = Universe.GetStation(2);
        city.CreateHangar(PlayerCorp);
        OSTData.Station mine = Universe.GetStation(6);
        mine.CreateHangar(PlayerCorp);
        OSTData.Station reprocessing = Universe.GetStation(21);
        reprocessing.CreateHangar(PlayerCorp);
        OSTData.Ship            ship = city.CreateShip(PlayerCorp);
        OSTData.ShipDestination dest = ship.AddDestination(city);
        dest.AddLoad(OSTData.ResourceElement.ResourceType.Wastes, 50);
        OSTData.ShipDestination dest2 = ship.AddDestination(mine);
        dest2.AddUnload(OSTData.ResourceElement.ResourceType.Wastes, 50);
        ship.Start();

        OSTData.Ship            ship2 = mine.CreateShip(PlayerCorp);
        OSTData.ShipDestination dest3 = ship2.AddDestination(reprocessing);
        dest3.AddUnload(OSTData.ResourceElement.ResourceType.Wastes, 100);
        OSTData.ShipDestination dest4 = ship2.AddDestination(mine);
        dest4.AddLoad(OSTData.ResourceElement.ResourceType.Wastes, 100);
        ship2.Start();
    }
Пример #2
0
        /// <summary>
        /// Indique a la station d'effectuer le travail qu'elle doit faire a la fin d'une journee
        /// </summary>
        /// <param name="timestamp">le timestamp en cours</param>
        public void EndDays(int timestamp)
        {
            Hangar stationHangar = GetHangar(-1);

            foreach (Receipe r in _receipies)
            {
                for (int qte = 0; qte < r.MaxFreq; qte++)
                {
                    if (!r.ProduceOneBatch(this, timestamp))
                    {
                        break;
                    }
                }
            }

            //pour tout les corp qui ont chargé dans ce jour une certaine ressources, on leur boost leur standing
            foreach (int i in _currentLoaders.Keys)
            {
                foreach (ResourceElement.ResourceType t in _currentLoaders[i])
                {
                    Corporation corp = System.Universe.GetCorporation(i);
                    if (null != corp)
                    {
                        float oldStanding = GetStanding(t, i);
                        float newStanding = oldStanding + (1.0f - oldStanding) * 0.05f;
                        SetStanding(t, i, newStanding);
                    }
                }
            }
            _currentLoaders.Clear();

            //mettre a jour les prix d'achats
            UpdateBuyingPrices();
        }
Пример #3
0
        /// <summary>
        /// creer un hangar dans la station pour la owner donne, ou retourner celui existant
        /// s'il existe deja
        /// </summary>
        /// <param name="owner">la corporation a qui appartient ce hangar</param>
        /// <returns>le hangar creer, ou celui qui existait deja</returns>
        public Hangar CreateHangar(Corporation owner)
        {
            Hangar result = GetHangar(owner.ID);

            if (null == result)
            {
                result = new Hangar(this, owner);
                _hangars.Add(owner.ID, result);
            }

            return(result);
        }
Пример #4
0
        /// <summary>
        /// Permet de creer une nouvelle corporation dans l'univers.
        /// De base la corporation possede un capital de 100 ICU.
        /// </summary>
        /// <param name="ID"> L'identifiant unique de la corp</param>
        /// <returns> La corporation cree si l'id etait libre, null sinon</returns>
        public Corporation CreateCorp(int ID)
        {
            if (_corporations.ContainsKey(ID))
            {
                return(null);
            }

            Corporation corp = new Corporation(ID);

            _corporations.Add(ID, corp);
            corp.AddICU(100, "starting");
            return(corp);
        }
Пример #5
0
        /// <summary> Permet de creer un vaisseau dans cette station. </summary>
        /// <param name="corp"> La corporation proprietaire de ce vaisseau. </param>
        /// <returns> Le vaisseau cree. </returns>
        public Ship CreateShip(Corporation corp)
        {
            if (corp.ICU < 100)
            {
                return(null);
            }

            Ship result = new Ship(System.Universe.Ships.Count + 1, corp);

            result.CurrentStation = this;
            System.Universe.Ships.Add(result);
            corp.RemoveICU(100, "Buying ship");

            return(result);
        }
Пример #6
0
 /// <summary> Le constructeur de base </summary>
 /// <param name="id"> L'id unique de ce vaisseau</param>
 /// <param name="owner"> La corporation qui possede ce vaisseau </param>
 public Ship(int id, Corporation owner)
 {
     ID    = id;
     Cargo = new ShipCargo(this);
     Owner = owner;
 }
Пример #7
0
        private void HardCordedBuildUniverse()
        {
            _stations     = new Dictionary <int, Station>();
            _corporations = new Dictionary <int, Corporation>();
            Systems       = new Dictionary <int, StarSystem>();
            Portals       = new List <Portal>();
            Ships         = new List <Ship>();

            //creaction de la corp NPC

            Corporation npcCorp = new Corporation(-1);

            _corporations.Add(-1, npcCorp);

            //creation des systemes
            for (int i = 0; i < _nbSystemPerMap; i++)
            {
                StarSystem sys = new StarSystem(i, this, GetRandomSystemPosition());
                sys.Name = "System " + (i + 1);
                Systems.Add(i, sys);

                //creation d'une cite
                OSTTools.Vector3 stationPos = new OSTTools.Vector3(1.0, 1.0, 1.0);
                Station          s          = new Station(Station.StationType.City, Systems[i], stationPos, _stations.Count + 1);
                s.Name = "city " + i;
                _stations.Add(s.ID, s);
                Systems[i].Stations.Add(s);
            }

            //creation des stations mines
            for (int i = 0; i < _nbMine; i++)
            {
                StarSystem sys = Systems[_random.Next(_nbSystemPerMap)];
                Station    s   = new Station(Station.StationType.Mine, sys, GetRandomStationPosition(), _stations.Count + 1);
                s.Name = "mine " + i;
                _stations.Add(s.ID, s);
                sys.Stations.Add(s);
            }

            for (int i = 0; i < _nbIceField; i++)
            {
                StarSystem sys = Systems[_random.Next(_nbSystemPerMap)];
                Station    s   = new Station(Station.StationType.IceField, sys, GetRandomStationPosition(), _stations.Count + 1);
                s.Name = "ice field " + i;
                _stations.Add(s.ID, s);
                sys.Stations.Add(s);
            }

            Array allTypes = Enum.GetValues(typeof(Station.StationType));

            while (_stations.Count < _nbStation)
            {
                StarSystem          sys  = Systems[_random.Next(_nbSystemPerMap)];
                Station.StationType type = (Station.StationType)allTypes.GetValue(_random.Next(allTypes.Length - 3) + 3);
                Station             s    = new Station(type, sys, GetRandomStationPosition(), _stations.Count + 1);
                s.Name = type.ToString() + " " + (_stations.Count + 1);
                _stations.Add(s.ID, s);
                sys.Stations.Add(s);
            }

            //creation des links entre systeme
            for (int i = 0; i < _nbSystemPerMap; i++)
            {
                for (int j = i + 1; j < _nbSystemPerMap; j++)
                {
                    Station from = Systems[i].Stations[_random.Next(Systems[i].Stations.Count)];
                    Station to   = Systems[j].Stations[_random.Next(Systems[j].Stations.Count)];
                    Portal  p    = new Portal(from, to, Portal.PortalType.StarToStar);
                    from.AddGate(p);
                    to.AddGate(p);
                    Portals.Add(p);
                }
                //creer les liens internes
                List <Station> connected = new List <Station>();
                foreach (Station s in Systems[i].Stations)
                {
                    Station closest  = null;
                    double  bestDist = 0.0;
                    foreach (Station s2 in connected)
                    {
                        if (s2 != s)
                        {
                            double dist = (s2.Position.X - s.Position.X) * (s2.Position.X - s.Position.X) +
                                          (s2.Position.Y - s.Position.Y) * (s2.Position.Y - s.Position.Y) +
                                          (s2.Position.Z - s.Position.Z) * (s2.Position.Z - s.Position.Z);
                            if (closest == null || dist < bestDist)
                            {
                                bestDist = dist;
                                closest  = s2;
                            }
                        }
                    }
                    if (closest != null)
                    {
                        Portal p = new Portal(s, closest, Portal.PortalType.StationToStation);
                        s.AddGate(p);
                        closest.AddGate(p);
                        Portals.Add(p);
                    }
                    connected.Add(s);
                }
            }
        }
 public void SetData(OSTData.Corporation playerCorp)
 {
     _playerCorp              = playerCorp;
     _playerCorp.onICUChange += OnICUChange;
     UpdateView();
 }
Пример #9
0
 /// <summary>
 /// Constructeur de base
 /// </summary>
 /// <param name="station">La station qui contient ce hangar</param>
 /// <param name="corporation">La corporation a qui appartient ce hangar</param>
 public Hangar(Station station, Corporation corporation)
 {
     Station     = station;
     Corporation = corporation;
 }