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

public enum ProjectileState
{
	Windup = 0,
	Airborne = 1,
	Landed = 2
}

public class Projectile : MonoBehaviour
{
	[Header("State Variables")]
	public ProjectileState currState = ProjectileState.Windup;
	public float currTime;
	public float totalThrowTime;
	
	[Header("Tuning Variables")]
	public float speed = 10f;
	public float maxThrowTime = 2f;
	
	public AnimationCurve arc = new AnimationCurve();


	// Use this for initialization
	void Start ()
	{
		
	}
	
	public void StartThrow(float power)
	{
		Debug.Log("Setting projectile power to " + power.ToString("f2"));
		totalThrowTime = power * maxThrowTime;
		currTime = 0f;
		currState = ProjectileState.Airborne;
	}

	// Update is called once per frame
	void Update ()
	{
		switch(currState)
		{
		case ProjectileState.Airborne:
			UpdateAirborne();
			break;
		}
	}

	void UpdateAirborne()
	{
		transform.Translate(transform.up * speed * Time.deltaTime);
		currTime = currTime + Time.deltaTime;
		if (currTime >= totalThrowTime)
			currState = ProjectileState.Landed;
	}
}<commit_msg>Projectile physics that aren't garbage<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum ProjectileState
{
	Windup = 0,
	Airborne = 1,
	Landed = 2,
	Dead = 3
}

public class Projectile : MonoBehaviour
{
	[Header("State Variables")]
	public ProjectileState currState = ProjectileState.Windup;
	public float currTime;
	public float totalThrowTime;
	public float currThrowProgress;
	public Vector3 startPos = new Vector3();
	public Vector3 destPos = new Vector3();
	public Vector3 startScale = new Vector3();
	public Vector3 maxScale = new Vector3();
	
	[Header("Tuning Variables")]
	public float speed = 10f;
	public float minThrowTime = 0.5f;
	public float maxThrowTime = 2f;
	public float maxScaleMod = 1.5f;
	
	public AnimationCurve arc = new AnimationCurve();


	// Use this for initialization
	void Start ()
	{
		
	}
	
	public void StartThrow(float power)
	{
		//Debug.Log("Setting projectile power to " + power.ToString("f2"));
		totalThrowTime = Mathf.Lerp(minThrowTime, maxThrowTime, power);
		float realPower = totalThrowTime / maxThrowTime;
		currTime = 0f;
		currState = ProjectileState.Airborne;
		startPos = transform.position;
		destPos = transform.position + transform.up * totalThrowTime * speed;
		startScale = transform.localScale;
		maxScale = startScale * maxScaleMod * realPower;
	}

	// Update is called once per frame
	void Update ()
	{
		switch(currState)
		{
		case ProjectileState.Airborne:
			UpdateAirborne();
			break;
		}
	}

	void UpdateAirborne()
	{
		currTime = currTime + Time.deltaTime;
		currThrowProgress = currTime / totalThrowTime;
		float scaleProgress = Mathf.SmoothStep(0,1,currThrowProgress);
		float currScaleFactor = 1 - Mathf.Abs(scaleProgress - 0.5f) * 2;
		float posProgress = (Mathf.SmoothStep(0, 1, 0.5f + currThrowProgress / 2) - 0.5f) * 2;
		//Vector3 currPos = Vector3.Lerp(startPos,destPos,posProgress);
		Vector3 currPos = Vector3.Lerp(startPos,destPos,scaleProgress);
		Vector3 currScale = Vector3.Lerp(startScale,maxScale, currScaleFactor);
		transform.position = currPos;
		transform.localScale = currScale;
		//transform.Translate(Vector3.up * speed * Time.deltaTime);

		if (currTime >= totalThrowTime)
			currState = ProjectileState.Landed;
	}

	void OnDrawGizmos()
	{
		if (currState == ProjectileState.Airborne)
		{
			Gizmos.color = Color.blue;
			Gizmos.DrawWireSphere(destPos, 1f);
		}
	}
}
{'fraction_non_alphanumeric': 0.10290386241894559, 'fraction_numerical': 0.014378347899633492, 'mean_word_length': 4.3353383458646615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '94071', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1157, 'n_words': 287}