1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Assets.Scripts.API;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Assets.Scripts;
public class SimpleEnnemy : MonoBehaviour
{
private Transform _position;
private GameObject _player;
public float Speed = 2f;
void Start ()
{
_position = GetComponent<Transform>();
_player = GameObject.FindWithTag("Player");
}
void Update ()
{
_position.Translate(new Vector3(Speed * Time.deltaTime * -1, 0, 0));
if (_position.position.x < Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x)
{
gameObject.SetActive(false);
}
}
void OnTriggerEnter2D(Collider2D other)
{
Destroy(gameObject);
_player.GetComponent<Player>().Battery -= 8;
_player.GetComponent<Player>().SetBlinking();
}
}