Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     if (!GameProgress.IS_GAME_ACTIVE)
     {
         CloseFridge();
     }
     else
     {
         if (SwipeManager.IsSwipingRight() && !fridgeOpen.activeSelf)
         {
             if (SwipeManager.SWIPE_ENABLE)
             {
                 OpenFridge();
             }
         }
         else if (SwipeManager.IsSwipingLeft())
         {
             if (SwipeManager.SWIPE_ENABLE)
             {
                 CloseFridge();
             }
         }
         if (GameProgress.GAME_TIME - timeOpenFridge > delta)
         {
             CloseFridge();
         }
     }
 }
 void Update()
 {
     if (autoDetectSwipes)
     {
         DetectSwipe();
     }
     if (GameManager.instance.inRun)
     {
         if (SwipeManager.IsSwipingUp())
         {
             GameManager.instance.MovePlayer("2");
         }
         if (SwipeManager.IsSwipingDown())
         {
             GameManager.instance.MovePlayer("8");
         }
         if (SwipeManager.IsSwipingLeft())
         {
             GameManager.instance.MovePlayer("4");
         }
         if (SwipeManager.IsSwipingRight())
         {
             GameManager.instance.MovePlayer("6");
         }
     }
 }
Exemple #3
0
    // Update is called once per frame
    void Update()
    {
        float offGroundY = rb2d.transform.position.y - baseY;

        //print ("off Ground" + offGroundY);
        GameControl.instance.setPlayerOffGroundY(offGroundY);
        GameControl.instance.setPlayerPosition(rb2d.transform.position);

        //Input.GetTouch(0).deltaPosition.x < 0
        //if (Input.GetKeyUp("left") ) {
        if (SwipeManager.IsSwipingLeft())
        {
            rb2d.velocity = Vector2.zero;
            rb2d.AddForce(new Vector2(-upForce, 0));
            ninjaFlyOn(true);
            removeGravity();
        }

        //if(Input.GetKeyUp("right") ){
        if (SwipeManager.IsSwipingRight())
        {
            rb2d.velocity = Vector2.zero;
            rb2d.AddForce(new Vector2(upForce, 0));
            ninjaFlyOn(true);
            removeGravity();
        }
    }
Exemple #4
0
 // Update is called once per frame
 void Update()
 {
     if (SwipeManager.IsSwipingLeft())
     {
         // do something
         Debug.Log("LEFT");
     }
     if (SwipeManager.IsSwipingRight())
     {
         // do something
         Debug.Log("RIGHT");
     }
     if (SwipeManager.IsSwipingDown())
     {
         // do something
         Debug.Log("DOWN");
     }
     if (SwipeManager.IsSwipingUp())
     {
         // do something
         Debug.Log("UP");
     }
     if (SwipeManager.IsSwipingDownLeft())
     {
         // do something
         Debug.Log("DownLeft");
     }
 }
Exemple #5
0
 private void GamePlayInputs()
 {
     if (GameManager.instance.status == GameStatus.GamePlay)
     {
         //Rotate Player To Left
         if (SwipeManager.IsSwipingLeft() && myCollision.canTurn)
         {
             EventManager.TriggerEvent(EventManager.instance.RotateLeftButton);
         }
         //Rotate Player To Right
         else if (SwipeManager.IsSwipingRight() && myCollision.canTurn)
         {
             EventManager.TriggerEvent(EventManager.instance.RotateRightButton);
         }
         //Jump Player
         else if (SwipeManager.IsSwipingUp())
         {
             EventManager.TriggerEvent(EventManager.instance.JumpButton);
         }
         else if (SwipeManager.IsSwipingDown())
         {
             EventManager.TriggerEvent(EventManager.instance.CrouchButton);
         }
         else if (Input.GetMouseButton(0))
         {
             EventManager.TriggerEvent(EventManager.instance.MoveButton);
         }
     }
 }
Exemple #6
0
    void Update()
    {
        /*if (transform.position.x < 0)
         *  currentLane = 0;
         * else if (transform.position.x > 0)
         *  currentLane = 2;
         * else
         *  currentLane = 1;*/


        if ((SwipeManager.IsSwipingRight() || Input.GetKeyDown(KeyCode.RightArrow)))
        {
            if (currentLane == 0)
            {
                //animator.SetTrigger("LeanRight");
                //StartCoroutine("SwitchLane", centralLane);
                currentLane = 1;
                animator.SetTrigger("CL01");
                animator.ResetTrigger("CL12");
                animator.ResetTrigger("CL10");
                animator.ResetTrigger("CL21");
            }
            else if (currentLane == 1)
            {
                //animator.SetTrigger("LeanRight");
                //StartCoroutine("SwitchLane", rightLane);
                currentLane = 2;
                animator.SetTrigger("CL12");
                animator.ResetTrigger("CL01");
                animator.ResetTrigger("CL10");
                animator.ResetTrigger("CL21");
            }
        }

        else if ((SwipeManager.IsSwipingLeft() || Input.GetKeyDown(KeyCode.LeftArrow)))
        {
            if (currentLane == 1)
            {
                //animator.SetTrigger("LeanLeft");
                //StartCoroutine("SwitchLane", leftLane);
                currentLane = 0;
                animator.SetTrigger("CL10");
                animator.ResetTrigger("CL12");
                animator.ResetTrigger("CL01");
                animator.ResetTrigger("CL21");
            }
            else if (currentLane == 2)
            {
                //animator.SetTrigger("LeanLeft");
                //StartCoroutine("SwitchLane", centralLane);
                currentLane = 1;
                animator.SetTrigger("CL21");
                animator.ResetTrigger("CL12");
                animator.ResetTrigger("CL01");
                animator.ResetTrigger("CL10");
            }
        }
    }
Exemple #7
0
 private void Update()
 {
     if (SwipeManager.IsSwipingLeft())
     {
         Map1.SetActive(false);
         Map2.SetActive(true);
     }
     if (SwipeManager.IsSwipingRight())
     {
         Map1.SetActive(true);
         Map2.SetActive(false);
     }
 }
Exemple #8
0
 /// <summary>
 /// Detects the users swipe and plays the subsequent animation.
 /// Deals damage to enemy based on the weapon equipped.
 /// </summary>
 void Update()
 {
     if (player.GetCurrentAnimatorStateInfo(0).IsName("IdleWithWeapon"))
     {
         if (SwipeManager.IsSwipingLeft())
         {
             player.SetTrigger("Hit01");
             enemyHealth.TakeDamage(Inventory.instance.getEquipped().lightDamage);
         }
         else if (SwipeManager.IsSwipingRight())
         {
             player.SetTrigger("Hit02");
             enemyHealth.TakeDamage(Inventory.instance.getEquipped().heavyDamage);
         }
     }
 }
    void MoveOnSwipe()
    {
        if (SwipeManager.IsSwipingUp())
        {
            if (Time.time > nextJump)
            {
                nextJump             = Time.time + jumpRate;
                myRigidBody.velocity = new Vector3(myRigidBody.velocity.x, 5f, 0f);
            }
        }
        if (SwipeManager.IsSwiping())
        {
            //shooting
            //isFire=true;

            /*Debug.Log("tragem tragem tragem ");
             * if(Time.time>nextFire){
             *      nextFire=Time.time+fireRate;
             *      myAnim.Play("WalkAndFire");
             *      Instantiate(bullet,bulletSpawn.position,bulletSpawn.rotation);
             *
             * }/* */
        }
        //}
        if (SwipeManager.IsSwipingLeft())
        {
            moveSpeed = moveSpeed - 1;
            if (moveSpeed <= 1)
            {
                moveSpeed = 1;
            }
        }
        if (SwipeManager.IsSwipingRight())
        {
            moveSpeed = moveSpeed + 1;
            if (moveSpeed >= 10)
            {
                moveSpeed = 10;
            }
        }
    }
Exemple #10
0
    // Update is called once per frame
    void Update()
    {
        if (SwipeManager.IsSwipingLeft())
        {
            Debug.Log("swiped left ");
            book.FlipRightPage();
        }

        if (SwipeManager.IsSwipingRight())
        {
            Debug.Log("swiped right ");
            book.FlipLeftPage();
        }

        // OR

        if (SwipeManager.IsSwiping())
        {
            // do something
        }
    }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        if (failureTriggered)
        {
            PlayerPrefsManager.CheckSetHighScore(kidsServed);

            debugResetButton.gameObject.SetActive(true);
        }
        else
        {
            if (SwipeManager.IsSwipingLeft())
            {
                currentKidAnimator.SetTrigger("SwipeLeft");
                Naughty();
            }
            if (SwipeManager.IsSwipingRight())
            {
                currentKidAnimator.SetTrigger("SwipeRight");
                Nice();
            }
        }
    }
Exemple #12
0
 public Vector3 inputToDirection()
 {
     if (Input.GetKeyDown(KeyCode.A) || SwipeManager.IsSwipingLeft())
     {
         direction = Vector3.left;
         return(Vector3.left);
     }
     else if (Input.GetKeyDown(KeyCode.D) || SwipeManager.IsSwipingRight())
     {
         direction = Vector3.right;
         return(Vector3.right);
     }
     else if (Input.GetKeyDown(KeyCode.S) || SwipeManager.IsSwipingDown())
     {
         direction = Vector3.down;
         return(Vector3.down);
     }
     else if (Input.GetKeyDown(KeyCode.W) || SwipeManager.IsSwipingUp())
     {
         direction = Vector3.up;
         return(Vector3.up);
     }
     return(Vector3.zero);
 }
        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;
        }
Exemple #14
0
    void Update()
    {
        if (!GameSession.isGameStart)
        {
            return;
        }
        else
        {
            animator.SetTrigger("GameStart");
        }
        if (!isAlive || GameSession.youLose)
        {
            return;
        }



        #region Decrease battery variable unit per 5 seconds
        if (currentCharge > 0)
        {
            count += Time.deltaTime;
        }
        while (count > 2)
        {
            DealCharge(-decraseChargePerFiveSeconds);
            count = 0;
        }
        #endregion

        myRigidbody.velocity = new Vector3(transform.position.x, myRigidbody.velocity.y, forwardSpeed);

        Jump();

        #region Move Left, Right

        if (Input.GetKeyDown(KeyCode.LeftArrow) || SwipeManager.IsSwipingLeft())
        {
            if (hasHorizontalSpeed)
            {
                return;
            }                                   // prevent multi change lane

            hasHorizontalSpeed = true;

            laneIndex--;
            if (laneIndex < 0)
            {
                laneIndex = 0;
            }

            StartCoroutine(Move(0.3f));
        }

        if (Input.GetKeyDown(KeyCode.RightArrow) || SwipeManager.IsSwipingRight())
        {
            if (hasHorizontalSpeed)
            {
                return;
            }                                   // prevent multi change lane

            hasHorizontalSpeed = true;

            laneIndex++;
            if (laneIndex > 2)
            {
                laneIndex = 2;
            }

            StartCoroutine(Move(0.3f));
        }

        #endregion
    }
        void Update()
        {
            if (MovementActive)
            {
                if (target != null && (Vector2)mTransform.position != target.WorldPosition)
                {
                    MovementTo(target.WorldPosition);
                }
#if UNITY_EDITOR || UNITY_WEBG || UNITY_WEBGL || UNITY_WEBGL_API
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(target, 0, 1);
                    direction  = PlayerDirection.Up;
                }

                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(target, 0, -1);
                    direction  = PlayerDirection.Down;
                }

                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(target, 1, 0);
                    direction  = PlayerDirection.Right;
                }

                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(target, -1, 0);
                    direction  = PlayerDirection.Left;
                }
#else
                if (SwipeManager.IsSwipingUp())
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, 0, 1);
                    direction  = PlayerDirection.Up;
                }

                if (SwipeManager.IsSwipingDown())
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, 0, -1);
                    direction  = PlayerDirection.Down;
                }

                if (SwipeManager.IsSwipingRight())
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, 1, 0);
                    direction  = PlayerDirection.Right;
                }

                if (SwipeManager.IsSwipingLeft())
                {
                    nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, -1, 0);
                    direction  = PlayerDirection.Left;
                }
#endif
                if (nextTarget != null && nextTarget != target && (Vector2)mTransform.position == target.WorldPosition)
                {
                    if (currentPosition.Edges[(int)direction])
                    {
                        target = nextTarget;
                    }
                }
            }
        }
        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);
                }
            }
        }
Exemple #17
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();
                }
            }
        }
        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();
                }
            }
        }
Exemple #19
0
    //move function
    public void move()
    {
        float currentSpeed = speed;

        if (Input.GetKey(KeyCode.UpArrow))
        {
            currentSpeed *= 2;
        }

        //move the head
        if (bodyParts.Count != 0)
        {
            bodyParts[0].Translate(bodyParts[0].forward * currentSpeed * Time.smoothDeltaTime, Space.World);
        }

        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //rotate the head with directions
        //go to 90 degrees with right arrow
        if ((Input.GetKeyDown(KeyCode.RightArrow) || SwipeManager.IsSwipingRight()) && bodyParts.Count != 0)
        {
            StopAllCoroutines();
            StartCoroutine(Rotate(angel));
            angel += 90;
            bodyParts[0].Rotate(-Vector3.forward * fTurnRate * Time.deltaTime);
        }

        //go to -90 degrees with left arrow
        if ((Input.GetKeyDown(KeyCode.LeftArrow) || SwipeManager.IsSwipingLeft()) && bodyParts.Count != 0)
        {
            StopAllCoroutines();
            StartCoroutine(Rotate(angel - 180));
            angel -= 90;
            bodyParts[0].Rotate(Vector3.forward * fTurnRate * Time.deltaTime);
        }

        //move the head
        if (bodyParts.Count != 0)
        {
            bodyParts[0].position = bodyParts[0].position + bodyParts[0].forward * 2.0f * Time.deltaTime;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        for (int i = 1; i < bodyParts.Count; i++)
        {
            currentBodyPart = bodyParts[i];
            prevBodyPart    = bodyParts[i - 1];

            //calc distance between current and prev bodyPart
            distance = Vector3.Distance(prevBodyPart.position, currentBodyPart.position);

            //previous part position
            Vector3 newPosition = prevBodyPart.position;

            //lock the y to prevent bodypart from moving up
            newPosition.y = bodyParts[0].position.y;

            //calc time delta
            float dTime = Time.deltaTime * (distance / minDistance) * currentSpeed;

            //keep time delta small to prevent slow movement (frame drop)
            if (dTime > 0.5f)
            {
                dTime = 0.5f;
            }

            //move between current position and new position
            currentBodyPart.position = Vector3.Slerp(currentBodyPart.position, newPosition, dTime);

            //rotate current body part
            currentBodyPart.rotation = Quaternion.Slerp(currentBodyPart.rotation, prevBodyPart.rotation, dTime);
        }
    }
        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();
                    }
                }
            }
        }