Game/Assets/Scripts/Bomb.cs
2021-01-16 18:29:12 +01:00

37 lines
1.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bomb : MonoBehaviour
{
public GameObject explosion;
public int bombDamage;
public float bombSpeed;
[HideInInspector]
public int pointsPerBomb;
void Update()
{
this.gameObject.transform.Translate(new Vector3(0, -1, 0) * bombSpeed * Time.deltaTime);
}
void OnTriggerEnter2D(Collider2D obj)
{
if(obj.gameObject.tag == "Player")
{
PointsManager.points -= pointsPerBomb;
obj.gameObject.GetComponent<PlayerCarMuvement>().durability -= bombDamage;
Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
Destroy(this.gameObject);
} else if(obj.gameObject.tag =="Shield")
{
Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
Destroy(this.gameObject);
} else if(obj.gameObject.tag =="EndOfTheRoad")
{
PointsManager.points += pointsPerBomb;
Destroy(this.gameObject);
}
}
}