Inheritance: MonoBehaviour
        /// <inheritdoc />
        protected override void FrameAction()
        {
            if (!GameProcess.IsValid)
            {
                return;
            }

            FpsCounter.Update();

            System.Windows.Application.Current.Dispatcher.Invoke(() =>
            {
                // set render state
                Device.RenderState.AlphaBlendEnable = true;
                Device.RenderState.AlphaTestEnable  = false;
                Device.RenderState.SourceBlend      = Blend.SourceAlpha;
                Device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
                Device.RenderState.Lighting         = false;
                Device.RenderState.CullMode         = Cull.None;
                Device.RenderState.ZBufferEnable    = true;
                Device.RenderState.ZBufferFunction  = Compare.Always;

                // clear scene
                Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.FromArgb(0, 0, 0, 0), 1, 0);

                // render scene
                Device.BeginScene();
                Render();
                Device.EndScene();

                // flush to screen
                Device.Present();
            }, DispatcherPriority.Normal);
        }
        protected override void Initialize()
        {
            base.Initialize();

            FpsCounter.Enable(this);
            var message = new DebugMessageBuilder(Corner.TopRight, Color.Black);

            Add(message);

            Add(new GridAxis(RenderContext, true));

            _camera = new FirstPersonCamera(RenderContext.GraphicsDevice, Vector3.Zero, FirstPersonCamera.FirstPersonMode.Person);

            var player = new Player(_camera);

            GenerateMaze(player);
            Add(player);

            var chunkManager = GetComponents <ChunkManager>().First();
            // for first maze, place player at the starting cell

            const int playerHeight = 2;
            // position the player in the center of the starting cell
            var start  = chunkManager.GetStartCell().GetBoundingBox();
            var center = (start.Min + start.Max) / 2f;
            var s      = new Vector3(center.X, playerHeight, center.Z);

            _camera.SetPosition(s);

            UpdateDetails();
        }
Beispiel #3
0
        protected override void Initialize()
        {
            //Initialize FPS counter
            fpsCounter = new FpsCounter();

            base.Initialize();
        }
        /// <summary>
        /// Core framework constructor.
        /// </summary>
        public FrameworkCore() : base()
        {
            game = this;

            graphicsDeviceManager = new GraphicsDeviceManager(this);
            viewer           = new Viewer(this);
            inputManager     = new InputComponentManager();
            fontManager      = new FontManager();
            screenManager    = new GameScreenManager(this);
            textManager      = new TextManager(this);
            resourceManager  = new ResourceManager(this, "Content");
            particleManager  = new ParticleManager();
            collisionContext = new CollisionContext();
            soundManager     = new SoundManager();
            gameEventManager = new GameEventManager();
            fpsCounter       = new FpsCounter();

            //  Entry GameScreenManager
            AddComponent(screenManager);

            // Disable vertical retrace to get highest framerates possible for
            // testing performance.
            //graphicsDeviceManager.SynchronizeWithVerticalRetrace = false;

            // Update as fast as possible, do not use fixed time steps
            IsFixedTimeStep = false;
        }
Beispiel #5
0
        public override void Render()
        {
            if (!IsInitialized || !Visible)
            {
                return;
            }
            RenderContext.SetRenderScreen(ScreenContext);
            ScreenContext.MoveCameraByCameraMotionProvider();
            RenderContext.Timer.TickUpdater();
            FpsCounter.CountFrame();
            ClearViews();
            ScreenContext.WorldSpace.DrawAllResources(ScreenContext.HitChekcer);

#if VSG_DEBUG
#else
            SpriteBatch.Begin();
            if (DrawSpriteHandler != null)
            {
                DrawSpriteHandler(SpriteBatch);
            }
            SpriteBatch.End();
#endif

            ScreenContext.SwapChain.Present(0, PresentFlags.None);
        }
Beispiel #6
0
        /// <summary>
        ///     レンダリング
        /// </summary>
        public virtual void Render()
        {
            if (!_初期化済み || !Visible)
            {
                return;
            }

            RenderContext.Instance.描画対象にする(ScreenContext);

            ScreenContext.RenderContextにマウス監視を登録する();

            // 進行

            ScreenContext.カメラを移動する();

            // 一定時間が経過していれば、すべてのワールド座標の進行を行う。(経過していないなら何もしない。)
            RenderContext.Instance.Timer.一定時間が経過していればActionを行う(() => {
                RenderContext.Instance.ワールド座標をすべて更新する(ScreenContext);
            });

            FpsCounter.フレームを進める();

            // 描画

            画面をクリアする();

            ScreenContext.ワールド空間.登録されているすべての描画の必要があるものを描画する();

            ScreenContext.SwapChain.Present(0, PresentFlags.None);      // Present

            OnPresented();
        }
    void Update()
    {
        UpdateUI();

        if (connectionWindow.Visibility)
        {
            if (Input.GetKeyDown(KeyCode.Return))
            {
                if (connectionWindow.ConnectionTarget == ConnectionTarget.Controller)
                {
                    string ipAddressText = connectionWindow.IpAddress;
                    if (ipAddressText.Length == 0)
                    {
                        ipAddressText = "127.0.0.1";
                    }

                    TryConnectToController(ipAddressText, ControllerMessages.PORT);
                }
                else
                {
                    string ipAddressText = connectionWindow.IpAddress;
                    if (ipAddressText.Length == 0)
                    {
                        ipAddressText = "127.0.0.1";
                    }


                    if (!IPAddress.TryParse(ipAddressText, out IPAddress ipAddress))
                    {
                        TextToaster.Toast($"Failed to parse {ipAddress} as an IP address.");
                    }

                    StartCoroutine(TryConnectToKinectSender(new IPEndPoint(ipAddress, SENDER_DEFAULT_PORT)));
                }
            }
        }

        // Sets the anchor's position and rotation using the current position of the HoloLens device.
        if (Input.GetKeyDown(KeyCode.Space))
        {
            sharedSpaceScene.SetPositionAndRotation(mainCameraTransform.position, mainCameraTransform.rotation);
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            sharedSpaceScene.GizmoVisibility = !sharedSpaceScene.GizmoVisibility;
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            FpsCounter.Toast();
        }

        if (controllerClientSocket != null)
        {
            UpdateControllerClient();
        }

        UpdateReceivers();
    }
Beispiel #8
0
        void mainLoop()
        {
            FpsCounter fpsCounter   = new FpsCounter("mainLoop");
            FpsCounter fpsDrawFrame = new FpsCounter("drawFrame", reportCounters: FpsReportCounters.SimpleFrameTime);
            FpsControl fpsControl   = new FpsControl();

            GLFW.EventLoop(window, () =>
            {
                fpsCounter.Begin();

                GLFW.glfwPollEvents();

                fpsDrawFrame.Begin();
                drawFrame();
                fpsDrawFrame.End();

                fpsCounter.End();

                fpsCounter.DebugPeriodicReport();
                fpsDrawFrame.DebugPeriodicReport();

                fpsControl.Update();
            });

            Vulkan.vkDeviceWaitIdle(device);
        }
Beispiel #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        protected Application(string name, string rootContentDirectory, string version)
        {
            // associates the static application instance to the current one
            Instance = this;

            _name    = name;
            _version = version;

#if WINDOWS
            Window.Title = _name;
#endif

            Content.RootDirectory = rootContentDirectory;

            _graphics = new GraphicsDeviceManager(this);

            _inputManager        = new InputManager();
            _magicContentManager = new MagicContentManager(GameAssemblies, Content);
            _gameStateManager    = new GameStateManager();
            _scriptManager       = new ScriptManager();
            _physicsManager      = new PhysicsManager();

            _fpsCounter    = new FpsCounter();
            _randomMachine = new RandomMachine(DateTime.Now.Millisecond);

            //Xbox Live
#if XBOX
            this.Components.Add(new GamerServicesComponent(this));
#endif
        }
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_DebuggerManager = GameFrameworkEntry.GetModule <IDebuggerManager>();
            if (m_DebuggerManager == null)
            {
                Log.Fatal("Debugger manager is invalid.");
                return;
            }

            switch (m_ActiveWindow)
            {
            case DebuggerActiveWindowType.AlwaysOpen:
                ActiveWindow = true;
                break;

            case DebuggerActiveWindowType.OnlyOpenWhenDevelopment:
                ActiveWindow = Debug.isDebugBuild;
                break;

            case DebuggerActiveWindowType.OnlyOpenInEditor:
                ActiveWindow = Application.isEditor;
                break;

            default:
                ActiveWindow = false;
                break;
            }

            m_FpsCounter = new FpsCounter(0.5f);
        }
Beispiel #11
0
        private void WorkerThread()
        {
            _waitContinue.Reset();
            FpsCounter.Start();
            _waitContinue.Set();
            _continue.Wait();
            _waitContinue.Reset();

            do
            {
                if (FpsCounter.ShouldRender)
                {
                    FpsCounter.CountFrame();
                    foreach (var r in _renderables)
                    {
                        r.Render();
                    }
                }
                else
                {
                    Thread.Sleep(1);
                }

                _waitContinue.Set();
                _continue.Wait();
                _waitContinue.Reset();
            } while (_run);
        }
Beispiel #12
0
        protected override void Initialize()
        {
            LogHelper.Log("Game Root: Initialize..");

            _fpsCounter = new FpsCounter(this);

            Components.Add(_fpsCounter);

            _graphCanvas = new GraphCanvas(this)
            {
                Position = new Vector2(660, 256),
                Size     = new Size2(600, 100)
            };
            Components.Add(_graphCanvas);

            _fpsCounter.OnFpsUpdate += (sender, args) =>
            {
                FpsCounter fpsCounter = (FpsCounter)sender;
                _graphCanvas.PushValue(fpsCounter.FramesPerSecond);
            };

            base.Initialize();

            LogHelper.Log("Game Root: End Initialize..");
        }
        /// <summary>
        /// Initialize all manangers and informations.
        /// </summary>
        protected override void Initialize()
        {
            //  Creates debug font
            debugFont = FontManager.CreateFont("DebugFont", "Font/SmallArial");

            //  Initialize input manager
            InputManager.Initialize();

            //  Initialize viewer
            Viewer.Initialize();

            //  Initialize text manager
            TextManager.Initialize();

            //  Initialize FPS counter
            FpsCounter.Initialize();

            //  Add FPS info
            Vector2 pos = new Vector2(0, 0);

            pos = ClampSafeArea(pos);

            textFPS = TextManager.AddText(debugFont,
                                          string.Format("FPS : {0}", FrameworkCore.FpsCounter.Fps.ToString()),
                                          (int)pos.X, (int)pos.Y, Color.White);
#if DEBUG
            textFPS.Visible = true;
#else
            textFPS.Visible = false;
#endif

            base.Initialize();

            System.Diagnostics.Debug.WriteLine("Framework Initialize OK...");
        }
Beispiel #14
0
        /// <summary>
        /// 游戏框架组件初始化。
        /// </summary>
        private void Awake()
        {
            if (_instance == null)
            {
                _instance = this;
            }

            if (_instance != null && _instance != this)
            {
                Destroy(this.gameObject);
                return;
            }

            m_DebuggerManager = new DebuggerManager();

            if (m_ActiveWindow == DebuggerActiveWindowType.Auto)
            {
                ActiveWindow = Debug.isDebugBuild;
            }
            else
            {
                ActiveWindow = (m_ActiveWindow == DebuggerActiveWindowType.Open);
            }

            m_FpsCounter = new FpsCounter(0.5f);
        }
Beispiel #15
0
    public MyGame() : base(SCREEN_WIDTH, SCREEN_HEIGHT, Settings.FullScreen) // Create a window that's 800x600 and NOT fullscreen
    {
        SCREEN_WIDTH  = game.width;
        SCREEN_HEIGHT = game.height;

        HALF_SCREEN_WIDTH  = SCREEN_WIDTH / 2;
        HALF_SCREEN_HEIGHT = SCREEN_HEIGHT / 2;

        ShowMouse(true);

        string[] tmxFiles = TmxFilesLoader.GetTmxFileNames("Level*.tmx");
        var      mapData  = TiledMapParserExtended.MapParser.ReadMap(tmxFiles[0]);

        _caveLevelMap = new CaveLevelMapGameObject(mapData);

        _cam       = new FollowCamera(0, 0, game.width, game.height);
        _cam.scale = Settings.Camera_Scale;
        Cam        = _cam;

        var gameSoundManager = new GameSoundManager(mapData);

        AddChild(gameSoundManager);

        var startScreen = new PreGameStartScreen(Settings.StartScreen_Bg_Image, Settings.StartScreen_Music, () =>
        {
            var inGameStartScreen1 =
                new PreGameStartScreen(Settings.In_Game_StartScreen_1_Bg_Image, Settings.In_Game_StartScreen_1_Music,
                                       () =>
            {
                var inGameStartScreen2 =
                    new PreGameStartScreen(Settings.In_Game_StartScreen_2_Bg_Image, Settings.In_Game_StartScreen_2_Music,
                                           () =>
                {
                    var inGameStartScreen3 =
                        new PreGameStartScreen(Settings.In_Game_StartScreen_3_Bg_Image, null,
                                               () =>
                    {
                        GameSoundManager.Instance.FadeOutCurrentMusic();
                        CoroutineManager.StartCoroutine(LoadLevelWithDelay(), this);
                    });
                    AddChild(inGameStartScreen3);
                });
                AddChild(inGameStartScreen2);
            });
            AddChild(inGameStartScreen1);
        });

        AddChild(startScreen);

        //Debug
        _fpsCounter = new FpsCounter();
        AddChild(_fpsCounter);

        _debugText = new DebugTextBox("Hello World", width, 100);
        _cam.AddChild(_debugText);
        _debugText.x = -SCREEN_WIDTH / 2;
        _debugText.y = -SCREEN_HEIGHT / 2;
        _debugText.SetActive(false);
    }
Beispiel #16
0
        public Window(string Title, int Width, int Height) : base(Title, Width, Height)
        {
            presenter = new Present(Handle, true);

            IsVisible = true;

            Micos.Add(fpsCounter = new FpsCounter());
        }
Beispiel #17
0
 public testgame()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     IsMouseVisible        = true;
     fps = new FpsCounter(this);
     Components.Add(fps);
 }
Beispiel #18
0
        internal void Initialise()
        {
            RemoveAndDispose(ref _d2dFactory);
            RemoveAndDispose(ref _dwFactory);

            _d2dFactory = ToDispose(new SharpDX.Direct2D1.Factory1(FactoryType.SingleThreaded));
            _dwFactory  = ToDispose(new SharpDX.DirectWrite.Factory(SharpDX.DirectWrite.FactoryType.Shared));

            RemoveAndDispose(ref _d3dDevice);
            RemoveAndDispose(ref _d3dContext);
            RemoveAndDispose(ref _d2dDevice);
            RemoveAndDispose(ref _d2dContext);


            //var desc = CreateSwapChainDescription();

            using (var device = new Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport)) // | DeviceCreationFlags.Debug,
            {
                _d3dDevice = ToDispose(device.QueryInterface <SharpDX.Direct3D11.Device1>());
            }

            _d3dContext = ToDispose(_d3dDevice.ImmediateContext.QueryInterface <SharpDX.Direct3D11.DeviceContext1>());



            using (var dxgiDevice = _d3dDevice.QueryInterface <SharpDX.DXGI.Device>())
            {
                _d2dDevice = ToDispose(new SharpDX.Direct2D1.Device(_d2dFactory, dxgiDevice));
            }
            _d2dContext = ToDispose(new DeviceContext(_d2dDevice, DeviceContextOptions.None));

            /*
             * D2Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, new [] { FeatureLevel.Level_10_0 }, desc, out _device, out _swapChain);
             *
             * ToDispose(_device);
             * ToDispose(_swapChain);
             *
             * var d2dFactory = ToDispose(new SharpDX.Direct2D1.Factory());
             *
             * Factory factory = ToDispose(_swapChain.GetParent<Factory>());
             * factory.MakeWindowAssociation(_outputHandle, WindowAssociationFlags.IgnoreAll);
             *
             * _backBuffer = ToDispose(Texture2D.FromSwapChain<Texture2D>(_swapChain, 0));
             * _renderTargetView = ToDispose(new RenderTargetView(_device, _backBuffer));
             * _surface = ToDispose(_backBuffer.QueryInterface<Surface>());
             *
             * _target = ToDispose(new RenderTarget(d2dFactory, _surface, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied))));
             */

            InitialiseResources();

            RemoveAndDispose(ref _fpsCounter);

            _fpsCounter = new FpsCounter();
            _fpsCounter.InitialiseGraphics(this);

            OnInitialize?.Invoke(this);
        }
Beispiel #19
0
 public MonitoringHeader(Game game, Renderer renderer) : base(game, renderer, 0, false, true)
 {
     _cpuUsageCounter = new CpuUsageCounter();
     _fpsCounter      = new FpsCounter();
     _text            = renderer.TextManager.Create("Courrier", 14, 80, new Vector4(1, 1, 1, 0.5f));
     _text.Position   = new Vector2I(3, 0);
     _videoCardInfo   = renderer.DirectX.VideoCardName + " (" + renderer.DirectX.VideoCardMemorySize + " MB)";
     _overlay         = new Rectangle(renderer, renderer.ScreenSize, new Vector2I(0, 0), new Vector2I(485, 16), new Vector4(1, 0, 0, 0.2f));
 }
Beispiel #20
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.LogError("There should be only one FpsCounter.");
        }

        instance = this;
    }
        /// <summary>
        /// Update fps counter
        /// </summary>
        private void UpdateFps()
        {
            int?fps = FpsCounter.Update();

            if (fps != null)
            {
                OutputFacade.UpdateFps(fps.Value);
            }
        }
Beispiel #22
0
 public Bridge(Engine.Engine engine, FpsCounter fpsCounter)
 {
     State = new State
     {
         Projection = engine.GraphicsSettings.Projection,
         Fps        = fpsCounter.Fps,
         ClearColor = engine.GraphicsSettings.ClearColor
     };
 }
        public Time()
        {
            QueryPerformanceFrequency(out POLL_INTERVAL);
            POLL_MULTIPLIER = 1d / POLL_INTERVAL;

            _fps = new FpsCounter(POLL_INTERVAL);

            Restart();
        }
Beispiel #24
0
 public SphericalWorldScreen(IContext context) : base(context, "spherical_world")
 {
     _sphere  = new Sphere(Context, 255, 5000);
     _sky     = new Sky(Context);
     _sun     = new Sun();
     _camera  = new SphericalWorldCamera();
     _counter = new FpsCounter();
     Register(new DynamicLabel(context, "fps_counter", new UniRectangle(5, 5, 100, 50),
                               () => _counter.Value + "FPS"));
 }
        /// <summary />
        public Graphics(WindowOverlay windowOverlay, GameProcess gameProcess, GameData gameData)
        {
            WindowOverlay = windowOverlay;
            GameProcess   = gameProcess;
            GameData      = gameData;
            FpsCounter    = new FpsCounter();

            InitDevice();
            FontVerdana8 = new Microsoft.DirectX.Direct3D.Font(Device, new System.Drawing.Font("Verdana", 8.0f, FontStyle.Regular));
        }
 public MonitoringHeader(Game game, Renderer renderer)
     : base(game, renderer, 0, false, true)
 {
     _cpuUsageCounter = new CpuUsageCounter();
     _fpsCounter = new FpsCounter();
     _text = renderer.TextManager.Create("Courrier", 14, 80, new Vector4(1,1,1,0.5f));
     _text.Position = new Vector2I(3,0);
     _videoCardInfo = renderer.DirectX.VideoCardName + " ("+renderer.DirectX.VideoCardMemorySize+" MB)";
     _overlay = new Rectangle(renderer, renderer.ScreenSize, new Vector2I(0,0), new Vector2I(485,16), new Vector4(1,0,0,0.2f));
 }
 public override void DrawUI()
 {
     if (!Loaded)
     {
         return;
     }
     FpsCounter.Draw();
     UIRect.Position = new Vector2(350, 200);
     UIRect.Draw();
     base.DrawUI();
 }
Beispiel #28
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Game1.DefaultSpriteBatch = spriteBatch;

            // FPS Counter
            fps = new FpsCounter();

            // TODO: use this.Content to load your game content here
        }
Beispiel #29
0
 private void UnPause()
 {
     if (_kft.IsRunning)
     {
         return;
     }
     _fpsCounter = new FpsCounter();
     _kft.Start();
     statusLabel.Text = "";
     _programState    = ProgramState.Running;
     startStopToolStripMenuItem.Text = "Start (Space)";
 }
Beispiel #30
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
#if DEBUG
            var debugFont = Content.Load <SpriteFont>("Fonts/debugFont");

            var fpsCounter = new FpsCounter(this, debugFont, new Vector2(5, 5));
            Components.Add(fpsCounter);
#endif
            SceneManager.LoadContent();
        }
Beispiel #31
0
 internal virtual void OnUpdate(GameTime gameTime)
 {
     watch2.Stop();
     FpsCounter.BetweenTime = watch2.Elapsed;
     watch3.Restart();
     Scenes.Update(gameTime);
     this.Update(gameTime);
     this.UpdateEvent(gameTime);
     FpsCounter.Update(gameTime);
     watch3.Stop();
     FpsCounter.UpdateTime = watch3.Elapsed;
 }
Beispiel #32
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Beispiel #33
0
 public msgame()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     IsMouseVisible = true;
     fps = new FpsCounter(this);
     mainMenu = new gameScreens.MainMenu(this);
     optionMenu = new gameScreens.OptionsMenu(this);
     highscoreMenu = new gameScreens.HighscoreMenu(this);
     Components.Add(mainMenu);
     Components.Add(optionMenu);
     Components.Add(highscoreMenu);
     Components.Add(fps);
 }
Beispiel #34
0
        // Use this for initialization
        public override void Start()
        {
            // Initialize
            InitAll();
            Logger.debug = true;

            // Set up input listeners
            Inputs.SetKeyListeners(_keyListeners);

            // Beats logo
            TestLogo.Init();
            TestLogo logo = TestLogo.Instantiate();
            logo.position = new Vector3(Screens.xmid, Screens.ymid, Screens.zmin);

            // Arrow in each corner
            TestArrow.Init();
            for (int x = 0; x < 3; x++) {
                for (int y = 0; y < 3; y++) {
                    float posX = (x == 0) ? Screens.xmin : (x == 1) ? Screens.xmid : Screens.xmax;
                    float posY = (y == 0) ? Screens.ymin : (y == 1) ? Screens.ymid : Screens.ymax;
                    float posZ = Screens.zmin;
                    TestArrow arrow = TestArrow.Instantiate();
                    arrow.name = String.Format("_arrow({0}, {1})", x, y);
                    arrow.position = new Vector3(posX, posY, posZ);
                }
            }
            _randomArrow = TestArrow.Instantiate();
            _randomArrow.name = "_randomArrow";
            _randomArrow.position = new Vector3(Screens.xmax - 75f, Screens.ymax - 50f, Screens.zmin);

            // Two random holds
            TestHold.Init();
            _hold1 = TestHold.Instantiate(Screens.height - _randomArrow.height);
            _hold1.name = "_hold1";
            _hold1.position = new Vector3(Screens.xmax - (_hold1.width / 2), Screens.ymid, Screens.zmid);

            _hold2 = TestHold.Instantiate(_randomArrow.height * 4);
            _hold2.name = "_hold2";
            _hold2.position = new Vector3(_hold1.x - _hold1.width * 2, Screens.ymid, Screens.zmid);

            // Background image
            TestBackground background = TestBackground.Instantiate();
            background.name = "_background2";
            background.position = new Vector3(Screens.xmid, Screens.ymid, Screens.zmax);
            background.color = new Color(background.color.r, background.color.g, background.color.b, 0.75f);

            // Generated arrows
            _arrows = new List<TestArrow>();
            _addTimer = ADD_INTERVAL;
            _arrowCount = 0;

            // Text label
            FontMeshData squareTextData = new FontMeshData(
                "_SquareFont",
                SysInfo.GetPath("Sandbox/Square.png"),
                SysInfo.GetPath("Sandbox/Square.fnt")
                );
            float textWidth = squareTextData.width * (_randomArrow.height / 2) / squareTextData.height;
            float textHeight = (_randomArrow.height / 2);

            _sysInfo = TestText.Instantiate(
                squareTextData,
                "_SysInfo",
                textWidth * 0.7f, textHeight * 0.7f,
                TextAnchor.UpperLeft
                );
            _sysInfo.position = new Vector3(Screens.xmin, Screens.ymax, Screens.zdebug);
            _sysInfo.color = new Color(1f, 1f, 1f, 0.5f); // Semi-transparent Gray
            _sysInfo.text = SysInfo.InfoString();

            _audioTime = TestText.Instantiate(
                squareTextData,
                "_AudioTime",
                textWidth, textHeight,
                TextAnchor.LowerLeft
                );
            _audioTime.position = new Vector3(Screens.xmin, Screens.ymin + (_randomArrow.height / 2), Screens.zdebug);

            _touchLog = TestText.Instantiate(
                squareTextData,
                "_Touch Log",
                textWidth, textHeight,
                TextAnchor.LowerLeft
                );
            _touchLog.position = new Vector3(Screens.xmin, Screens.ymin, Screens.zdebug);
            _touchLog.color = new Color(255f / 255f, 204f/255f, 0f); // Tangerine

            _collisionLog = TestText.Instantiate(
                squareTextData,
                "_Collision Log",
                textWidth, textHeight,
                TextAnchor.LowerRight
                );
            _collisionLog.position = new Vector3(Screens.xmax, Screens.ymin, Screens.zdebug);
            _collisionLog.color = Color.red;

            // FPS Counter
            _fpsCounter = FpsCounter.Instantiate(squareTextData,textHeight);
            _fpsCounter.position = new Vector3(Screens.xmax, Screens.ymax, Screens.zdebug);

            // Load music
            _audioPlayer = AudioPlayer.Instantiate();
            _audioPlayer.Set(AudioClips.SANDBOX_SONG);
            _audioPlayer.loop = true;
            _audioPlayer.Play();

            TestMine.Init();
            _mine = TestMine.Instantiate();
            _mine.gameObject.transform.position = new Vector3(Screens.xmid, (Screens.ymin + Screens.ymid) / 2, Screens.zmin - 10);

            SettingsFile testIniFile = new SettingsFile(SysInfo.GetPath("Sandbox/Test.ini"));
            testIniFile.Set("Beats", "Version", "MODIFIED");
            testIniFile.Write(SysInfo.GetPath("Sandbox/Test2.ini"));
        }
Beispiel #35
0
        public void Initalize()
        {
            FPSCounter = new FpsCounter();

            spriteBatch = new SpriteBatch(MyGame.DeviceManager.GraphicsDevice);

            //аниматор
            animationManager = AnimationManager.AnimationManager.Manager;

            //шойдер
               /* using (var stream = new FileStream(@"Content\Shaders\ObjectRender.fx", FileMode.Open))
            {
                PhysX_test2.Engine.Render.Materials.Material.ObjectRenderEffect = Shader.FromStream(stream, MyGame.Device);
            }
            */
            PhysX_test2.Engine.Render.Materials.Material.ObjectRenderEffect = Shader.Load(MyGame.Instance.Content);

            //камера
            CameraManager.Init();

            //рендерщик
            GraphicPipeleine = new RenderPipeline(MyGame.DeviceManager.GraphicsDevice, CameraManager.Camera);
        }
Beispiel #36
0
    public static void InitializeWithGame(Game g)
    {
        // Initialize debug manager and add it to components.
        _debugManager = new DebugManager(g);
        g.Components.Add(_debugManager);

        // Initialize debug command UI and add it to compoents.
        _debugCommandUI = new DebugCommandUI(g);

        // Change DrawOrder for render debug command UI on top of other compoents.
        _debugCommandUI.DrawOrder = int.MaxValue;

        g.Components.Add(_debugCommandUI);

        // Initialize FPS counter and add it to compoentns.
        _fpsCounter = new FpsCounter(g);
        g.Components.Add(_fpsCounter);

        // Initialize TimeRuler and add it to compoentns.
        _currentRuler = new TimeRuler(g);
        g.Components.Add(_currentRuler);
    }