StaticEnemy.cs 656 Bytes
Newer Older
Naliwe GS committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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)
	    {
Naliwe GS committed
20
	        Destroy(gameObject);
Naliwe GS committed
21 22 23 24 25 26 27
	    }
	}

    void OnTriggerEnter2D(Collider2D other)
    {
        gameObject.SetActive(false);
        _player.GetComponent<Player>().SetBlinking();
Raphael committed
28
        _player.GetComponent<Player>().Battery -= 8;
Naliwe GS committed
29 30
    }
}