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

/// <summary>
/// The script should be attached on BaseballBoy and AnotherBaseballBoy
/// </summary>
public class ThrowBaseball : MonoBehaviour {

    public bool hasBall;
    public bool isAtPlayingPosition;

    public GameObject otherBoy;

    public GameObject item;

    /// <summary>
    /// The time needed for the boy to be upset when not playing baseball.
    /// </summary>
    public float timeTillUpset = 5.0f;

    /// <summary>
    /// The last time when the boy is playing
    /// </summary>
    public float lastTimePlaying;

    /// <summary>
    /// Is the boy playing?
    /// </summary>
    public bool isPlaying;

    /// <summary>
    /// Is the boy upsetting?
    /// </summary>
    public bool isUpset;

	// Use this for initialization
	void Start ()
    {

	}
	
	// Update is called once per frame
	void Update ()
    {
        if (null == item)
        {
            hasBall = false;
            return;
        }

        if (hasBall == true)
        {
            lastTimePlaying = Time.time;
            isPlaying = true;
            throwBall();
        }

        if(hasBall == false && otherBoy.GetComponent<ThrowBaseball>().hasBall == false && Time.time - lastTimePlaying >= timeTillUpset)
        {
            isUpset = true;
        }

        if(item.name != "Baseball")
        {
            item.GetComponent<ItemProperty>().isPickedUp = false;
            item.GetComponent<ItemProperty>().owner = null;
            item = null;
        }

        if(item.name == "Baseball")
        {
            hasBall = true;
        }
	}

    public void throwBall()
    {
        //throw baseball towards otherBoy, probably need a lerp
        float randomNum = Random.Range(0, 1);

        if (randomNum >= 0 && randomNum <= 0.7)
        {
            item.GetComponent<LinearMovement>().messageReceiver = otherBoy;
            item.GetComponent<LinearMovement>().MoveTo(otherBoy);
        }
        //the NPC has a small chance to throw the ball else where

        else if (randomNum > 0.7 && randomNum <= 1)
        {
            item.GetComponent<LinearMovement>().MoveTo(new Vector3(otherBoy.transform.position.x + 60, otherBoy.transform.position.y, otherBoy.transform.position.z));
        }

        item = null;
        hasBall = false;
    }

    void OnBallCatched(GameObject ball)
    {
        hasBall = true;
        item = ball;
    }<commit_msg>BaseBall<commit_after>﻿using UnityEngine;
using System.Collections;

/// <summary>
/// The script should be attached on BaseballBoy and AnotherBaseballBoy
/// </summary>
public class ThrowBaseball : MonoBehaviour {

    public bool hasBall;
    public bool isAtPlayingPosition;

    public GameObject otherBoy;

    public GameObject item;

    /// <summary>
    /// The time needed for the boy to be upset when not playing baseball.
    /// </summary>
    public float timeTillUpset = 5.0f;

    /// <summary>
    /// The last time when the boy is playing
    /// </summary>
    public float lastTimePlaying;

    /// <summary>
    /// Is the boy playing?
    /// </summary>
    public bool isPlaying;

    /// <summary>
    /// Is the boy upsetting?
    /// </summary>
    public bool isUpset;

    private bool isArrived;
	// Use this for initialization
	void Start ()
    {

	}

    // Update is called once per frame
    void Update()
    {
        if (isArrived)
        {
            if (null == item)
            {
                hasBall = false;
                return;
            }

            if (hasBall == true)
            {
                lastTimePlaying = Time.time;
                isPlaying = true;
                throwBall();
            }

            if (hasBall == false && otherBoy.GetComponent<ThrowBaseball>().hasBall == false && Time.time - lastTimePlaying >= timeTillUpset)
            {
                isUpset = true;
            }

            if (item.name != "Baseball")
            {
                item.GetComponent<ItemProperty>().isPickedUp = false;
                item.GetComponent<ItemProperty>().owner = null;
                item = null;
            }

            if (item.name == "Baseball")
            {
                hasBall = true;
            }
        }
    }

    public void throwBall()
    {
        //throw baseball towards otherBoy, probably need a lerp
        float randomNum = Random.Range(0, 1);

        if (randomNum >= 0 && randomNum <= 0.7)
        {
            item.GetComponent<LinearMovement>().messageReceiver = otherBoy;
            item.GetComponent<LinearMovement>().MoveTo(otherBoy);
        }
        //the NPC has a small chance to throw the ball else where

        else if (randomNum > 0.7 && randomNum <= 1)
        {
            item.GetComponent<LinearMovement>().MoveTo(new Vector3(otherBoy.transform.position.x + 60, otherBoy.transform.position.y, otherBoy.transform.position.z));
        }

        item = null;
        hasBall = false;
    }

    void OnBallCatched(GameObject ball)
    {
        hasBall = true;
        item = ball;
    }
    public void Arrived() {
        isArrived = true;
    }
{'fraction_non_alphanumeric': 0.10987942434850252, 'fraction_numerical': 0.005056398288603656, 'mean_word_length': 1.692670157068063, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 41, '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': '4203982', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1413, 'n_words': 387}