<commit_before>﻿using UnityEngine;
using System.Collections;

public class gunMover : MonoBehaviour {

    Rigidbody rb;

    /// <summary>
    /// sensibility of moving
    /// </summary>
    public float speed;

    public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
    public RotationAxes axes = RotationAxes.MouseXAndY;
    public float sensitivityX = 15F;
    public float sensitivityY = 15F;
    public float minimumX = -360F;
    public float maximumX = 360F;
    public float minimumY = -60F;
    public float maximumY = 60F;
    private float rotationY = 0F;
    private float offsetX;

    /// <summary>
    /// intensity of moving forward (W)
    /// </summary>
    private float moveForward = 0;

    /// <summary>
    /// intensity of moving backward (S)
    /// </summary>
    private float moveBackward = 0;

    /// <summary>
    /// set the max speed of the gun
    /// </summary>
    public float maxSpeed;


    void Update()
    {
        if (!PauseGame.gamePaused)
        {
            if (axes == RotationAxes.MouseXAndY)
            {
                float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;

                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

                transform.localEulerAngles = new Vector3(0, rotationX, rotationY);
            }
            else if (axes == RotationAxes.MouseX)
            {
                transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

                transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
            }
        }
    }

    void Start()
    {
        // Make the rigid body not change rotation
        rb = GetComponent<Rigidbody>();
        if (rb)
            rb.freezeRotation = true;
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (!PauseGame.gamePaused)
        {
            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))
            {
                //I memorize the offset generated by pressing the key (W-A-S-D or arrows)

                moveForward = Input.GetAxis("Vertical");
                moveBackward = -Input.GetAxis("Horizontal");

                ///Create the vector3 generated by the offset before
                Vector3 v3 = new Vector3(moveForward, 0.0f, moveBackward);

                //movement relative to the direction of camera (for example, if we press W we'll go forward to the current camera view)
                //the y is set to 0 otherwise the gun takes the fly...
                v3 = rb.transform.TransformDirection(v3.x,0.0f,v3.z); 

                ///apply the vector 3 summed with the previous values of the gun's transform at the transform
                //transform.position = new Vector3(transform.position.x + moveForward,
                //transform.position.y, transform.position.z + moveBackward);
                ///if W is not pressed, stop the force applied to the gun
                /////the y is set to 0 otherwise the gun takes the fly...
                rb.AddForce(v3.x * speed, 0.0f, v3.z * speed);

                //max velocity ifs , if the velocity is faster than maxspeed (if moving forward) or -maxspeed (if moving backward) set the velocity to maxspeed if already positive (moving forward) or to -maxspeed if already negative (moving backward)
                if (rb.velocity.x > maxSpeed) rb.velocity = new Vector3(maxSpeed, rb.velocity.y, rb.velocity.z);
                if (rb.velocity.x < -maxSpeed) rb.velocity = new Vector3(-maxSpeed, rb.velocity.y, rb.velocity.z);

                if (rb.velocity.y > maxSpeed) rb.velocity = new Vector3(rb.velocity.x, maxSpeed, rb.velocity.z);
                if (rb.velocity.y < -maxSpeed) rb.velocity = new Vector3(rb.velocity.x, -maxSpeed, rb.velocity.z);

                if (rb.velocity.z > maxSpeed) rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, maxSpeed);
                if (rb.velocity.z < -maxSpeed) rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, -maxSpeed);

                Debug.Log("for: " + moveForward);<commit_msg>movement relative to the camera view, yeee<commit_after>﻿using UnityEngine;
using System.Collections;

public class gunMover : MonoBehaviour {

    Rigidbody rb;

    /// <summary>
    /// sensibility of moving
    /// </summary>
    public float speed;

    public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
    public RotationAxes axes = RotationAxes.MouseXAndY;
    public float sensitivityX = 15F;
    public float sensitivityY = 15F;
    public float minimumX = -360F;
    public float maximumX = 360F;
    public float minimumY = -60F;
    public float maximumY = 60F;
    private float rotationY = 0F;
    private float offsetX;

    /// <summary>
    /// intensity of moving forward (W)
    /// </summary>
    private float moveForward = 0;

    /// <summary>
    /// intensity of moving backward (S)
    /// </summary>
    private float moveBackward = 0;

    /// <summary>
    /// set the max speed of the gun
    /// </summary>
    public float maxSpeed;


    void Update()
    {
        if (!PauseGame.gamePaused)
        {
            if (axes == RotationAxes.MouseXAndY)
            {
                float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX;

                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

                transform.localEulerAngles = new Vector3(0, rotationX, rotationY);
            }
            else if (axes == RotationAxes.MouseX)
            {
                transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
                rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);

                transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
            }
        }
    }

    void Start()
    {
        // Make the rigid body not change rotation
        rb = GetComponent<Rigidbody>();
        if (rb)
            rb.freezeRotation = true;
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (!PauseGame.gamePaused)
        {
            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D))
            {
                //I memorize the offset generated by pressing the key (W-A-S-D or arrows)

                moveForward = Input.GetAxis("Vertical");
                moveBackward = -Input.GetAxis("Horizontal");

                ///Create the vector3 generated by the offset before
                Vector3 v3 = new Vector3(moveForward, 0.0f, moveBackward);

                //movement relative to the direction of camera (for example, if we press W we'll go forward to the current camera view)
                //the y is set to 0 otherwise the gun takes the fly...
                v3 = rb.transform.TransformDirection(v3.x,0.0f,v3.z); 

                ///apply the vector 3 summed with the previous values of the gun's transform at the transform
                //transform.position = new Vector3(transform.position.x + moveForward,
                //transform.position.y, transform.position.z + moveBackward);
                ///if W is not pressed, stop the force applied to the gun
                /////the y is set to 0 otherwise the gun takes the fly... 
                rb.AddForce(v3.x * speed, 0.0f, v3.z * speed);

                //max velocity ifs , if the velocity is faster than maxspeed (if moving forward) or -maxspeed (if moving backward) set the velocity to maxspeed if already positive (moving forward) or to -maxspeed if already negative (moving backward)
                if (rb.velocity.x > maxSpeed) rb.velocity = new Vector3(maxSpeed, rb.velocity.y, rb.velocity.z);
                if (rb.velocity.x < -maxSpeed) rb.velocity = new Vector3(-maxSpeed, rb.velocity.y, rb.velocity.z);

                if (rb.velocity.y > maxSpeed) rb.velocity = new Vector3(rb.velocity.x, maxSpeed, rb.velocity.z);
                if (rb.velocity.y < -maxSpeed) rb.velocity = new Vector3(rb.velocity.x, -maxSpeed, rb.velocity.z);

                if (rb.velocity.z > maxSpeed) rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, maxSpeed);
                if (rb.velocity.z < -maxSpeed) rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, -maxSpeed);

                Debug.Log("for: " + moveForward);
{'fraction_non_alphanumeric': 0.10707865168539325, 'fraction_numerical': 0.01146067415730337, 'mean_word_length': 1.955179282868526, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4540115', 'n_tokens_mistral': 2714, 'n_tokens_neox': 2476, 'n_words': 761}