Skip to content
Permalink
f458da139e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
69 lines (54 sloc) 1.34 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DestroyByContact_1 : MonoBehaviour
{
public float health_1 =10;
public void Update()
{
if (health_1 < 1)
{
Destroy(gameObject);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Boundary")
{
return;
}
if (other.tag == "Asteroid")
{
return;
}
if (other.tag == "Ship")
{
HealthScript.healthValue = HealthScript.healthValue - 25;
other.gameObject.SetActive(true);
Destroy(gameObject);
if (HealthScript.healthValue < 1)
{
other.gameObject.SetActive(false);
}
}
if (other.tag == "Shot")
{
ScoreScript.scoreValue += 1;
Destroy(other.gameObject);
health_1 = health_1 - 1;
}
if (other.tag == "Shot_2")
{
ScoreScript.scoreValue += 5;
Destroy(other.gameObject);
health_1 = health_1 - 5;
}
if (other.tag == "Shot_3")
{
ScoreScript.scoreValue += 5;
Destroy(other.gameObject);
health_1 = health_1 - 15;
}
}
}