using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour {

    public float XMoveSpeed = 1.0f;
    public float YPos = -1.0f;
    public GameObject Manager;

    // Use this for initialization
    void Start () {
	    
	}
	
	// Update is called once per frame
	void Update () {
        // 襲ってくる
        transform.position = new Vector3(
        transform.position.x - XMoveSpeed * Time.deltaTime,
        YPos,
        10 + YPos * 0.01f);
        // 左端まで移動しきったら削除
        if (transform.position.x < -20) {
            Destroy(gameObject);
        }
    }
    // プレイヤーに触れたら救助状態
    void OnTriggerEnter2D(Collider2D col) {
        // Debug.Log("接触");
        if (col.gameObject.tag == "Play") {
            Manager.GetComponent<MainManager>().Damage();
        }
    }
}
