コード例 #1
0
ファイル: Simulation.cs プロジェクト: andatr/orbitsim
 // -------------------------------------------------------------------------------------------------------------------
 public Simulation(Assets.StarSystem starSystem, double initTime)
 {
     this.starSystem = starSystem;
     planets         = new Planet[starSystem.planets.Length];
     star            = new SpaceBody(this, starSystem.star);
     for (int i = 0; i < planets.Length; ++i)
     {
         planets[i] = Instantiator.CreatePlanet(this, starSystem.planets[i]);
     }
     SetTime(initTime);
 }
コード例 #2
0
        // -------------------------------------------------------------------------------------------------------------------
        private void CreateViews()
        {
            var bodies        = new GameObject("Bodies");
            var canvasObject  = GameObject.Find("Canvas");
            var canvas        = canvasObject.GetComponent <Canvas>();
            var iconContainer = canvasObject.transform.Find("Bodies").gameObject;
            // star view
            var starView = Instantiator.CreateSpaceBodyView(_simulation.star, bodies);

            Instantiator.CreateSpaceBodyIcon(starView, Camera.main, canvas, _cameraController, iconContainer);
            _cameraController.Target = starView.gameObject;
            // planet views
            for (int i = 0; i < starSystem.planets.Length; ++i)
            {
                var container = new GameObject(starSystem.planets[i].name);
                container.SetParent(bodies);
                var planetView = Instantiator.CreateSpaceBodyView(_simulation.planets[i], container);
                Instantiator.CreateOrbitView(_simulation.planets[i], container);
                Instantiator.CreateSpaceBodyIcon(planetView, Camera.main, canvas, _cameraController, iconContainer);
            }
        }