Esempio n. 1
0
        private void DoGameLoop()
        {
            if (!HasInitted)
            {
                return;
            }

            GlobalUIManager.fps.Start();
            GraphicsRenderer.DeviceContext.ClearRenderTargetView(
                GraphicsRenderer.RenderTarget, new Color4(0.0f, .4f, 0.0f));
            GraphicsRenderer.DeviceContext.ClearDepthStencilView(
                GraphicsRenderer.DepthView, DepthStencilClearFlags.Depth,
                1.0f, 0);

            if (NetworkClient.PendingReset)
            {
                HasInitted   = false;
                hasConnected = false;
                NetworkClient.PendingReset      = false;
                GraphicsRenderer.panel1.Visible = true;
                GraphicsRenderer.panel1.Show();
                GraphicsRenderer.panel1.Focus();
                return;
            }


            // Receive any packets from the server.
            ReceivePackets();
            // If there's an active player right now.
            if (ActivePlayer != null)
            {
                // Update input events.
                InputManager.Update();

                //If enough time has passed since the last packet, send.
                if (sendTimer.ElapsedMilliseconds > sendDelay)
                {
                    // Send any packets to the server.
                    SendRequest();

                    sendTimer.Restart();
                }
            }


            // Update all objects.
            Update();

            // Draw everythhing.
            Render();


            GlobalUIManager.Update();
            UIManagerSpriteRenderer.Update();
            UIManagerSpriteRenderer.SpriteRenderer.Flush();
            UIManagerSpriteRenderer.SpriteRenderer.ClearReorderBuffer();
            GraphicsRenderer.SwapChain.Present(0, PresentFlags.None);
            GlobalUIManager.fps.StopAndCalculateFps();
            AudioManager.Update();
        }
Esempio n. 2
0
        private static void Main(String[] args)
        {
            //Process.Start("..\\..\\..\\LeafMeAloneServer\\bin\\Debug\\LeafMeAloneServer.exe");

            // Initialize static classes
            GraphicsRenderer.Init();

            //catch (FormatException e)
            //{
            //    IPHostEntry ipHostInfo = Dns.GetHostEntry(args[0]);
            //    ipAddress = ipHostInfo.AddressList[0];
            //}
            // }

            // Create a new camera with a specified offset.
            Camera activeCamera =
                new Camera(CAMERA_OFFSET, Vector3.Zero, Vector3.UnitY);

            GraphicsManager.Init(activeCamera);
            AudioManager.Init();
            AudioManager.SetListenerVolume(4.0f);
            AnimationManager.Init();

            GameClient Client = new GameClient();

            GlobalUIManager.Init();
            GraphicsRenderer.connectButton.Click += (sender, eventArgs) =>
            {
                if (!Client.hasConnected)
                {
                    Client.hasConnected = true;
                    IPAddress ipAddress = IPAddress.Loopback;
                    if (GraphicsRenderer.networkedCheckbox.Checked)
                    {
                        ipAddress = IPAddress.Parse(GraphicsRenderer.ipTextbox.Text);
                        Console.WriteLine($@" ip is {ipAddress.ToString()}");
                    }

                    Client.Init(new NetworkClient(ipAddress));

                    GraphicsRenderer.panel1.Visible = false;
                    GraphicsRenderer.panel1.Hide();
                    GraphicsRenderer.Form.Focus();
                }
            };

            MessagePump.Run(GraphicsRenderer.Form, Client.DoGameLoop);

            GraphicsRenderer.Dispose();
        }
Esempio n. 3
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
    }
Esempio n. 4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
     if (particleHolder == null)
     {
         particleHolder = GameObject.Find("ParticleHolder");
     }
 }
 private void Awake()
 {
     guim = this;
     DontDestroyOnLoad(this);
 }