EndlessRocket/Assets/Scripts/Obstacle.cs
2023-07-30 23:14:41 +05:30

28 lines
809 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Obstacle : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D other){
if(other.tag == "Powerup"){
LevelGeneratorV2.instance.DespawnPickup(other.gameObject);
PlayerController.instance.ActivatePowerup();
return;
}
Debug.Log(other.name);
if(other.tag == "asteroid"){
if(PlayerController.instance.PowerupActive){
PlayerController.instance.SpawnExplosionFX(other.transform.position);
LevelGeneratorV2.instance.DespawnAsteroid(other.gameObject);
DataManager.AddItem("add_asteroid.php");
return;
}
}
PlayerController.instance.GameOver();
}
}