Skip to content
Permalink
3a8c711b32
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
53 lines (45 sloc) 1.15 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyByContact : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Boundary")
{
return;
}
if (other.tag == "Enemy1")
{
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 += 3;
Destroy(other.gameObject);
Destroy(gameObject);
}
if (other.tag == "Shot_2")
{
ScoreScript.scoreValue += 3;
Destroy(other.gameObject);
Destroy(gameObject);
}
if (other.tag == "Shot_3")
{
ScoreScript.scoreValue += 3;
Destroy(other.gameObject);
Destroy(gameObject);
}
}
}