using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof (Rigidbody2D))]
public class SoundWave : PooledObject {

	//private variables
	Rigidbody2D rb;

	//public variables
	public bool goingToRight;
	public int damagePower = 10;
	public int playerID;
	[Range(0f,1f)] public float speed = 1f;

	// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody2D> ();
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		rb.MovePosition(rb.position + (Vector2.right * speed * (goingToRight ? 1f : -1f)));
		Vector3 scale = transform.localScale;
		scale.x = goingToRight ? 1f : -1f;
		transform.localScale = scale;
	}


	void OnTriggerEnter2D(Collider2D coll){
		if (coll.gameObject.CompareTag("Player")) {
			PlayerController playerEnemy = coll.gameObject.GetComponent<PlayerController> ();
			//playerEnemy.AddScore (10);
			//playerEnemy.BeHit (damagePower);
		}
		//Recycle ();
	}
}
