void OnTriggerEnter2D(Collider2D other)
    {
        if (other.name.StartsWith("Ship"))
        {
            sa = GameObject.Find("Ship").transform.GetComponent <ShipActions>();

            sa.shocknow     = true;
            sa.hullcurrent -= getEnemyDamageValue();

            transform.gameObject.GetComponent <Renderer> ().material.color = Color.cyan;

            if (stopAfterShock)
            {
                EnemyMoveForward emf = transform.GetComponent <EnemyMoveForward>();
                emf.stop = true;
            }

            edh.health = 0;
            shocked    = true;
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (readyToShoot && withinAttackDistance())
        {
            sa.hullcurrent -= getEnemyDamageValue();
            Instantiate(bullet, transform.position + getBulletOffset(), transform.rotation);

            readyToShoot = false;

            if (stopAfterShoot)
            {
                EnemyMoveForward emf = transform.GetComponent <EnemyMoveForward>();
                emf.stop = true;
            }

            if (dieAfterShoot)
            {
                EnemyDamageHandler edh = transform.GetComponent <EnemyDamageHandler>();
                edh.health = 0;
            }
        }
    }
Example #3
0
 // Use this for initialization
 void Start()
 {
     emf           = transform.GetComponent <EnemyMoveForward>();
     originalSpeed = emf.maxSpeed;
     attackSpeed   = emf.maxSpeed * speedMultiple;
 }