1ea616dd60
Enemy balance, added upgrades, added score, added menu
40 lines
626 B
C#
40 lines
626 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Bullet : MonoBehaviour
|
|
{
|
|
public int speed;
|
|
public Rigidbody2D rb;
|
|
|
|
void Start()
|
|
{
|
|
rb.AddForce(transform.right * speed);
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
if (other.CompareTag("Enemy"))
|
|
{
|
|
DestroyBullet();
|
|
Debug.Log("Enemy damage taken");
|
|
}
|
|
if (other.CompareTag("Obstacle"))
|
|
{
|
|
DestroyBullet();
|
|
Debug.Log("Obstacle detected");
|
|
}
|
|
}
|
|
|
|
void OnBecameInvisible()
|
|
{
|
|
Debug.Log("Invisible bullet");
|
|
DestroyBullet();
|
|
}
|
|
|
|
void DestroyBullet()
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|