Esempio n. 1
0
        static void Main(string[] args)
        {
            bool            ld    = false;
            PlanetarySystem plsys = new PlanetarySystem();
            Planet          earth = new Planet("Earth", 'e', true);
            Planet          mars  = new Planet("Mars", 'e', false);
            Station         iss   = new Station("ISS-2", true, 3);
            Station         uran  = new Station("Uranus-1", false, 0);

            plsys.add(iss);
            plsys.add(earth);
            plsys.add(uran);
            plsys.add(mars);

            plsys.current();
            plsys.next();
            plsys.next();
            plsys.prev();

            plsys.useScan();
            ld = plsys.useLand(ld);
            ld = plsys.useTakeoff(ld);

            plsys.del();
            plsys.del();
        }
Esempio n. 2
0
        static void TESTClone(PlanetarySystem systemToClone)
        {
            var clone = systemToClone.Clone();

            clone.Name      += "CLONE";
            clone.Star.Name += "CLONE";
            clone.Planets.ToList().ForEach(p => p.Name   += "CLONE");
            clone.Moons.ToList().ForEach(m => m.Name     += "CLONE");
            clone.Asteroids.ToList().ForEach(a => a.Name += "CLONE");
            clone.Moons.ToList().ForEach(art => art.Name += "CLONE");

            Console.WriteLine(systemToClone.Name);
            Console.WriteLine(systemToClone.Star.Name);
            systemToClone.Planets.ToList().ForEach(p => Console.WriteLine(p.Name));
            systemToClone.Moons.ToList().ForEach(m => Console.WriteLine(m.Name));
            systemToClone.Asteroids.ToList().ForEach(a => Console.WriteLine(a.Name));
            systemToClone.ArtificialObjects.ToList().ForEach(art => Console.WriteLine(art.Name));
            Console.WriteLine();
            Console.WriteLine(clone.Name);
            Console.WriteLine(clone.Star.Name);
            clone.Planets.ToList().ForEach(p => Console.WriteLine(p.Name));
            clone.Moons.ToList().ForEach(m => Console.WriteLine(m.Name));
            clone.Asteroids.ToList().ForEach(a => Console.WriteLine(a.Name));
            clone.ArtificialObjects.ToList().ForEach(art => Console.WriteLine(art.Name));
        }
Esempio n. 3
0
        private void LoadPlanetarySystemToTree(PlanetarySystem planetarySystem)
        {
            if (currentPlanetarySystem != null)
            {
                listboxOfPlanetarySystems.Visible = false;
                planetarySystemTreeView.Nodes.Clear();
                planetarySystemTreeView.Nodes.Add(planetarySystem.Name);
                var planetarySystemNode = planetarySystemTreeView.Nodes[0];
                if (planetarySystem.Star != null)
                {
                    planetarySystemNode.Nodes.Add($"Star: {planetarySystem.Star.Name}");
                }
                else
                {
                    planetarySystemNode.Nodes.Add($"No star assigned");
                }

                var starNode = planetarySystemNode.Nodes[0];

                planetarySystemNode.Nodes.Add("Planets:");
                var planetsNode = planetarySystemNode.Nodes[1];
                var planets     = planetarySystem.Planets.ToList();
                for (int i = 0; i < planets.Count; i++)
                {
                    planetsNode.Nodes.Add(planets[i].Name);
                    var planetNode = planetsNode.Nodes[i];
                    planetNode.Nodes.Add("Moons:");
                    var moonsNode = planetNode.Nodes[0];
                    foreach (var m in planets[i].Moons)
                    {
                        moonsNode.Nodes.Add(m.Name);
                    }
                }

                planetarySystemNode.Nodes.Add("Asteroids:");
                var asteroidsNode = planetarySystemNode.Nodes[2];
                foreach (var asteroid in planetarySystem.Asteroids)
                {
                    asteroidsNode.Nodes.Add(asteroid.Name);
                }

                planetarySystemNode.Nodes.Add("Artificial objects:");
                var artificialObjectsNode = planetarySystemNode.Nodes[3];
                foreach (var artObj in planetarySystem.ArtificialObjects)
                {
                    artificialObjectsNode.Nodes.Add(artObj.Name);
                }

                planetarySystemTreeView.Nodes[0].Expand();
            }
            else
            {
                if (planetarySystemTreeView.Nodes.Count > 0)
                {
                    planetarySystemTreeView.Nodes.Remove(planetarySystemTreeView.Nodes[0]);
                }
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var system = PlanetarySystem.Create(new List <String>()
            {
                "Earth"
            });

            system.Evolve(10e-7);
        }
Esempio n. 5
0
 public static PlanetarySystem create()
 {
     var p = new PlanetarySystem();
     p.sunSecondsLeft = 30f + Random.value * 60f;
     p.sunUV = 0.25f;
     p.sunIR = 0.15f;
     p.sunGamma = 0.15f;
     p.sunEnergyLeft = 3;
     p.creatureCounts = new Dictionary<int, int>();
     return p;
 }
Esempio n. 6
0
        public SaveFile_PlanetarySystem(PlanetarySystem planetarySystem)
        {
            this.Id = planetarySystem.Data.Id;

            this.Planets = new SaveFile_Planet[planetarySystem.Planets.Length];

            for (int i = 0; i < Planets.Length; i++)
            {
                Planets[i] = new SaveFile_Planet(planetarySystem.Planets[i].Data.Id, planetarySystem.Planets[i].Visited);
            }
        }
Esempio n. 7
0
        public void Load_PlanetarySystems()
        {
            PlanetarySystem[] systems = new PlanetarySystem[PlanetarySystemIds.Length];

            for (int i = 0; i < systems.Length; i++)
            {
                systems[i] = new PlanetarySystem(DataController.LoadData <PlanetarySystemData>(PlanetarySystemIds[i], DataFileType.PlanetarySystems));
            }

            GalaxyController.AddVisitables(systems);
        }
Esempio n. 8
0
 private void listboxOfPlanetarySystems_SelectedIndexChanged(object sender, EventArgs e)
 {
     currentPlanetarySystem = Database.LoadPlanetarySystem(listboxOfPlanetarySystems.SelectedItem.ToString());
     LoadPlanetarySystemToTree(currentPlanetarySystem);
     ClearPropertiesControls();
     listboxOfPlanetarySystems.Visible = false;
     listboxOfPlanetarySystems.Items.Clear();
     planetarySystemTreeView.Visible = true;
     SetScale();
     Backup();
 }
Esempio n. 9
0
    // PUBLIC METHODS
    public void SetupScene()
    {
        // init members
        sys    = new PlanetarySystem(sectorSize);
        player = GameObject.FindGameObjectWithTag("Player").transform;
        //player.position = new Vector2(0f, 0f);
        renderedSectors = new HashSet <Sector>();
        prevSector      = CurrentSector();

        // create planets and artifacts
        //RenderAdjacentSectors(prevSector);
    }
Esempio n. 10
0
    public void createSystem()
    {
        system = Instantiate(sysPrefab).transform;
        if (debugOut == 1)
        {
            Debug.Log("[Star/createSystem]: New System! x:" + system.position.x + " y:" + system.position.y);
        }

        sysScript = system.gameObject.GetComponent <PlanetarySystem>();
        system.SetParent(transform);
        sysScript.sysName = starName;
        sysScript.star    = gameObject;
    }
Esempio n. 11
0
        override public void init()
        {
            universe       = (SpaceObject)Registry.getInstance().getElement("universe");
            timer          = new GCore.Timer();
            timer.interval = 3000;
            timer.stop();

            game_run = false;

            keeper.add(Game.interfaceView, console);
            console.text = "init";

            PlanetarySystem ss = (PlanetarySystem)Registry.getInstance().getElement("s0000001");

            current_ps = new PlanetarySystemView(ss);

            keeper.add(Game.stage, current_ps);
            ss.nextTick(0.0001f);
            Bitmap bg = new Bitmap();

            bg.load("DATA\\Backgrounds\\1.jpg");
            keeper.add(Game.background, bg);

            Game.camera.scaleX = Game.camera.scaleY = 1f;

            Player mplayer = (Player)Registry.getInstance().getElement("player");

            mplayer.ship.setHull(Economy.hulls[0]);
            mplayer.ship.setEngine(Economy.engines[0]);
            player = new AIController(mplayer);
            PlayerSpaceView view = new PlayerSpaceView(mplayer, current_ps);

            view.rotationZ = (float)Math.PI / 2;

            for (int i = 0; i < 200; i++)
            {
                Player          r     = createRandomPlayer();
                AIController    aic   = new AIController(r);
                PlayerSpaceView view2 = new PlayerSpaceView(r, current_ps);
                keeper.add(view2, MouseEvent.CLICK, clickAtShip);
                con.Add(aic);
                GameWorld.players.Add(r);
            }

            keeper.add(Game.mouse, MouseEvent.CLICK, onClick);
            keeper.add(Game.mouse, MouseEvent.MOUSE_WHEEL, onWheel);
            keeper.add(Game.mouse, MouseEvent.MOUSE_MOVE, onMove);
            keeper.add(Game.keyboard, KeyboardEvent.KEY_UP, onKeyUp);
            keeper.add(timer, TimerEvent.TIMER, onTimer);
        }
    public void SetPositionAtTimeSetsInitialPositionsForZeroTime()
    {
      PlanetarySystem system = new PlanetarySystem();
      OrbitMechanics.SetPositionAtTime(0, system.Star);

      var earth = system.Star.OrbitingObjects.FirstOrDefault(o => o.Name == "Terra");
      Assert.AreEqual(0, earth.CurrentPosition.Polar);
      Assert.AreEqual(0, earth.CurrentPosition.Elevation);
      Assert.AreEqual(earth.Orbit.MeanDistance, earth.CurrentPosition.Radius);
      var moon = earth.OrbitingObjects.FirstOrDefault(o => o.Name == "Luna");
      Assert.AreEqual(0, moon.CurrentPosition.Polar);
      Assert.AreEqual(0, moon.CurrentPosition.Elevation);
      Assert.AreEqual(moon.Orbit.MeanDistance, moon.CurrentPosition.Radius);
    }
Esempio n. 13
0
    //void MovementComplete ()
    //{
    //  tween.Kill();
    //  transform.localEulerAngles = new Vector3( 0, 0, 0 );
    //}

    void Start()
    {
        nPlanetsExplored++;
        planetarySystem = GameObject.Find("PlanetarySystem").GetComponent <PlanetarySystem>();
        ship            = GetComponent <Ship>();
        events          = GameObject.Find("Events").GetComponent <Events>();
        gameUI          = GameObject.Find("GameUI").GetComponent <GameUI>();
        //tween = transform.DOMove( new Vector3( 45, 80, 0 ), 15, true ).SetSpeedBased( true );
        //tween.OnComplete( MovementComplete );
        AudioSource audioSrc = GetComponent <AudioSource>();

        audioSrc.clip = ambientClip;
        audioSrc.Play();
    }
Esempio n. 14
0
        public static void generate(XmlDocument config)
        {
            SpaceObject space = new SpaceObject("Вселенная", 0, null, new RelativeMovement());

            RegistrySystem.Registry.getInstance().addElement(space, "universe");
            foreach (XmlNode table in config.DocumentElement)
            {
                String          id   = rs(table.Attributes["id"]);
                String          name = rs(table.Attributes["name"]);
                PlanetarySystem ps   = new PlanetarySystem(name);
                RegistrySystem.Registry.getInstance().addElement(ps, id);
                f(table, ps);
            }
        }
Esempio n. 15
0
    void Start()
    {
        Time.timeScale = 1.0f;
        // options for game length, 3 for quick, 6 for medium, 8 for long
        int planetaryBodies = Random.Range(8, 13);

        Debug.Log("Generating " + planetaryBodies + " planetary bodies");
        Generate(planetaryBodies);

        PlanetarySystem planetarySystem = GetComponent <PlanetarySystem>();

        planetarySystem.nStars   = nStars;
        planetarySystem.nPlanets = nPlanets;
        planetarySystem.nMoons   = nMoons;
        GameObject.Destroy(this);
    }
Esempio n. 16
0
        static PlanetarySystem GetSolarSystem()
        {
            PlanetarySystem solarSystem = new PlanetarySystem("Solar system");

            Models.Bodies.Star sun = new Models.Bodies.Star(
                center: new Point(0, 0, 0),
                mass: 2 * Math.Pow(10, 30),
                radius: 5,
                velocity: new Vector(0, 0, 0),
                name: "Sun");
            solarSystem.SetStar(sun);

            Planet earth = new Planet(
                center: new Point(0, 0, 0),
                mass: 5.972 * Math.Pow(10, 24),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "Earth");

            solarSystem.AddPlanetByOrbitalRadius(earth, 150 * Math.Pow(10, 9), 0);

            //Moon moon = new Moon(
            //    center: new Point(0, 0, 0),
            //    mass: 7.342 * Math.Pow(10, 22),
            //    radius: 5,
            //    velocity: new Vector(new Point(0, 0, 0)),
            //    name: "Moon");
            //solarSystem.AddMoonByOrbitalSpeed(moon, earth, 1022);

            //Asteroid someAsteroid = new Asteroid(
            //    center: new Point(380 * Math.Pow(10, 13), 4560, 7867860),
            //    mass: 7987,
            //    radius: 5,
            //    velocity: new Vector(new Point(-456, 645, 6)),
            //    name: "someAsteroid");
            //solarSystem.AddAsteroid(someAsteroid);

            //ArtificialObject something = new ArtificialObject(
            //    center: new Point( -456786, 1568790, 12370),
            //    mass: 2000,
            //    radius: 5,
            //    velocity: new Vector(new Point(620, -82, 894)),
            //    name: "something");
            //solarSystem.AddArtificialObject(something);

            return(solarSystem);
        }
  // Use this for initialization
  void Start()
  {
    system = new PlanetarySystem();
    OrbitMechanics.SetPositionAtTime(currentTime, system.Star);

    //create GameObjects for the star
    GameObject starGameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
    starGameObject.name = system.Star.Name;
    system.Star.UnityObject = starGameObject;
    var sizeScale = system.Star.Size * SunSizeToWorldUnits;
    starGameObject.transform.localScale = new Vector3(sizeScale, sizeScale, sizeScale);
    starGameObject.transform.position = system.Star.CurrentPosition.ToCartesian() * AUToWorldUnits;
    //create GameObjects for each object in the system
    foreach (SpaceObject orbitingObject in system.Star.OrbitingObjects)
    {
      BuildSystemGameOjects(orbitingObject, starGameObject);
      DrawOrbit(orbitingObject);
    }
  }
Esempio n. 18
0
    public bool createCluster()
    {
        bool cluster_created = false;

        if(num_systems > 0){
          //create the cluster!
          float sdistance = 0f;
          base.sub_spheres = new SphereRenderer[num_systems];

          for(int i = 0; i < num_systems; ++i){
        float omega = Random.Range(0, 2*Mathf.PI);
        /*uncomment to implement system types and mass
        int stype = Random.Range(0, 2);
        float smass = Random.Range(1000f, 100000f);
        */
        float sradius = Random.Range(500f, 800f);
        sdistance = Random.Range(sdistance, sdistance + 50);
        Vector3 sposition = new Vector3(position.x + sdistance*Mathf.Cos(omega) , Random.Range(-100, 100), position.z + sdistance*Mathf.Sin(omega));
        sdistance += sradius;

        string sname = name + ": " + i;

        /*
        float sdistance = Random.Range(pdistance, radius) + (2 * pdistance)
        */
        PlanetarySystem system = new PlanetarySystem(stype, 0, sname, sradius, 0, sposition);
        system.setNumPlanets(Random.Range(3, 9));
        if(!system.createSystem()){
          cluster_created = false;
          break;
        }
        else{
          factory = (SphereRendererFactory)GameObject.Find("SphereRendererFactory").GetComponent("SphereRendererFactory");
          base.sub_spheres[i] = factory.createSphereRenderer();
          base.sub_spheres[i].initialize(0, 0, system_threshold,1,  system);
          //base.sub_spheres[i].setIsDisplayed(true);
        }
        cluster_created = true;
          }
        }
        return cluster_created;
    }
Esempio n. 19
0
        public void CreateTestData()
        {
            var galaxy = new Galaxy()
            {
                Name = "milkyway"
            };
            var planetarySystem = new PlanetarySystem()
            {
                Name = "solar", Galaxy = galaxy
            };

            galaxy.PlanetarySystems.Add(planetarySystem);
            var planet = new Planet()
            {
                Name = "earth", PlanetarySystem = planetarySystem
            };

            planetarySystem.Planets.Add(planet);
            Save(galaxy);
        }
Esempio n. 20
0
        static void TESTPopulateDb()
        {
            using (SqlServerContext context = new SqlServerContext())
            {
                PlanetarySystem    solarSystem = new PlanetarySystem("Solar system");
                Models.Bodies.Star sun         = new Models.Bodies.Star(
                    center: new Point(0, 0, 0),
                    mass: 2 * Math.Pow(10, 30),
                    radius: 5,
                    velocity: new Vector(0, 0, 0),
                    name: "Sun");

                Planet earth = new Planet(
                    center: new Point(0, 0, 0),
                    mass: 5.972 * Math.Pow(10, 24),
                    radius: 5,
                    velocity: new Vector(new Point(0, 0, 0)),
                    name: "Earth");
                Moon moon = new Moon(
                    center: new Point(0, 0, 0),
                    mass: 7.342 * Math.Pow(10, 22),
                    radius: 5,
                    velocity: new Vector(new Point(0, 0, 0)),
                    name: "Moon");


                solarSystem.SetStar(sun);
                solarSystem.AddPlanetByOrbitalRadius(earth, 150 * Math.Pow(10, 9), 0);
                //solarSystem.AddPlanetByOrbitalSpeed(earth, 29780);
                solarSystem.AddMoonByOrbitalRadius(moon, earth, 384000000, 0);
                //solarSystem.AttachMoonToPlanetByOrbitalSpeed(moon, earth, 1022);

                context.PlanetarySystems.Add(solarSystem);
                context.Stars.Add(sun);
                context.Planets.Add(earth);
                context.Moons.Add(moon);

                Console.WriteLine("presave");
                context.SaveChanges();
            }
        }
Esempio n. 21
0
 public static bool SavePlanetarySystem(PlanetarySystem planetarySystem)
 {
     try
     {
         DeletePlanetarySystem(planetarySystem.Name);
         using (var context = new SqlServerContext())
         {
             context.PlanetarySystems.Add(planetarySystem);
             context.Stars.Add(planetarySystem.Star);
             context.Planets.AddRange(planetarySystem.Planets);
             context.Moons.AddRange(planetarySystem.Moons);
             context.Asteroids.AddRange(planetarySystem.Asteroids);
             context.ArtificialObjects.AddRange(planetarySystem.ArtificialObjects);
             context.SaveChanges();
         }
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 22
0
 private void Backup()
 {
     backupPlanetarySystem = currentPlanetarySystem.Clone();
 }
Esempio n. 23
0
 public static void SetPlanetarySystem(PlanetarySystem planetarySystem)
 {
     CurrentPlanetarySystem = planetarySystem;
 }
Esempio n. 24
0
 public Planemo(string name, PlanetarySystem planetarySystem)
     : base(name)
 {
     PlanetarySystem = planetarySystem;
     planetarySystem.Planets.Add(this);
 }
Esempio n. 25
0
        private void createNewButton_Click(object sender, EventArgs e)
        {
            try
            {
                ClearCreateNewSection();
                double coveredAngle = 0;
                try
                {
                    coveredAngle = double.Parse(createNewCoveredAngleBox.Text);
                }
                catch (Exception exc)
                { }

                double mass             = 0;
                double radius           = 0;
                double orbitalParameter = 0;
                if (createNewTypeBox.SelectedIndex != 0)
                {
                    mass             = MathUtilities.ParseFromExpNotation(double.Parse(createNewMassBox.Text), int.Parse(createNewMassEBox.Text));
                    radius           = MathUtilities.ParseFromExpNotation(double.Parse(createNewRadiusBox.Text), int.Parse(createNewRadiusEBox.Text));
                    orbitalParameter = MathUtilities.ParseFromExpNotation(double.Parse(orbitalParameterBox.Text), int.Parse(orbitalParameterEBox.Text));
                }

                switch (createNewTypeBox.SelectedIndex)
                {
                case 0:
                    currentPlanetarySystem = new PlanetarySystem(createNewNameBox.Text);
                    Star star = new Star(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        1,
                        1,
                        createNewNameBox.Text + "\' star");
                    currentPlanetarySystem.SetStar(star);
                    break;

                case 1:
                    Planet planet = new Planet(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        mass,
                        radius,
                        createNewNameBox.Text);

                    if (orbitByRadiusRadio.Checked)
                    {
                        currentPlanetarySystem.AddPlanetByOrbitalRadius(
                            planet,
                            orbitalParameter,
                            coveredAngle);
                    }
                    else
                    {
                        currentPlanetarySystem.AddPlanetByOrbitalSpeed(
                            planet,
                            orbitalParameter,
                            coveredAngle);
                    }
                    break;

                case 2:
                    string planetName = createNewPrimeSelectionBox.Text;
                    var    primeQuery = from p in currentPlanetarySystem.Planets
                                        where p.Name == planetName
                                        select p;
                    var  prime = primeQuery.FirstOrDefault();
                    Moon moon  = new Moon(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        mass,
                        radius,
                        createNewNameBox.Text);

                    if (orbitByRadiusRadio.Checked)
                    {
                        currentPlanetarySystem.AddMoonByOrbitalRadius(
                            moon,
                            prime,
                            orbitalParameter,
                            coveredAngle);
                    }
                    else
                    {
                        currentPlanetarySystem.AddMoonByOrbitalSpeed(
                            moon,
                            prime,
                            orbitalParameter,
                            coveredAngle);
                    }
                    break;

                case 3:
                    Asteroid asteroid = new Asteroid(
                        new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                        mass,
                        radius,
                        createNewNameBox.Text);
                    currentPlanetarySystem.AddAsteroid(asteroid);
                    break;

                case 4:
                    ArtificialObject artObj = new ArtificialObject(new PlanetSystem.Models.Utilities.Point(0, 0, 0),
                                                                   mass,
                                                                   radius,
                                                                   createNewNameBox.Text);
                    currentPlanetarySystem.AddArtificialObject(artObj);
                    break;
                }
                LoadPlanetarySystemToTree(currentPlanetarySystem);
                Backup();
            }
            catch (Exception exc)
            {
            }
        }
Esempio n. 26
0
 public PlanetarySystemView(PlanetarySystem so)
 {
     this.planerarySystemModel = so;
     rec(this, so);
 }
Esempio n. 27
0
    void Start()
    {
        planetarySystem = GameObject.Find("PlanetarySystem").GetComponent <PlanetarySystem>();
        player          = GameObject.Find("PlayerShip").GetComponent <Player>();
        ship            = GameObject.Find("PlayerShip").GetComponent <Ship>();
        battleSystem    = GameObject.Find("BattleSystem").GetComponent <BattleSystem>();

        targetPanel            = GameObject.Find("TargetPanel").transform;
        targetTxt              = targetPanel.FindChild("TargetTxt").GetComponent <Text>();
        planetTypeTxt          = targetPanel.FindChild("PlanetTypeTxt").GetComponent <Text>();
        fuelCompoundsTxt       = targetPanel.FindChild("FuelCompoundsTxt").GetComponent <Text>();
        structuralCompoundsTxt = targetPanel.Find("StructuralCompoundsTxt").GetComponent <Text>();
        ordnanceCompoundsTxt   = targetPanel.Find("OrdnanceCompoundsTxt").GetComponent <Text>();
        edibleFoodTxt          = targetPanel.Find("EdibleFoodTxt").GetComponent <Text>();
        targetStr              = "Select a target";
        planetTypeStr          = "Unknown Planet Type";
        fuelCompoundsStr       = "Unknown Resource 0";
        structuralCompoundsStr = "Unknown Resource 0";
        ordnanceCompoundsStr   = "Unknown Resource 0";
        edibleFoodStr          = "Unknown Resource 0";

        shipPanel                = GameObject.Find("ShipPanel").transform;
        yourShipTxt              = shipPanel.FindChild("YourShipTxt").GetComponent <Text>();
        yourShieldsTxt           = shipPanel.FindChild("ShieldsTxt").GetComponent <Text>();
        yourArmorTxt             = shipPanel.FindChild("ArmorTxt").GetComponent <Text>();
        yourHullTxt              = shipPanel.FindChild("HullTxt").GetComponent <Text>();
        yourDamageOutputTxt      = shipPanel.FindChild("DamageOutputTxt").GetComponent <Text>();
        yourShipTxt.text         = "Your Ship — \"" + ship.shipName + "\"";
        yourShieldsTxt.text      = "Shields " + ship.shields + "/" + ship.maxShields;
        yourArmorTxt.text        = "Armor " + ship.armor + "/" + ship.maxArmor;
        yourHullTxt.text         = "Hull " + ship.hull + "/" + ship.maxHull;
        yourDamageOutputTxt.text = "Damage Output " + ship.damageOutput;

        eventPopupPanel = GameObject.Find("EventPopupPanel").transform;
        eventTitleTxt   = eventPopupPanel.FindChild("EventTitleTxt").GetComponent <Text>();
        eventDescrTxt   = eventPopupPanel.FindChild("EventDescrTxt").GetComponent <Text>();
        eventPopupPanel.gameObject.SetActive(false);

        battlePanel    = GameObject.Find("BattlePanel").transform;
        battleTitleTxt = battlePanel.FindChild("BattleTitleTxt").GetComponent <Text>();
        battleLogTxt   = battlePanel.FindChild("BattleLogTxt").GetComponent <Text>();
        battleTimerTxt = battlePanel.FindChild("BattleTimerTxt").GetComponent <Text>();
        yourShipImg    = battlePanel.FindChild("YourShipImg").GetComponent <Image>();
        AIShipImg      = battlePanel.Find("AIShipImg").GetComponent <Image>();
        battlePanel.gameObject.SetActive(false);

        shipTargetPanel           = GameObject.Find("ShipTargetPanel").transform;
        shipTargetShieldsTxt      = shipTargetPanel.FindChild("ShieldsTxt").GetComponent <Text>();
        shipTargetArmorTxt        = shipTargetPanel.FindChild("ArmorTxt").GetComponent <Text>();
        shipTargetHullTxt         = shipTargetPanel.FindChild("HullTxt").GetComponent <Text>();
        shipTargetDamageOutputTxt = shipTargetPanel.FindChild("DamageOutputTxt").GetComponent <Text>();
        shipTargetPanel.gameObject.SetActive(false);

        systemSummaryTxt = GameObject.Find("TopPanel/SystemSummaryTxt").GetComponent <Text>();
        shipSummaryTxt   = GameObject.Find("TopPanel/ShipSummaryTxt").GetComponent <Text>();

        shipSummaryTxt.text = string.Format("[ Ship Summary | Fuel: {0} — Ordnance: {1} — Food: {2} — Repair Equipment: {3} ]", ship.fuel, ship.ordnance, ship.food, ship.repairEquipment);
        systemSummaryStr    = string.Format("[ Explored | Planets: {0}/{1} ]", player.nPlanetsExplored, planetarySystem.nPlanets);

        gameOverPanel    = GameObject.Find("GameOverPanel").transform;
        gameOverTitleTxt = gameOverPanel.FindChild("GameOverTitleTxt").GetComponent <Text>();
        gameOverDescrTxt = gameOverPanel.FindChild("GameOverDescrTxt").GetComponent <Text>();
        gameOverPanel.gameObject.SetActive(false);

        escapeMenuPanel = GameObject.Find("EscapeMenuPanel").transform;
        escapeMenuPanel.gameObject.SetActive(false);

        plotPanel = GameObject.Find("PlotPanel").transform;
        plotPanel.gameObject.SetActive(true);
        Time.timeScale = 0.0f;
    }
Esempio n. 28
0
    void ShowPlanetarySystem()
    {
        if (!systemCreated && !exhausted) {
            gameObject.GetComponent<SpriteRenderer>().enabled = false;

            planetarySystemParams = PlanetarySystem.create();

            var cam = Camera.main;
            planetarySystem = (Transform)Instantiate(planetarySystemPrefab);

            planetarySystem.position = (cam.transform.rotation * planetarySystem.localPosition)
                + cam.transform.position
                + cam.transform.forward * 10f;

            planetarySystem.rotation = cam.transform.rotation;

            var sun = planetarySystem.GetComponentInChildren<Sun>();
            sun.uv = planetarySystemParams.sunUV;
            sun.ir = planetarySystemParams.sunIR;
            sun.gamma = planetarySystemParams.sunGamma;
            sun.lifeTime = planetarySystemParams.sunSecondsLeft;
            sun.energyLeft = planetarySystemParams.sunEnergyLeft;
            planetarySystem.GetComponentInChildren<Planet>().Init(planetarySystemParams.creatureCounts);

            FindObjectOfType<Galaxy>().SetCurrentStar(this);
        }
    }
Esempio n. 29
0
        static PlanetarySystem GetOtherSystem()
        {
            PlanetarySystem otherSystem = new PlanetarySystem("Other system");

            Models.Bodies.Star sun = new Models.Bodies.Star(
                center: new Point(0, 0, 0),
                mass: 2 * Math.Pow(10, 34),
                radius: 5,
                velocity: new Vector(0, 0, 0),
                name: "not the sun");
            otherSystem.SetStar(sun);

            Planet aiur = new Planet(
                center: new Point(0, 0, 0),
                mass: 6.772 * Math.Pow(10, 16),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "Aiur");

            otherSystem.AddPlanetByOrbitalRadius(aiur, 75 * Math.Pow(10, 9), 0);

            Moon someAuirMoon = new Moon(
                center: new Point(0, 0, 0),
                mass: 8.123 * Math.Pow(10, 16),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "Some Aiur moon");

            otherSystem.AddMoonByOrbitalSpeed(someAuirMoon, aiur, 220, 0);

            Planet notAiur = new Planet(
                center: new Point(0, 0, 0),
                mass: 4.772 * Math.Pow(10, 20),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "NotAiur");

            otherSystem.AddPlanetByOrbitalRadius(notAiur, 15 * Math.Pow(10, 9), 0);

            //Moon floatingBrick = new Moon(
            //    center: new Point(0, 0, 0),
            //    mass: 2121.123 * Math.Pow(10, 16),
            //    radius: 5,
            //    velocity: new Vector(new Point(0, 0, 0)),
            //    name: "FoatingBrick");
            //otherSystem.AddMoonByOrbitalSpeed(floatingBrick, notAiur, 1520);

            Moon aDamnSubmarine = new Moon(
                center: new Point(0, 0, 0),
                mass: 1.123 * Math.Pow(10, 13),
                radius: 5,
                velocity: new Vector(new Point(0, 0, 0)),
                name: "a damn submarine");

            otherSystem.AddMoonByOrbitalSpeed(aDamnSubmarine, notAiur, 999, 0);

            Asteroid someOtherAsteroid = new Asteroid(
                center: new Point(-250 * Math.Pow(10, 17), -874560, 565784),
                mass: 7987,
                radius: 5,
                velocity: new Vector(new Point(754, 245, -3)),
                name: "someOtherAsteroid");

            otherSystem.AddAsteroid(someOtherAsteroid);

            ArtificialObject somethingElse = new ArtificialObject(
                center: new Point(1334124, -54656, 9654187654),
                mass: 2000,
                radius: 5,
                velocity: new Vector(new Point(-450, 15, -9987)),
                name: "somethingElse");

            otherSystem.AddArtificialObject(somethingElse);

            return(otherSystem);
        }
Esempio n. 30
0
 public SystemView(PlanetarySystem sys)
 {
     this.sys    = sys;
     this.camera = new Camera(sys.Max(b => Vector3.Magnitude(b.position - sys.origin)), Vector3.zero);
     SetMax();
 }
Esempio n. 31
0
    // Update is called once per frame
    void CreatePlanet(int _seed)
    {
        // Create planet system
        GameObject      planet_system = (GameObject)Instantiate(Resources.Load("PlanetSystem"));
        PlanetarySystem psc           = planet_system.GetComponent(typeof(PlanetarySystem)) as PlanetarySystem;

        // Planet
        PlanetConfig p_config = new PlanetConfig();

        // Name
        p_config.name = "p" + seed.ToString();

        // Size
        p_config.diameter = Random.Range(p_limits.diameter_min_size, p_limits.diameter_max_size);
        p_config.size     = ClassifySize(p_config.diameter);

        // Atmosphere
        p_config.temperature = Random.Range(p_limits.temperature_min, p_limits.temperature_max);
        p_config.humidity    = Random.Range(p_limits.humidity_min, p_limits.humidity_max);

        // Classification (type)
        if (p_config.size >= PlanetConfig.SizeClassification.Large)
        {
            p_config.type = PlanetConfig.PlanetType.Gas;
        }
        else
        {
            p_config.type = PlanetConfig.PlanetType.Solid;
        }

        // Population (if planet solid)
        if (p_config.type == PlanetConfig.PlanetType.Solid)
        {
            p_config.has_civ = true;

            if (p_config.has_civ == true)
            {
                p_config.density = Random.Range(0.01f, p_limits.max_density);

                int max_pop = (int)((p_config.density * 1000) * 1.0 + (float)p_config.size) * 10000;
                int min_pop = (int)((p_config.density * 100) * 1.0 + (float)p_config.size) * 1000;

                p_config.population = Random.Range(min_pop, max_pop);
            }
            else
            {
                p_config.density    = 0.0f;
                p_config.population = 0;
            }
        }
        else
        {
            p_config.has_civ    = false;
            p_config.density    = 0.0f;
            p_config.population = 0;
        }

        if (p_config.type == PlanetConfig.PlanetType.Solid)
        {
            // Clouds
            p_config.has_clouds      = true;
            p_config.cloud_elevation = (4 - (float)p_config.size) / 5;
            p_config.cloud_coverage  = Random.Range(0, 1.0f);
        }
        else
        {
            p_config.has_clouds = false;
        }

        // Set Meteorites
        SetResources(ref p_config);

        // Set Meteorites
        SetMeteorites(ref p_config);

        // Set nightlights color
        p_config.nightlights_col = new Color(0.8f, 0.6f, 0.1f);

        // Initiate planet
        psc.Initiate(_seed, p_config);

        // Update stats in GUI
        StatManager s_manager = GameObject.Find("UiUpdater").GetComponent(typeof(StatManager)) as StatManager;

        s_manager.SetStats(p_config);
    }
Esempio n. 32
0
 public Planemo(string name, PlanetarySystem planetarySystem)
     : base(name)
 {
     PlanetarySystem = planetarySystem;
     planetarySystem.Planets.Add(this);
 }
Esempio n. 33
0
 private void Restore()
 {
     currentPlanetarySystem = backupPlanetarySystem.Clone();
 }