Example #1
0
        public void Next()
        {
            //从左往右显示动画
            if (_pageIndex < ImageList.Count - 1)
            {
                //如果不是第一张则显示前一张
                _imageDirection = AnimatorDirection.LeftToRight;
                _oldpageIndex   = _pageIndex;
                ++_pageIndex;
            }
            else
            {
                //如果是第一张显示最后一张
                _imageDirection = AnimatorDirection.LeftToRight;
                _oldpageIndex   = _pageIndex;
                _pageIndex      = 0;
            }
            //是否以动画效果显示图片
            if (IsShowAnimation)
            {
                if (_imageDirection == AnimatorDirection.LeftToRight)
                {
                    InfoPaddingLeft = -Width;
                }
                else if (_imageDirection == AnimatorDirection.RightToLeft)
                {
                    InfoPaddingLeft = Width + 40;
                }

                DoubleBuffered = true;

                _timer          = new Timer();
                _timer.Interval = AnimationSpeed;
                _timer.Tick    += AnimationTick;
                _timer.Start();
            }
            else
            {
                _oldpageIndex   = _pageIndex;
                InfoPaddingLeft = 20;
                Invalidate();
            }
        }
Example #2
0
        public void Previous()
        {
            //从右向左显示动画
            if (_pageIndex > 0)
            {
                //如果不是最后一张则显示下一张
                _oldpageIndex = _pageIndex;
                --_pageIndex;

                _imageDirection = AnimatorDirection.RightToLeft;
            }
            else
            {
                //如果是最后一张显示第一张
                _imageDirection = AnimatorDirection.RightToLeft;
                _oldpageIndex   = _pageIndex;
                _pageIndex      = ImageList.Count - 1;
            }
            //是否以动画效果显示图片
            if (IsShowAnimation)
            {
                if (_imageDirection == AnimatorDirection.LeftToRight)
                {
                    InfoPaddingLeft = -Width;
                }
                else if (_imageDirection == AnimatorDirection.RightToLeft)
                {
                    InfoPaddingLeft = Width + 40;
                }
                DoubleBuffered = true;

                _timer          = new Timer();
                _timer.Interval = AnimationSpeed;
                _timer.Tick    += AnimationTick;
                _timer.Start();
            }
            else
            {
                InfoPaddingLeft = 20;
                Invalidate();
            }
        }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (CanTarget)
        {
            if (UseMouse)
            {
                targetDir = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)) - transform.position;
                //Debug.Log(Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)));
                //Debug.Log(targetDir);
            }
            else
            {
                targetDir = target.position - transform.position;
            }

            float angle = Vector3.SignedAngle(targetDir, transform.right, Vector3.back);

            if (angle > 45f && angle < 135f)
            {
                direction = AnimatorDirection.Up;
            }

            if (angle > 135f || angle < -135f)
            {
                direction = AnimatorDirection.Left;
            }

            if (angle > -135 && angle < -45)
            {
                direction = AnimatorDirection.Down;
            }

            if (angle > -45 && angle < 45)
            {
                direction = AnimatorDirection.Right;
            }

            //Debug.Log(direction);
            //Debug.Log(angle);
        }
    }