Beispiel #1
0
        public void StarFactory_Create_With_No_Name_Throws()
        {
            var sf = new StarFactory(MinAge, MaxAge);

            sf.Create("");
        }
Beispiel #2
0
 public NodeController(StarFactory starFactory) => _starFactory = starFactory;
Beispiel #3
0
        private static void Main(String[] args)
        {
            //Environment.SetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1");

            XTrace.UseConsole();

            var star = new StarFactory(null, null, null);

            DefaultTracer.Instance = star?.Tracer;
            //(star.Tracer as StarTracer).AttachGlobal();

#if DEBUG
            XTrace.Debug     = true;
            XTrace.Log.Level = LogLevel.All;

            var set = NewLife.Setting.Current;
            set.Debug    = true;
            set.LogLevel = LogLevel.All;

            //new LogEventListener(new[] {
            //    "System.Runtime",
            //    "System.Diagnostics.Eventing.FrameworkEventSource",
            //    "System.Transactions.TransactionsEventSource",
            //    "Microsoft-Windows-DotNETRuntime",
            //    //"Private.InternalDiagnostics.System.Net.Sockets",
            //    "System.Net.NameResolution",
            //    //"Private.InternalDiagnostics.System.Net.NameResolution",
            //    "System.Net.Sockets",
            //    //"Private.InternalDiagnostics.System.Net.Http",
            //    "System.Net.Http",
            //    //"System.Data.DataCommonEventSource",
            //    //"Microsoft-Diagnostics-DiagnosticSource",
            //});

            var set2 = XCode.Setting.Current;
            set2.Debug = true;
#endif
            while (true)
            {
                var sw = Stopwatch.StartNew();
#if !DEBUG
                try
                {
#endif
                Test35();
#if !DEBUG
            }
            catch (Exception ex)
            {
                XTrace.WriteException(ex?.GetTrue());
            }
#endif

                sw.Stop();
                Console.WriteLine("OK! 耗时 {0}", sw.Elapsed);
                //Thread.Sleep(5000);
                GC.Collect();
                GC.WaitForPendingFinalizers();
                var key = Console.ReadKey(true);
                if (key.Key != ConsoleKey.C)
                {
                    break;
                }
            }
        }
Beispiel #4
0
 public void DestroyAllObjects()
 {
     StarFactory.DestroyAll(Scene);
     BombFactory.DestroyAll(Scene);
 }
Beispiel #5
0
 public AppDeployNodeController(StarFactory starFactory) => _starFactory = starFactory;
Beispiel #6
0
 static EntityFactories()
 {
     PlanetFactory = new PlanetFactory();
     StarFactory   = new StarFactory();
 }
Beispiel #7
0
        /// <summary>
        /// Load content.
        /// </summary>
        public void LoadContent()
        {
            // Store graphics device
            this.graphicsDevice = core.GraphicsDevice;

            // Load rendering effects
            clearBufferEffect      = core.ContentManager.Load <Effect>("Effects/ClearGBuffer");
            finalCombineEffect     = core.ContentManager.Load <Effect>("Effects/CombineFinal");
            directionalLightEffect = core.ContentManager.Load <Effect>("Effects/DirectionalLight");
            pointLightEffect       = core.ContentManager.Load <Effect>("Effects/PointLight");
            emissiveLightEffect    = core.ContentManager.Load <Effect>("Effects/EmissiveLight");
            renderBillboards       = core.ContentManager.Load <Effect>("Effects/RenderBillboards");
            fxaaAntialiasing       = core.ContentManager.Load <Effect>("FXAA/fxaa");

            // Get render billboards parameters
            renderBillboards_Texture  = renderBillboards.Parameters["Texture"];
            renderBillboards_Position = renderBillboards.Parameters["Position"];
            renderBillboards_Size     = renderBillboards.Parameters["Size"];

            // Get point light parameters
            pointLight_colorMap             = pointLightEffect.Parameters["ColorMap"];
            pointLight_normalMap            = pointLightEffect.Parameters["NormalMap"];
            pointLight_depthMap             = pointLightEffect.Parameters["DepthMap"];
            pointLight_worldMatrix          = pointLightEffect.Parameters["World"];
            pointLight_viewMatrix           = pointLightEffect.Parameters["View"];
            pointLight_projectionMatrix     = pointLightEffect.Parameters["Projection"];
            pointLight_lightPosition        = pointLightEffect.Parameters["LightPosition"];
            pointLight_lightColor           = pointLightEffect.Parameters["Color"];
            pointLight_lightRadius          = pointLightEffect.Parameters["LightRadius"];
            pointLight_lightIntensity       = pointLightEffect.Parameters["LightIntensity"];
            pointLight_cameraPosition       = pointLightEffect.Parameters["CameraPosition"];
            pointLight_invertViewProjection = pointLightEffect.Parameters["InvertViewProjection"];
            pointLight_halfPixel            = pointLightEffect.Parameters["HalfPixel"];

            // Get directional light paramters
            directionalLight_colorMap             = directionalLightEffect.Parameters["ColorMap"];
            directionalLight_normalMap            = directionalLightEffect.Parameters["NormalMap"];
            directionalLight_depthMap             = directionalLightEffect.Parameters["DepthMap"];
            directionalLight_lightDirection       = directionalLightEffect.Parameters["LightDirection"];
            directionalLight_lightColor           = directionalLightEffect.Parameters["Color"];
            directionalLight_lightIntensity       = directionalLightEffect.Parameters["LightIntensity"];
            directionalLight_cameraPosition       = directionalLightEffect.Parameters["CameraPosition"];
            directionalLight_invertViewProjection = directionalLightEffect.Parameters["InvertViewProjection"];
            directionalLight_gBufferTextureSize   = directionalLightEffect.Parameters["GBufferTextureSize"];

            // Get emissive light parameters
            emissiveLight_ColorMap           = emissiveLightEffect.Parameters["colorMap"];
            emissiveLight_gBufferTextureSize = emissiveLightEffect.Parameters["GBufferTextureSize"];

            // Load light geometry
            pointLightGeometry = core.ContentManager.Load <Model>("Models/PointLightGeometry");
            spotLightGeometry  = core.ContentManager.Load <Model>("Models/SpotLightGeometry");

            // Load light textures
            spotLightCookie = core.ContentManager.Load <Texture2D>("Textures/SpotLightCookie");

            // Create billboard template
            CreateDaggerfallBillboardTemplate();

            // Create rendering classes
            fullScreenQuad = new FullScreenQuad(graphicsDevice);
            gBuffer        = new GBuffer(core);
            bloomProcessor = new BloomProcessor(core);

            // Load content
            skyDomeEffect = core.ContentManager.Load <Effect>("Effects/SkyDomeEffect");
            skyDomeModel  = core.ContentManager.Load <Model>("Models/SkyDomeModel");
            skyDomeModel.Meshes[0].MeshParts[0].Effect = skyDomeEffect.Clone();

            // Create factories
            cloudFactory = new CloudFactory(core);
            starFactory  = new StarFactory(core);

            // Wire up GraphicsDevice events
            graphicsDevice.DeviceReset += new EventHandler <EventArgs>(GraphicsDevice_DeviceReset);
            graphicsDevice.DeviceLost  += new EventHandler <EventArgs>(GraphicsDevice_DeviceLost);
        }
Beispiel #8
0
    void Update()
    {
        if (rend == null)
        {
            rend = transform.GetChild(0).GetComponent <SpriteRenderer>();
        }

        if (!UiInitDone)
        {
            InitUI();
        }

        Vector2  v  = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2d v2 = new Vector2d(v.x, v.y);

        bool currentlyHovering = false;

        for (int i = 0; i < Stars.Length; i++)
        {
            if ((Stars[i].Position - v2).sqrMagnitude <= (0.5 * 0.5))
            {
                HoveredStar        = i;
                currentlyHovering ^= true;

                TooltipNameText.text     = Stars[i].Name;
                TooltipTypeText.text     = StarFactory.ESpectralTypeToString(Stars[i].SpectralType) + StarFactory.ELuminosityTypeToString(Stars[i].LuminosityType);
                TooltipPositionText.text = Stars[i].Position.ToString();

                if (!Tooltip.gameObject.activeSelf)
                {
                    Tooltip.gameObject.SetActive(true);
                }

                if (!CursorHover.gameObject.activeSelf)
                {
                    CursorHover.gameObject.SetActive(true);
                }

                CursorHover.localPosition = new Vector2((float)Stars[HoveredStar].Position.x + 0.27f, (float)Stars[HoveredStar].Position.y + 0.25f);

                break;
            }
        }

        if (!currentlyHovering)
        {
            HoveredStar = -1;

            if (Tooltip.gameObject.activeSelf)
            {
                Tooltip.gameObject.SetActive(false);
            }

            if (CursorHover.gameObject.activeSelf)
            {
                CursorHover.gameObject.SetActive(false);
            }
        }

        if (Input.GetMouseButtonDown(0) && HoveredStar != -1)
        {
            SelectedStar                      = HoveredStar;
            TooltipMoreNameText.text          = Stars[SelectedStar].Name;
            TooltipMoreRadiusText.text        = Stars[SelectedStar].RadiusSuns.ToString();
            TooltipMoreMassText.text          = Stars[SelectedStar].MassSuns.ToString();
            TooltipMoreLuminosityText.text    = Stars[SelectedStar].LuminositySuns.ToString();
            TooltipMoreLifetimeText.text      = Stars[SelectedStar].LifetimeMyears.ToString() == "-1" ? "Infinite" : Stars[SelectedStar].LifetimeMyears.ToString();
            TooltipMoreHabitableZoneText.text = Stars[SelectedStar].HabitableZoneAU.ToString();
            TooltipMoreTemperatureText.text   = Stars[SelectedStar].TemperatureKelvin.ToString();

            if (!CursorLock.gameObject.activeSelf)
            {
                CursorLock.gameObject.SetActive(true);
            }

            CursorLock.localPosition = new Vector2((float)Stars[SelectedStar].Position.x + 0.27f, (float)Stars[SelectedStar].Position.y + 0.25f);

            if (!TooltipMore.gameObject.activeSelf)
            {
                TooltipMore.gameObject.SetActive(true);
            }
        }
        else if (Input.GetMouseButtonDown(0) && HoveredStar == -1)
        {
            if (TooltipMore.gameObject.activeSelf)
            {
                TooltipMore.gameObject.SetActive(false);
            }

            if (CursorLock.gameObject.activeSelf)
            {
                CursorLock.gameObject.SetActive(false);
            }
        }
    }