Exemplo n.º 1
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
     {
         Move(currentDirection);
     }
     else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
     {
         Move(currentDirection.GetNextClockwise());
     }
     else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
     {
         Move(currentDirection.GetOpposite());
     }
     else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
     {
         Move(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.Q))
     {
         Look(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.E))
     {
         Look(currentDirection.GetNextClockwise());
     }
 }
Exemplo n.º 2
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W) && !gameOver)
     {
         Move(currentDirection);
     }
     else if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D) && !gameOver)
     {
         Move(currentDirection.GetNextClockwise());
     }
     else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S) && !gameOver)
     {
         Move(currentDirection.GetOpposite());
     }
     else if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A) && !gameOver)
     {
         Move(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.Q) && !gameOver)
     {
         Rotate(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.E) && !gameOver)
     {
         Rotate(currentDirection.GetNextClockwise());
     }
 }
Exemplo n.º 3
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.UpArrow))           // NOTE Should use axes keys
     {
         Move(currentDirection);
     }
     else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
     {
         Move(currentDirection.GetOposite());
     }
     else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
     {
         Move(currentDirection.GetNextClockwise());
     }
     else if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.LeftArrow))
     {
         Move(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.A))
     {
         Rotate(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.E))
     {
         Rotate(currentDirection.GetNextClockwise());
     }
 }
Exemplo n.º 4
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Joystick1Button3))
     {
         Move(currentDirection);
     }
     else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.Joystick1Button1))
     {
         Move(currentDirection.GetNextClockwise());
     }
     else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.Joystick1Button0))
     {
         Move(currentDirection.GetOpposite());
     }
     else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.Joystick1Button2))
     {
         Move(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.Joystick1Button4))
     {
         Rotate(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.Joystick1Button5))
     {
         Rotate(currentDirection.GetNextClockwise());
     }
 }
Exemplo n.º 5
0
 private void Update()
 {
     GunCheck();
     ColorGun();
     if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
     {
         Move(currentDirection);
     }
     else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
     {
         Move(currentDirection.GetNextClockwise());
     }
     else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
     {
         Move(currentDirection.GetOpposite());
     }
     else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
     {
         Move(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.Q))
     {
         Rotate(currentDirection.GetNextCounterclockwise());
     }
     else if (Input.GetKeyDown(KeyCode.E))
     {
         Rotate(currentDirection.GetNextClockwise());
     }
     else if (Input.GetKeyDown(KeyCode.Space))
     {
         StartCoroutine(Shoot());
     }
 }
Exemplo n.º 6
0
 // Update is called once per frame
 void Update()
 {
     if (canMove)
     {
         if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
         {
             Move(currentDirection);
         }
         else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
         {
             Move(currentDirection.GetNextClockwise());
         }
         else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
         {
             Move(currentDirection.GetOpposite());
         }
         else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
         {
             Move(currentDirection.GetNextCounterclockwise());
         }
         //else if (Input.GetKeyDown(KeyCode.Q))
         //{
         //    Rotate(currentDirection.GetNextCounterclockwise());
         //}
         //else if (Input.GetKeyDown(KeyCode.E))
         //{
         //    Rotate(currentDirection.GetNextClockwise());
         //}
     }
 }
Exemplo n.º 7
0
    void Update()
    {
        /*
         * if (!isLocalPlayer)
         * {
         *      return;
         * }
         */

        if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
        {
            Move(currentDirection);
        }
        else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
        {
            Move(currentDirection.GetNextClockwise());
        }
        else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
        {
            Move(currentDirection.GetOpposite());
        }
        else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
        {
            Move(currentDirection.GetNextCounterclockwise());
        }

        /*
         * var x = Input.GetAxis("Horizontal");
         * var z = Input.GetAxis("Vertical");
         */

        if (Input.GetKeyDown(KeyCode.Q))
        {
            Look(currentDirection.GetNextCounterclockwise());
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            Look(currentDirection.GetNextClockwise());
        }
    }
Exemplo n.º 8
0
    void Update()
    {
        //Vector2 v3 = new Vector3(0.0f, Input.GetAxis("Horizontal"), 0.0f);//put in y instead
        //transform.Rotate(v3 * rotateSpeed * Time.deltaTime);
        controller = GetComponent <CharacterController> ();
        //if (controller.isGrounded) { //*FIX DISSSSS**
        //	Debug.Log ("In grounded");

        moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Vertical"));

        if (deltaMoveInput)
        {
            moveDirection = new Vector3(0f, 0.0f, 1f);
        }

        moveDirection  = transform.TransformDirection(moveDirection);
        moveDirection *= speed;

        moveDirection.y -= gravity * Time.deltaTime;

        if (canMoveAround)
        {
            controller.Move(moveDirection * Time.deltaTime);
        }

        if (isTurning)
        {
            UpdateTurning();
        }
        else    // ignore additional input to turn if a turn is already in progress
        {
            if (canMoveAround)
            {
                if (Input.GetKeyDown(KeyCode.Q) || mustTurnLeft)
                {
                    //transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
                    Rotate(currentDirection.GetNextCounterclockwise());
                }
                if (Input.GetKeyDown(KeyCode.E) || mustTurnRight)
                {
                    //transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
                    Rotate(currentDirection.GetNextClockwise());
                }
            }
        }
    }
Exemplo n.º 9
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        var x = Input.GetAxis("Horizontal") * Time.deltaTime * 150.0f;
        var z = Input.GetAxis("Vertical") * Time.deltaTime * 3.0f;

        if (Input.GetKeyDown(KeyCode.Q))
        {
            Rotate(currentDirection.GetNextCounterclockwise());
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            Rotate(currentDirection.GetNextClockwise());
        }

        transform.Rotate(0, x, 0);
        transform.Translate(0, 0, z);
    }
Exemplo n.º 10
0
    // Update is called once per frame
    void FixedUpdate()
    {
        bool ready = true;
        // Vector3 MoveDirection = Vector3.zero;
        // if (GetComponent<CharacterController>().isGrounded)
        //{
        //  MoveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        //    MoveDirection = transform.TransformDirection(MoveDirection);
        //  MoveDirection *= speed;

        Vector3 movement = Vector3.zero;

        movement = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
        if (ready)
        {
            if (movement.x > 0)
            {
                Move(currentDirection.GetNextClockWise());
            }
            else if (movement.x < 0)
            {
                Move(currentDirection.GetNextCounterclockwise());
            }
            else if (movement.z > 0)
            {
                Move(currentDirection);
            }
            else if (movement.z < 0)
            {
                Move(currentDirection.GetOpposite());
            }
            else if (Input.GetKeyDown(KeyCode.Q))
            {
                rotate(currentDirection.GetNextCounterclockwise());
            }
            else if (Input.GetKeyDown(KeyCode.E))
            {
                rotate(currentDirection.GetNextClockWise());
            }
        }
//            if(Input.GetButton("jump1"))
//            {
//                MoveDirection.y = jumpSpeed;
//            }

        //  }
        //    MoveDirection.y -= gravity * Time.deltaTime; //Apply gravity
        // GetComponent<CharacterController>().Move(MoveDirection * Time.deltaTime);


        /*
         * if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
         * {
         *  Move(currentDirection);
         * }
         * else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
         * {
         *  Move(currentDirection.GetNextClockWise());
         * }
         * else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
         * {
         *  Move(currentDirection.GetOpposite());
         * }
         * else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
         * {
         *  Move(currentDirection.GetNextCounterclockwise());
         * }
         * else if (Input.GetKeyDown(KeyCode.Q))
         * {
         *  rotate(currentDirection.GetNextCounterclockwise());
         * }
         * else if (Input.GetKeyDown(KeyCode.E))
         * {
         *  rotate(currentDirection.GetNextClockWise());
         * }
         */
    }
Exemplo n.º 11
0
    void FixedUpdate()
    {
        if (!isInMaze)
        {
            float yStore = moveDirection.y;
            moveDirection   = transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal");
            moveDirection   = moveDirection.normalized * moveSpeed;
            moveDirection.y = yStore;

            //No jump unless on the groud
            if (controller.isGrounded && Input.GetButtonDown("Jump"))
            {
                moveDirection.y = jumpForce;
            }

            moveDirection.y += Physics.gravity.y * gravityScale * Time.deltaTime * 2;
            controller.Move(moveDirection * Time.deltaTime);
        }

        if (mazeSteps == 0)
        {
            stepsLeft.transform.GetChild(0).GetComponent <Text>().text =
                "You have no more Moves, press ESC to reset.";
        }

        if (isInMaze && mazeSteps > 0)
        {
            if (Input.GetButtonDown("Jump"))
            {
                moveDirection.y = jumpForce;
            }

            moveDirection.y += Physics.gravity.y * gravityScale * Time.deltaTime / 4;
            controller.Move(moveDirection * Time.deltaTime);

            game.SetPlayerLocation(this, curCell);

            if (transform.position.y <= 2)
            {
                if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
                {
                    IntVector2 lastCoord = curCell.coordinates;
                    Move(curDirection);
                    IntVector2 currCoord = curCell.coordinates;

                    if (currCoord == new IntVector2(7, 7))
                    {
                        endPanel.SetActive(true);
                    }
                    if (currCoord != lastCoord)
                    {
                        mazeSteps--;
                        stepsLeft.transform.GetChild(0).GetComponent <Text>().text = mazeSteps.ToString();
                        coord = curCell.coordinates;

                        game.ResetMatrix(curCell.coordinates);
                        game.SetPlayerLocation(this, currCoord);
                    }
                    Look(curDirection);
                }
                else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
                {
                    Look(curDirection.GetOpposite());
                }
                else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    Look(curDirection.GetNextCounterclockwise());
                }
                else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
                {
                    Look(curDirection.GetNextClockwise());
                }
            }
        }
    }
Exemplo n.º 12
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
        {
            Move(MazeDirection.North);
            Look(MazeDirection.North);
        }
        else if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
        {
            Move(MazeDirection.East);
            Look(MazeDirection.East);
        }
        else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
        {
            Move(MazeDirection.South);
            Look(MazeDirection.South);
        }
        else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
        {
            Move(MazeDirection.West);
            Look(MazeDirection.West);
        }
        else if (Input.GetKeyDown(KeyCode.Q))
        {
            Look(currentDirection.GetNextCounterclockwise());
        }
        else if (Input.GetKeyDown(KeyCode.E))
        {
            Look(currentDirection.GetNextClockwise());
        }

        // for buttons on UI
        if (Input.GetMouseButtonDown(0) && EventSystem.current.currentSelectedGameObject != null)
        {
            if (EventSystem.current.currentSelectedGameObject.name == "ButtonNorth")
            {
                Move(MazeDirection.North);
                Look(MazeDirection.North);
            }
            else if (EventSystem.current.currentSelectedGameObject.name == "ButtonEast")
            {
                Move(MazeDirection.East);
                Look(MazeDirection.East);
            }
            else if (EventSystem.current.currentSelectedGameObject.name == "ButtonSouth")
            {
                Move(MazeDirection.South);
                Look(MazeDirection.South);
            }
            else if (EventSystem.current.currentSelectedGameObject.name == "ButtonWest")
            {
                Move(MazeDirection.West);
                Look(MazeDirection.West);
            }

            //else if (EventSystem.current.currentSelectedGameObject.name == "ButtonTurnLeft")
            //{
            //    Look(currentDirection.GetNextCounterclockwise());
            //}

            //else if (EventSystem.current.currentSelectedGameObject.name == "ButtonTurnRight")
            //{
            //    Look(currentDirection.GetNextClockwise());
            //}
        }
    }