Exemplo n.º 1
0
        public Program()
        {
            RpcManager.Instance.TriggerRPC("announce", new ElementRpc <Player>(Player.Local));

            RpcManager.Instance.RegisterRPC <EmptyRpc>("announce-response", (rpc) =>
            {
                ChatBox.WriteLine("Hey, we responded!");
            });

            RpcManager.Instance.RegisterRPC <EmptyRpc>("queue", (rpc) =>
            {
                ChatBox.WriteLine("I was queued!");
            });

            RpcManager.Instance.RegisterAsyncRPC <SingleCastRpc <string>, EmptyRpc>("Async.RequestLocalization", (request) =>
            {
                return(new SingleCastRpc <string>(GameClient.Localization.Item1));
            });

            Task.Run(async() =>
            {
                var responseRpc = await RpcManager.Instance.TriggerAsyncRpc <SingleCastRpc <string> >("Async.RequestMapName", new EmptyRpc());
                string name     = responseRpc.Value;
                ChatBox.WriteLine($"Map name: {name}");
            });

            Dx.DrawCircle(Vector2.Zero, 4);

            var vehicle = new Vehicle(VehicleModel.Cars.Alpha, new Vector3(20, 20, 5), Vector3.Zero, "CLIENT");

            vehicle.OnStreamIn  += (o, args) => ChatBox.WriteLine("Streamed in!");
            vehicle.OnStreamOut += (o, args) => ChatBox.WriteLine("Streamed out!");
        }
Exemplo n.º 2
0
        public Program()
        {
            RpcManager.Instance.TriggerRPC("announce", new ElementRpc <Player>(Player.Local));

            RpcManager.Instance.RegisterRPC <EmptyRpc>("announce-response", (rpc) =>
            {
                ChatBox.WriteLine("Hey, we responded!");
            });

            RpcManager.Instance.RegisterRPC <EmptyRpc>("queue", (rpc) =>
            {
                ChatBox.WriteLine("I was queued!");
            });

            RpcManager.Instance.RegisterAsyncRPC <SingleCastRpc <string>, EmptyRpc>("Async.RequestLocalization", (request) =>
            {
                return(new SingleCastRpc <string>(GameClient.Localization.Item1));
            });

            Task.Run(async() =>
            {
                var responseRpc = await RpcManager.Instance.TriggerAsyncRpc <SingleCastRpc <string> >("Async.RequestMapName", new EmptyRpc());
                string name     = responseRpc.Value;
                ChatBox.WriteLine($"Map name: {name}");
            });

            Dx.DrawCircle(Vector2.Zero, 4);
        }
Exemplo n.º 3
0
        public TransformMatrix ComputeMatrix()
        {
            var dx = Dx.ToPixel();
            var dy = Dy.ToPixel();
            var dz = Dz.ToPixel();

            return(new TransformMatrix(1f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 1f, dx, dy, dz, 0f, 0f, 0f));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 字符串
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string str = String.Empty;

            str += "Ex_s=" + Ex.ToString("0.00000") +
                   ", Ey_s=" + Ey.ToString("0.00000") +
                   ", Ez_s=" + Ez.ToString("0.00000");
            str += ", Dx_m=" + Dx.ToString("0.00000") +
                   ", Dy_m=" + Dy.ToString("0.00000") +
                   ", Dz_m=" + Dz.ToString("0.00000");
            str += ", Scale_ppm=" + Scale_ppm.ToString("0.00000");
            return(str);
        }
Exemplo n.º 5
0
        private void GetAllFiles()
        {
            listViewgetFiles.Items.Clear();
            ClassWebFinder   obj        = new ClassWebFinder(textBoxUrl.Text, textBoxFilter.Text);
            StringCollection collection = obj.FileList();

            foreach (string Dx in collection)
            {
                ListViewItem Listitem = new ListViewItem();
                Listitem.SubItems.Add("Get Ready");
                Listitem.Text = Dx.Replace("%20", " ");
                listViewgetFiles.Items.Add(Listitem);
            }
        }
Exemplo n.º 6
0
        protected override void OnPaint(ref PaintPacket packet)
        {
            Dx.EnsureInitialized();

            try
            {
                OnDxPaint(Dx);
                Dx.D3D.SwapChain.Present(1, 0);
            }
            catch (SharpDXException ex)
            {
                if (!Dx.PerformResetOnException(ex))
                {
                    throw;
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Returns a hash code for the specified object
 /// </summary>
 /// <returns>A hash code for the specified object</returns>
 public override int GetHashCode()
 {
     return(Dx.GetHashCode() ^ Dy.GetHashCode() ^ Dz.GetHashCode() ^
            Ex.GetHashCode() ^ Ey.GetHashCode() ^ Ez.GetHashCode() ^
            Scale_ppm.GetHashCode());
 }
Exemplo n.º 8
0
    public static (vector, int) qnewton(
        Func <vector, double> f,                // Function to evaluate
        vector x,                               // starting point
        double acc    = 1e-3,                   // accuracy goal, |gradient|<acc on exit
        double alpha  = 1e-4,                   // alpha param for Armijo condition
        double dx     = 1e-7,                   // dx used in gradient calculation
        double minlam = 1e-7,                   // minimum lambda value before reset
        int limit     = 999,                    // limit on recursion steps
        double eps    = 1.0 / 4194304
        )
    {    // Quasi-newton minimization method for multivariable function
        int n = x.size;
        // Approximate inverse Hessian matrix B with identity matrix
        matrix B = new matrix(n, n);

        B.set_identity();

        // Gradient of f(x)
        vector gradx = gradient(f, x, dx: dx);
        vector Dx;
        // Precalc fx
        double fx = f(x);

        int nsteps = 0;

        do
        {
            nsteps++;
            // Calculate Newton step
            Dx = -B * gradx;
            // Lambda factor
            double lam = 1.0;

            // Armijo condition step check (Bracktracking line-search)
            while (f(x + lam * Dx) > fx + alpha * lam * Dx.dot(gradx))
            {
                // Check if B needs to be reset and begrudgingly accept
                if (lam < minlam)
                {
                    B.set_identity(); break;
                }
                // else update lambda
                lam /= 2;
            }

            // Calc new point z and gradz
            vector z     = x + lam * Dx;
            vector gradz = gradient(f, z, dx: dx);
            // Calc u and <u, y>
            vector y   = gradz - gradx;
            vector s   = lam * Dx;
            vector u   = s - B * y;
            double uTy = u.dot(y);
            // Do SR1 update of B if uTy numerically safe
            if (Abs(uTy) > 1e-6)
            {
                B.update(u, u, 1 / uTy);
            }
            // Update x, gradx, fx
            x     = z;
            gradx = gradz;
            fx    = f(x);
        }while (gradx.norm2() > acc & nsteps <limit& Dx.norm2()> eps * x.norm2());
        Error.WriteLine($"\nminimization.qnewton returning (x, nsteps)");
        Error.WriteLine($"gradx.norm2()		{gradx.norm2()}");
        Error.WriteLine($"acc			{acc}");
        Error.WriteLine($"nsteps / limit		{nsteps} / {limit}");
        Error.WriteLine($"Dx.norm2()		{Dx.norm2()}");
        Error.WriteLine($"eps*x.norm2()		{eps*x.norm2()}\n");
        return(x, nsteps);
    }     // end qnewton
Exemplo n.º 9
0
 public string ToString(string format)
 {
     return($"Grid2D information: dx = {Dx.ToString(format)}, dy = {Dy.ToString(format)}, X = {CountX}, Y= {CountY}");
 }