Пример #1
0
        public void MoveBall()
        {
            if (InvokeRequired)
            {
                MoveCallBack d = new MoveCallBack(MoveBall);
                Invoke(d);
            }
            else
            {
                int width  = Parent.Width;
                int height = Parent.Height;
                int X      = Location.X;
                int Y      = Location.Y;

                if (X <= (40 / 2) || X >= width - (40 / 2))
                {
                    dX = -dX;
                }

                if (Y <= (40 / 2) || Y >= height - (40 / 2))
                {
                    dY = -dY;
                }

                X += dX;
                Y += dY;

                Location = new Point(X, Y);
            }
        }
Пример #2
0
        public void MoveBall()
        {
            if (InvokeRequired)//этот ли поток создавал элемент управления
            {
                MoveCallBack d = new MoveCallBack(MoveBall);
                Invoke(d);//вызывает метод MoveBall  через делегат
            }
            else
            {
                int width  = Parent.Width;
                int height = Parent.Height;
                int X      = Location.X;
                int Y      = Location.Y;

                if (X <= (40 / 2) || X >= width - (40 / 2))
                {
                    dX = -dX;
                }

                if (Y <= (40 / 2) || Y >= height - (40 / 2))
                {
                    dY = -dY;
                }

                X += dX;
                Y += dY;

                Location = new Point(X, Y);
            }
        }
Пример #3
0
 void SendMessage(string message)
 {
     if (panel.listBox1.InvokeRequired)
     {
         MoveCallBack d = new MoveCallBack(SendMessage);
         panel.listBox1.Invoke(d, message);
     }
     else
     {
         panel.listBox1.Items.Add(message); //вывод сообщения
     }
 }
Пример #4
0
    void MoveCameraToPos(Transform targetTrans, MoveCallBack moveCallBack = null)
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));

        if (Physics.Raycast(ray, out hit, Mathf.Infinity, terrainChunkLayermask))
        {
            //Camera.main.transform.position = targetTrans.position + (-Camera.main.transform.forward * hit.distance);
            Vector3 targetPos = targetTrans.position +
                                (-Camera.main.transform.forward * (hit.distance + mainCameraZoom.localPosition.z));
            targetPos.y = mainCameraRoot.position.y;
            mainCameraRoot.DOMove(targetPos, 0.2f).
            OnComplete(() => {
                if (moveCallBack != null)
                {
                    moveCallBack();
                }
            });
        }
    }