using UnityEngine;
using System.Collections;
using Assets.Scripts;

public class StaticEnemy : MonoBehaviour
{
    private GameObject _player;
    private Transform _position;

	void Start ()
	{
	    _player = GameObject.FindWithTag("Player");
	    _position = GetComponent<Transform>();
	}
	
	void Update ()
    {
	    if (_position.position.x < Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x)
	    {
	        Destroy(gameObject);
	    }
	}

    void OnTriggerEnter2D(Collider2D other)
    {
        gameObject.SetActive(false);
        _player.GetComponent<Player>().SetBlinking();
        _player.GetComponent<Player>().Battery -= 8;
    }
}
