using UnityEngine;
using System.Collections;

public class JumperAction : MonoBehaviour {
	public float jumpForce;
	public bool isHorizontal;
	public float horizForce;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnTriggerEnter2D( Collider2D trig ){
		//trig.gameObject.rigidbody2D.AddForce(new Vector2(10.0f, 10.0f));

		if(trig.tag == "Player" || trig.tag == "Pushable_Block"){

			if (!isHorizontal){
				trig.gameObject.rigidbody2D.velocity = new Vector2(trig.gameObject.rigidbody2D.velocity.x , jumpForce);
			}else{
				float jumpDir;
				if (trig.gameObject.transform.position.x < transform.position.x){
					jumpDir = -1;
				}else{
					jumpDir = 1;
				}
				
				trig.gameObject.rigidbody2D.velocity = new Vector2(jumpForce*jumpDir, trig.gameObject.rigidbody2D.velocity.y);
			}

		}


	}
}
