예제 #1
0
 private void ActOnTap(float positionY, TouchPhase phase)
 {
     if (phase == TouchPhase.Began)
     {
         if (positionY < _camera.pixelHeight * 0.5f)
         {
             ship.AccelerateDown();
         }
         else
         {
             ship.AccelerateUp();
         }
     }
 }
예제 #2
0
        void Update()
        {
            bool isUpPressed   = (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W));
            bool isDownPressed = (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S));

            if (isUpPressed && !isDownPressed)
            {
                shipMovement.AccelerateUp();
            }
            if (isDownPressed && !isUpPressed)
            {
                shipMovement.AccelerateDown();
            }
            if (Input.GetKeyDown(KeyCode.Space))
            {
                if (shipMovement.IsStopped())
                {
                    SceneManager.LoadScene("MainMenu");
                }
                else
                {
                    shipBehaviour.Shoot();
                }
            }
        }