예제 #1
0
    private void Update()
    {
        if (!menuActive)
        {
            del2 for_collided_button = (del1 d) =>
            {
                var        ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit))
                {
                    d(hit.collider.gameObject.GetComponent <Button>());
                }
            };

            if (Input.GetButtonDown("Menu"))
            {
                ShowMenu();
            }

            if (Input.GetButtonDown("Jump"))
            {
                for_collided_button((Button b) => beginRayCast = b);
            }
            else if (beginRayCast)
            {
                for_collided_button((Button b) =>
                {
                    if (b == beginRayCast)
                    {
                        b.onClick.Invoke();
                    }
                });

                beginRayCast = null;
            }

            if (gameOver)
            {
                timeForRestart -= Time.deltaTime;
                if (timeForRestart < 0)
                {
                    restart();
                }
            }
        }
        else
        {
            if (Input.GetButtonDown("Menu"))
            {
                HideMenu();
            }
        }

        rotationX += Input.GetAxis("Mouse X") * sensX * Time.deltaTime;
        //rotationY += Input.GetAxis("Mouse Y") * sensY * Time.deltaTime;
        rotationY = Mathf.Clamp(rotationY, minY, maxY);
        camera.transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
    }
예제 #2
0
        public static int func2(int x, int y)
        {
            Console.WriteLine("Delegate Method 2");
            Console.WriteLine(x + y);
            del2 d = new del2(func3);

            d(23, 24);
            return(0);
        }
        static void Main(string[] args)
        {
            del  myDelegate  = x => x * x;
            int  rez         = myDelegate(5);     //rez = 25
            del2 myDelegate2 = (x1, x2) => x1 * x2;
            int  rez2        = myDelegate2(5, 5); //rez = 25

            Console.Write("Rez1: " + rez + " Rez2: " + rez2);
        }
예제 #4
0
        public static void testMetric1()
        {
            // Lambda used for delegate
            Func <int, bool> myFunc      = x => x == 5;
            del1             myDelegate1 = x => x * x;
            del2             myDelegate2 = x => x == 5;

            Console.WriteLine(myDelegate1(2));
            Console.WriteLine(myDelegate2(5));
            Console.WriteLine(myFunc(5));

            // Lambda used for Expression<Func> (linq operators accept Expression<Func<TSource>>)
            // TO BE Updated
        }
        static void Main(string[] args)
        {
            del1 handler1 = x => x * x;

            Console.WriteLine("Task 1: " + handler1(5) + "\n");

            del2 handler2 = (x1, x2, x3) => x1 + x2 + x3;

            Console.WriteLine("Task 2: " + handler2(5.12f, 6.31f, 1.17f) + "\n");

            del3 handler3 = () => "hello";

            Console.WriteLine("Task 3: " + handler3());
        }
예제 #6
0
        static void Main(string[] args)
        {
            del1 handler = DelegateStringMethod;

            handler();

            del2  handler2  = DelegateFloatMethod;
            float del2Float = handler2();

            Console.WriteLine("\n" + del2Float);

            del3 handler3 = DelegateNoReturn;

            handler3("hey", 122, 1.12f);
        }
 private void toolStripButton3_Click(object sender, EventArgs e)
 {
     this.Cursor         = Cursors.Hand;
     pictureBox1.Enabled = false;
     pictureBox2.Enabled = false;
     pictureBox3.Enabled = false;
     pictureBox4.Enabled = false;
     pictureBox5.Enabled = false;
     pictureBox6.Enabled = false;
     pictureBox7.Enabled = false;
     pictureBox8.Enabled = false;
     pictureBox9.Enabled = false;
     deli = null; deli2 = null;
     Points();
 }
 private void pictureBox2_MouseDown(object sender, MouseEventArgs e)         //метод определяющий какой из элементов удерживается
 {
     if (sender == pictureBox2)
     {
         deli  = PaiC;
         deli2 = null;
     }
     if (sender == pictureBox1)
     {
         deli  = PaiK;
         deli2 = null;
     }
     if (sender == pictureBox3)
     {
         deli  = PaiP;
         deli2 = null;
     }
     if (sender == pictureBox4)
     {
         deli2 = PaiI;
         deli  = null;
     }
     if (sender == pictureBox5)
     {
         deli2 = PaiS;
         deli  = null;
     }
     if (sender == pictureBox6)
     {
         deli  = PaiU;
         deli2 = null;
     }
     if (sender == pictureBox7)
     {
         deli  = PaiU;
         deli2 = null;
     }
     if (sender == pictureBox8)
     {
         deli  = null;
         deli2 = PaiL;
     }
     if (sender == pictureBox9)
     {
         deli  = null;
         deli2 = PaiM;
     }
 }
예제 #9
0
파일: Form1.cs 프로젝트: ChrisPaine/C-sharp
        private void button1_Click(object sender, EventArgs e)
        {
            del1 d1 = new del1(method1);//pass address with no params par
            d1();

            del2 d2 = new del2(method2);
            d2(5);

            del2 d3;
            d3 = method2;
            d3(12);

            del3 dAdd;
            dAdd = method3;
            int res = dAdd(4, 5);
            MessageBox.Show("method3 "+res);
        }
예제 #10
0
        static void Main(string[] args)
        {
            //Console.WriteLine("Hello World!");

            Ashfaaq a = new Ashfaaq();

            del1 d = a.AddNum;

            Console.WriteLine(d(3, 4));

            d = a.MulNum;
            Console.WriteLine(d(3, 4));

            Ashfaaq2 a2 = new Ashfaaq2();
            del2     d2 = a2.Check;

            Console.WriteLine(d2("True"));
        }
예제 #11
0
파일: Form1.cs 프로젝트: ChrisPaine/C-sharp
        private void button1_Click(object sender, EventArgs e)
        {
            del1 d1 = new del1(method1);//pass address with no params par

            d1();

            del2 d2 = new del2(method2);

            d2(5);

            del2 d3;

            d3 = method2;
            d3(12);

            del3 dAdd;

            dAdd = method3;
            int res = dAdd(4, 5);

            MessageBox.Show("method3 " + res);
        }
예제 #12
0
 public void refreshMaze(Maze i_maze, List <int[]> changedFields)
 {
     if (this.InvokeRequired)
     {
         Console.WriteLine("invoking");
         del2 f = new del2(refreshMaze);
         this.Invoke(f, new object[] { i_maze, changedFields });
     }
     else
     {
         using (Graphics g = this.CreateGraphics())
         {
             //g.Clear(SystemColors.Control); //Clear the draw area
             using (Pen pen = new Pen(Color.White, 2))
             {
                 foreach (int[] field in changedFields)
                 {
                     g.DrawString(i_maze.Coords[field[0]][field[1]] + "", new Font("Arial", 7), new SolidBrush(Color.Black), allRects[field[0]][field[1]]);
                 }
             }
         }
     }
 }
예제 #13
0
파일: Program.cs 프로젝트: Maxwa95/Shape
 public static void Pm(del m, del2 m2)
 {
     m(m2());
 }