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

public class HeroMovement : MonoBehaviour {

    [HideInInspector] public bool facingRight = true;
    [HideInInspector] public bool jump = false;
    [HideInInspector] public bool punchRange = false;
    [HideInInspector] public bool attack = false;
    [HideInInspector] public int myLayer;

    [HideInInspector] public bool inRange = false;

    public int playerNumber = 0;
    public int inputNumber = -1;

    public float moveForce = 400f;
    [HideInInspector] public float currentMoveForce;
    public float maxSpeed = 12f;
    [HideInInspector] public float currentMaxSpeed;
    public float jumpForce = 1800f;
    public Transform groundCheck;
    public Transform punchCheck;

    [HideInInspector] public bool grounded = false;
    //private Animator anim;
    private Rigidbody2D rb2d;
    private AttributeController myAttributes;
    [HideInInspector] public float currentSpeed;
    private bool doublejump = false;
    private bool candoublejump = false;
    private bool isKitty = false;
    // Use this for initialization
    void Awake()
    {
        //anim = GetComponent<Animator>();
        rb2d = GetComponent<Rigidbody2D>();
        myAttributes = GetComponent<AttributeController>();
        currentMoveForce = moveForce;
        currentMaxSpeed = maxSpeed;
        myLayer = gameObject.layer;
        string name = gameObject.name;
        if (name == "Kitty"){
            isKitty = true;
        }
    }

    // Update is called once per frame
    void Update()
    {
        grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));

        if (myAttributes.knockbacked && grounded && Time.time + myAttributes.invincibiltyLength - 0.25f >= myAttributes.nextVulnerable)
        {
            myAttributes.knockbacked = false;
        }

        if (Input.GetButtonDown("Jump_" + inputNumber))
        {
            if (grounded)
            {
                jump = true;
            }
            else if (candoublejump && isKitty)
            {
                doublejump = true;
            }
        }
      
        if (Input.GetButtonDown("Fire3"))
        {
            attack = true;
        }

    }

    //Does the actions during the frame the hero has to do, in this case jumping, flipping and attacking
    void FixedUpdate()
    {
        //Physics2D.IgnoreLayerCollision(8, 11, (rb2d.velocity.y > 0.0f)); // Doesnt work for multiplayer
        currentSpeed = Input.GetAxisRaw("Horizontal_" + inputNumber);

        //anim.SetFloat("Speed", Mathf.Abs(h));

        if (!myAttributes.knockbacked && currentSpeed * rb2d.velocity.x < currentMaxSpeed)
            rb2d.AddForce(Vector2.right * currentSpeed * currentMoveForce);

        if (Mathf.Abs(rb2d.velocity.x) > currentMaxSpeed)
            rb2d.velocity = new Vector2(Mathf.Sign(rb2d.velocity.x) * currentMaxSpeed, rb2d.velocity.y);

        if (currentSpeed > 0 && !facingRight)
            Flip();
        else if (currentSpeed < 0 && facingRight)
            Flip();

        if (jump)
        {
            //anim.SetTrigger("Jump");
            //rb2d.AddForce(new Vector2(0, 10), ForceMode2D.Impulse);
            rb2d.AddForce(new Vector2(0f, jumpForce));<commit_msg>punch is based on player number<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeroMovement : MonoBehaviour {

    [HideInInspector] public bool facingRight = true;
    [HideInInspector] public bool jump = false;
    [HideInInspector] public bool punchRange = false;
    [HideInInspector] public bool attack = false;
    [HideInInspector] public int myLayer;

    [HideInInspector] public bool inRange = false;

    public int playerNumber = 0;
    public int inputNumber = -1;

    public float moveForce = 400f;
    [HideInInspector] public float currentMoveForce;
    public float maxSpeed = 12f;
    [HideInInspector] public float currentMaxSpeed;
    public float jumpForce = 1800f;
    public Transform groundCheck;
    public Transform punchCheck;

    [HideInInspector] public bool grounded = false;
    //private Animator anim;
    private Rigidbody2D rb2d;
    private AttributeController myAttributes;
    [HideInInspector] public float currentSpeed;
    private bool doublejump = false;
    private bool candoublejump = false;
    private bool isKitty = false;
    // Use this for initialization
    void Awake()
    {
        //anim = GetComponent<Animator>();
        rb2d = GetComponent<Rigidbody2D>();
        myAttributes = GetComponent<AttributeController>();
        currentMoveForce = moveForce;
        currentMaxSpeed = maxSpeed;
        myLayer = gameObject.layer;
        string name = gameObject.name;
        if (name == "Kitty"){
            isKitty = true;
        }
    }

    // Update is called once per frame
    void Update()
    {
        grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));

        if (myAttributes.knockbacked && grounded && Time.time + myAttributes.invincibiltyLength - 0.25f >= myAttributes.nextVulnerable)
        {
            myAttributes.knockbacked = false;
        }

        if (Input.GetButtonDown("Jump_" + inputNumber))
        {
            if (grounded)
            {
                jump = true;
            }
            else if (candoublejump && isKitty)
            {
                doublejump = true;
            }
        }
      
        if (Input.GetButtonDown("Fire3_" + inputNumber))
        {
            attack = true;
        }

    }

    //Does the actions during the frame the hero has to do, in this case jumping, flipping and attacking
    void FixedUpdate()
    {
        //Physics2D.IgnoreLayerCollision(8, 11, (rb2d.velocity.y > 0.0f)); // Doesnt work for multiplayer
        currentSpeed = Input.GetAxisRaw("Horizontal_" + inputNumber);

        //anim.SetFloat("Speed", Mathf.Abs(h));

        if (!myAttributes.knockbacked && currentSpeed * rb2d.velocity.x < currentMaxSpeed)
            rb2d.AddForce(Vector2.right * currentSpeed * currentMoveForce);

        if (Mathf.Abs(rb2d.velocity.x) > currentMaxSpeed)
            rb2d.velocity = new Vector2(Mathf.Sign(rb2d.velocity.x) * currentMaxSpeed, rb2d.velocity.y);

        if (currentSpeed > 0 && !facingRight)
            Flip();
        else if (currentSpeed < 0 && facingRight)
            Flip();

        if (jump)
        {
            //anim.SetTrigger("Jump");
            //rb2d.AddForce(new Vector2(0, 10), ForceMode2D.Impulse);
            rb2d.AddForce(new Vector2(0f, jumpForce));
{'fraction_non_alphanumeric': 0.09687078904027549, 'fraction_numerical': 0.014073963168138942, 'mean_word_length': 2.3908629441624365, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4805895', 'n_tokens_mistral': 2008, 'n_tokens_neox': 1872, 'n_words': 481}