示例#1
0
    void FixedUpdate()
    {
        //0 is for when the left button is clicked, 1 is for the right
        if (Input.GetMouseButtonDown(0))
        {
            mouseDownTime = Time.time;
        }

        if (Input.GetMouseButtonUp(0))
        {
            mouseDownTime = Time.time - mouseDownTime;
            //speed = mouseDownTime + 13;//this is the minimum for the power required to shoot the ball

            //if (speed < 13)
            //    speed = 13;

            //if (speed > 27)
            //    speed = 27;

            GameObject newBall = Instantiate(Ball, this.transform.position, Quaternion.identity) as GameObject;

            // Calculate direction, set length to 1
            Vector2 dir = new Vector2(-100, 100).normalized;

            //speed = (Time.time - mouseDownTime) * 3f;

            // Set Velocity with dir * speed
            newBall.GetComponent <Rigidbody2D>().velocity = dir * speed;
        }

        swipeManager.DetectSwipe();

        //switch(SwipeManager.swipeDirection)
        //{
        //	case SwipeManager.Swipe.SwipingDown:
        //		swipeHasStarted = true;
        //		break;
        //	case SwipeManager.Swipe.SwipingUp:
        //		swipeHasStarted = true;
        //		break;
        //	case SwipeManager.Swipe.None:
        //		if(swipeHasStarted)
        //		{
        //			GameObject newBall=Instantiate(Ball,new Vector3(-1.747414f,-2f,0), Quaternion.identity) as GameObject;

        //			// Calculate direction, set length to 1
        //			Vector2 dir = new Vector2(-1, 1).normalized;

        //			// Set Velocity with dir * speed
        //			newBall.GetComponent<Rigidbody2D>().velocity = dir * speed;

        //			swipeHasStarted = false;
        //		}
        //		break;
        //}
    }
示例#2
0
    void FixedUpdate()
    {
        //0 is for when the left button is clicked, 1 is for the right
//		if(Input.GetMouseButtonDown(0))
//		{
//			GameObject newBall=Instantiate(Ball,new Vector3(-1.747414f,-2f,0), Quaternion.identity) as GameObject;
//
//			// Calculate direction, set length to 1
//			Vector2 dir = new Vector2(-1, 1).normalized;
//
//			// Set Velocity with dir * speed
//			newBall.rigidbody2D.velocity = dir * speed;
//
//		}

        swipeManager.DetectSwipe();

        switch (SwipeManager.swipeDirection)
        {
        case SwipeManager.Swipe.SwipingDown:
            swipeHasStarted = true;
            break;

        case SwipeManager.Swipe.SwipingUp:
            swipeHasStarted = true;
            break;

        case SwipeManager.Swipe.None:
            if (swipeHasStarted)
            {
                GameObject newBall = Instantiate(Ball, new Vector3(-1.747414f, -2f, 0), Quaternion.identity) as GameObject;

                // Calculate direction, set length to 1
                Vector2 dir = new Vector2(-1, 1).normalized;

                // Set Velocity with dir * speed
                newBall.GetComponent <Rigidbody2D>().velocity = dir * speed;

                swipeHasStarted = false;
            }
            break;
        }
    }
        private void Update()
        {
            if (CardGameManager.Instance.ModalCanvas != null || results.inputField.isFocused)
            {
                return;
            }

            if (SwipeManager.DetectSwipe())
            {
                if ((CardViewer.Instance.IsVisible && CardViewer.Instance.Mode == CardViewerMode.Maximal) ||
                    CardViewer.Instance.Zoom && CardViewer.Instance.ZoomTime > 0.5f)
                {
                    if (SwipeManager.IsSwipingRight())
                    {
                        SelectLeft();
                    }
                    else if (SwipeManager.IsSwipingLeft())
                    {
                        SelectRight();
                    }
                }
                else if (!CardViewer.Instance.Zoom)
                {
                    if (Input.touches.All(touch => touch.position.y > Screen.height - GameSelectorHeight))
                    {
                        if (SwipeManager.IsSwipingRight())
                        {
                            CardGameManager.Instance.Select(CardGameManager.Instance.Previous.Id);
                        }
                        else if (SwipeManager.IsSwipingLeft())
                        {
                            CardGameManager.Instance.Select(CardGameManager.Instance.Next.Id);
                        }
                    }
                    else
                    {
                        if (SwipeManager.IsSwipingRight())
                        {
                            PageLeft();
                        }
                        else if (SwipeManager.IsSwipingLeft())
                        {
                            PageRight();
                        }
                    }
                }
            }

            if (Inputs.IsVertical)
            {
                if (Inputs.IsDown && !Inputs.WasDown)
                {
                    SelectDown();
                }
                else if (Inputs.IsUp && !Inputs.WasUp)
                {
                    SelectUp();
                }
            }
            else if (Inputs.IsHorizontal)
            {
                if (Inputs.IsLeft && !Inputs.WasLeft)
                {
                    SelectLeft();
                }
                else if (Inputs.IsRight && !Inputs.WasRight)
                {
                    SelectRight();
                }
            }

            if (Inputs.IsPageVertical)
            {
                if (CardViewer.Instance.IsVisible && CardViewer.Instance.Mode == CardViewerMode.Maximal)
                {
                    return;
                }
                if (Inputs.IsPageDown && !Inputs.WasPageDown)
                {
                    PageDown();
                }
                else if (Inputs.IsPageUp && !Inputs.WasPageUp)
                {
                    PageUp();
                }
            }
            else if (Inputs.IsPageHorizontal)
            {
                if (Inputs.IsPageLeft && !Inputs.WasPageLeft)
                {
                    PageLeft();
                }
                else if (Inputs.IsPageRight && !Inputs.WasPageRight)
                {
                    PageRight();
                }
            }
        }
        private void Update()
        {
            if (CardGameManager.Instance.ModalCanvas != null)
            {
                return;
            }

            if (SwipeManager.DetectSwipe())
            {
                if (SwipeManager.IsSwipingRight())
                {
                    SelectPrevious();
                }
                else if (SwipeManager.IsSwipingLeft())
                {
                    SelectNext();
                }
            }

            if (Inputs.IsPageVertical)
            {
                if (Inputs.IsPageDown && !Inputs.WasPageDown)
                {
                    SelectNext();
                }
                else if (Inputs.IsPageUp && !Inputs.WasPageUp)
                {
                    SelectPrevious();
                }
            }
            else if (Inputs.IsPageHorizontal)
            {
                if (Inputs.IsPageLeft && !Inputs.WasPageLeft)
                {
                    SelectPrevious();
                }
                else if (Inputs.IsPageRight && !Inputs.WasPageRight)
                {
                    SelectNext();
                }
            }
            else if (Inputs.IsHorizontal && (EventSystem.current.currentSelectedGameObject == null ||
                                             EventSystem.current.currentSelectedGameObject ==
                                             selectableButtons[0].gameObject))
            {
                if (Inputs.IsLeft && !Inputs.WasLeft)
                {
                    SelectPrevious();
                }
                else if (Inputs.IsRight && !Inputs.WasRight)
                {
                    SelectNext();
                }
            }
            else if (Inputs.IsVertical && !selectableButtons.Contains(EventSystem.current.currentSelectedGameObject))
            {
                EventSystem.current.SetSelectedGameObject(selectableButtons[0].gameObject);
            }

            if (Input.GetKeyDown(Inputs.BluetoothReturn))
            {
                if (EventSystem.current.currentSelectedGameObject != null)
                {
                    EventSystem.current.currentSelectedGameObject.GetComponent <Button>()?.onClick?.Invoke();
                }
            }
            else if (Inputs.IsSort)
            {
                SelectPrevious();
            }
            else if (Inputs.IsFilter)
            {
                SelectNext();
            }
            else if (Inputs.IsNew)
            {
                if (gameManagement.activeSelf)
                {
                    Create();
                }
                else
                {
                    StartGame();
                }
            }
            else if (Inputs.IsLoad)
            {
                if (gameManagement.activeSelf)
                {
                    Download();
                }
                else
                {
                    JoinGame();
                }
            }
            else if (Inputs.IsSave)
            {
                if (gameManagement.activeSelf)
                {
                    Share();
                }
                else
                {
                    EditDeck();
                }
            }
            else if (Inputs.IsOption)
            {
                if (gameManagement.activeSelf)
                {
                    Delete();
                }
                else
                {
                    ExploreCards();
                }
            }
            else if (Inputs.IsFocusBack && !Inputs.WasFocusBack)
            {
                ToggleGameManagement();
            }
            else if (Inputs.IsFocusNext && !Inputs.WasFocusNext)
            {
                ShowSettings();
            }
            else if (Inputs.IsCancel)
            {
                if (EventSystem.current.currentSelectedGameObject == null)
                {
                    Quit();
                }
                else if (!EventSystem.current.alreadySelecting)
                {
                    EventSystem.current.SetSelectedGameObject(null);
                }
            }
        }
示例#5
0
        private void Update()
        {
            if (CardGameManager.Instance.ModalCanvas != null || editor.searchResults.inputField.isFocused)
            {
                return;
            }

            if (CardViewer.Instance.Zoom && CardViewer.Instance.ZoomTime > 0.5f && SwipeManager.DetectSwipe())
            {
                if (SwipeManager.IsSwipingUp())
                {
                    SelectEditorDown();
                }
                else if (SwipeManager.IsSwipingDown())
                {
                    SelectEditorUp();
                }
                if (SwipeManager.IsSwipingRight())
                {
                    SelectResultsLeft();
                }
                else if (SwipeManager.IsSwipingLeft())
                {
                    SelectResultsRight();
                }
            }

            if (Inputs.IsVertical)
            {
                if (Inputs.IsDown && !Inputs.WasDown)
                {
                    SelectResultsDown();
                }
                else if (Inputs.IsUp && !Inputs.WasUp)
                {
                    SelectResultsUp();
                }
            }
            else if (Inputs.IsHorizontal)
            {
                if (Inputs.IsLeft && !Inputs.WasLeft)
                {
                    SelectResultsLeft();
                }
                else if (Inputs.IsRight && !Inputs.WasRight)
                {
                    SelectResultsRight();
                }
            }

            if (Inputs.IsPageVertical)
            {
                if (Inputs.IsPageDown && !Inputs.WasPageDown)
                {
                    SelectEditorDown();
                }
                else if (Inputs.IsPageUp && !Inputs.WasPageUp)
                {
                    SelectEditorUp();
                }
            }
            else if (Inputs.IsPageHorizontal)
            {
                if (Inputs.IsPageLeft && !Inputs.WasPageLeft)
                {
                    SelectEditorLeft();
                }
                else if (Inputs.IsPageRight && !Inputs.WasPageRight)
                {
                    SelectEditorRight();
                }
            }
        }
        void Update()
        {
            if (CardGameManager.Instance.ModalCanvas != null)
            {
                return;
            }

            if (SwipeManager.DetectSwipe())
            {
                if (SwipeManager.IsSwipingRight())
                {
                    SelectNext();
                }
                else if (SwipeManager.IsSwipingLeft())
                {
                    SelectPrevious();
                }
            }

            if (Input.GetButtonDown(Inputs.PageVertical) || Input.GetAxis(Inputs.PageVertical) != 0)
            {
                if (Input.GetAxis(Inputs.PageVertical) < 0 && !_wasPageDown)
                {
                    SelectNext();
                }
                else if (Input.GetAxis(Inputs.PageVertical) > 0 && !_wasPageUp)
                {
                    SelectPrevious();
                }
            }
            else if ((Input.GetButtonDown(Inputs.PageHorizontal) || Input.GetAxis(Inputs.PageHorizontal) != 0))
            {
                if (Input.GetAxis(Inputs.PageHorizontal) < 0 && !_wasPageLeft)
                {
                    SelectPrevious();
                }
                else if (Input.GetAxis(Inputs.PageHorizontal) > 0 && !_wasPageRight)
                {
                    SelectNext();
                }
            }
            else if ((Input.GetButtonDown(Inputs.Horizontal) || Input.GetAxis(Inputs.Horizontal) != 0) &&
                     (EventSystem.current.currentSelectedGameObject == null ||
                      EventSystem.current.currentSelectedGameObject == selectableButtons[0].gameObject))
            {
                if (Input.GetAxis(Inputs.Horizontal) < 0 && !_wasLeft)
                {
                    SelectPrevious();
                }
                else if (Input.GetAxis(Inputs.Horizontal) > 0 && !_wasRight)
                {
                    SelectNext();
                }
            }
            else if ((Input.GetButtonDown(Inputs.Vertical) || Input.GetAxis(Inputs.Vertical) != 0) &&
                     !selectableButtons.Contains(EventSystem.current.currentSelectedGameObject))
            {
                EventSystem.current.SetSelectedGameObject(selectableButtons[0].gameObject);
            }

            if (Input.GetKeyDown(Inputs.BluetoothReturn))
            {
                EventSystem.current.currentSelectedGameObject?.GetComponent <Button>()?.onClick?.Invoke();
            }
            else if (Input.GetButtonDown(Inputs.Sort))
            {
                SelectPrevious();
            }
            else if (Input.GetButtonDown(Inputs.Filter))
            {
                SelectNext();
            }
            else if (Input.GetButtonDown(Inputs.New))
            {
                if (gameManagement.activeSelf)
                {
                    Download();
                }
                else
                {
                    StartGame();
                }
            }
            else if (Input.GetButtonDown(Inputs.Load))
            {
                if (gameManagement.activeSelf)
                {
                    Download();
                }
                else
                {
                    JoinGame();
                }
            }
            else if (Input.GetButtonDown(Inputs.Save))
            {
                if (gameManagement.activeSelf)
                {
                    Share();
                }
                else
                {
                    EditDeck();
                }
            }
            else if (Input.GetButtonDown(Inputs.Option))
            {
                if (gameManagement.activeSelf)
                {
                    Delete();
                }
                else
                {
                    ExploreCards();
                }
            }
            else if (Input.GetButtonDown(Inputs.FocusBack) || (Input.GetAxis(Inputs.FocusBack) > 0 && !_wasFocusBack))
            {
                ToggleGameManagement();
            }
            else if (Input.GetButtonDown(Inputs.FocusNext) || (Input.GetAxis(Inputs.FocusNext) > 0 && !_wasFocusNext))
            {
                ShowSettings();
            }
            else if (Input.GetKeyDown(KeyCode.Escape) || Input.GetButtonDown(Inputs.Cancel))
            {
                if (EventSystem.current.currentSelectedGameObject == null)
                {
                    Quit();
                }
                else if (!EventSystem.current.alreadySelecting)
                {
                    EventSystem.current.SetSelectedGameObject(null);
                }
            }

            _wasLeft      = Input.GetAxis(Inputs.Horizontal) < 0;
            _wasRight     = Input.GetAxis(Inputs.Horizontal) > 0;
            _wasPageDown  = Input.GetAxis(Inputs.PageVertical) < 0;
            _wasPageUp    = Input.GetAxis(Inputs.PageVertical) > 0;
            _wasPageLeft  = Input.GetAxis(Inputs.PageHorizontal) < 0;
            _wasPageRight = Input.GetAxis(Inputs.PageHorizontal) > 0;
            _wasFocusBack = Input.GetAxis(Inputs.FocusBack) > 0;
            _wasFocusNext = Input.GetAxis(Inputs.FocusNext) > 0;
        }
        void Update()
        {
            if (CardGameManager.Instance.ModalCanvas != null || editor.searchResults.inputField.isFocused)
            {
                return;
            }

            if (CardViewer.Instance.Zoom && CardViewer.Instance.ZoomTime > 0.5f && SwipeManager.DetectSwipe())
            {
                if (SwipeManager.IsSwipingUp())
                {
                    SelectEditorDown();
                }
                else if (SwipeManager.IsSwipingDown())
                {
                    SelectEditorUp();
                }
                if (SwipeManager.IsSwipingRight())
                {
                    SelectResultsLeft();
                }
                else if (SwipeManager.IsSwipingLeft())
                {
                    SelectResultsRight();
                }
            }

            if (Input.GetButtonDown(Inputs.Vertical) || Input.GetAxis(Inputs.Vertical) != 0)
            {
                if (Input.GetAxis(Inputs.Vertical) < 0 && !_wasDown)
                {
                    SelectResultsDown();
                }
                else if (Input.GetAxis(Inputs.Vertical) > 0 && !_wasUp)
                {
                    SelectResultsUp();
                }
            }
            else if (Input.GetButtonDown(Inputs.Horizontal) || Input.GetAxis(Inputs.Horizontal) != 0)
            {
                if (Input.GetAxis(Inputs.Horizontal) < 0 && !_wasLeft)
                {
                    SelectResultsLeft();
                }
                else if (Input.GetAxis(Inputs.Horizontal) > 0 && !_wasRight)
                {
                    SelectResultsRight();
                }
            }

            if (Input.GetButtonDown(Inputs.PageVertical) || Input.GetAxis(Inputs.PageVertical) != 0)
            {
                if (Input.GetAxis(Inputs.PageVertical) < 0 && !_wasPageDown)
                {
                    SelectEditorDown();
                }
                else if (Input.GetAxis(Inputs.PageVertical) > 0 && !_wasPageUp)
                {
                    SelectEditorUp();
                }
            }
            else if ((Input.GetButtonDown(Inputs.PageHorizontal) || Input.GetAxis(Inputs.PageHorizontal) != 0))
            {
                if (Input.GetAxis(Inputs.PageHorizontal) < 0 && !_wasPageLeft)
                {
                    SelectEditorLeft();
                }
                else if (Input.GetAxis(Inputs.PageHorizontal) > 0 && !_wasPageRight)
                {
                    SelectEditorRight();
                }
            }

            _wasDown      = Input.GetAxis(Inputs.Vertical) < 0;
            _wasUp        = Input.GetAxis(Inputs.Vertical) > 0;
            _wasLeft      = Input.GetAxis(Inputs.Horizontal) < 0;
            _wasRight     = Input.GetAxis(Inputs.Horizontal) > 0;
            _wasPageDown  = Input.GetAxis(Inputs.PageVertical) < 0;
            _wasPageUp    = Input.GetAxis(Inputs.PageVertical) > 0;
            _wasPageLeft  = Input.GetAxis(Inputs.PageHorizontal) < 0;
            _wasPageRight = Input.GetAxis(Inputs.PageHorizontal) > 0;
        }
        void Update()
        {
            if (CardGameManager.TopMenuCanvas != null || editor.searchResults.nameInputField.isFocused)
            {
                return;
            }

            if (CardInfoViewer.Instance.zoomPanel.gameObject.activeSelf && SwipeManager.DetectSwipe())
            {
                if (SwipeManager.IsSwipingDown())
                {
                    SelectUp();
                }
                else if (SwipeManager.IsSwipingUp())
                {
                    SelectDown();
                }
                else if (SwipeManager.IsSwipingRight())
                {
                    SelectLeft();
                }
                else if (SwipeManager.IsSwipingLeft())
                {
                    SelectRight();
                }
            }

            if (Input.anyKeyDown)
            {
                if (Input.GetButtonDown(Inputs.Vertical))
                {
                    if (Input.GetAxis(Inputs.Vertical) > 0)
                    {
                        SelectUp();
                    }
                    else
                    {
                        SelectDown();
                    }
                }
                else if (Input.GetButtonDown(Inputs.Horizontal))
                {
                    if (Input.GetAxis(Inputs.Horizontal) > 0)
                    {
                        SelectRight();
                    }
                    else
                    {
                        SelectLeft();
                    }
                }
                else if (Input.GetButtonDown(Inputs.Column))
                {
                    if (Input.GetAxis(Inputs.Column) > 0)
                    {
                        ShiftRight();
                    }
                    else
                    {
                        ShiftLeft();
                    }
                }
                else if (Input.GetButtonDown(Inputs.Page) && !CardInfoViewer.Instance.IsVisible)
                {
                    if (Input.GetAxis(Inputs.Page) > 0)
                    {
                        PageRight();
                    }
                    else
                    {
                        PageLeft();
                    }
                }
            }
        }