Skip to content

Instantly share code, notes, and snippets.

@SenpaiRar
Created May 6, 2020 08:40
Show Gist options
  • Save SenpaiRar/e9d56a7d9159ac4e264b10549a0dc867 to your computer and use it in GitHub Desktop.
Save SenpaiRar/e9d56a7d9159ac4e264b10549a0dc867 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Missile_Enemy : Enemy
{
public Entity Target;
public float Speed;
public AudioClip DeathSound;
public int Score;
private void Start()
{
Target = GameObject.FindGameObjectWithTag("Player").GetComponent<Entity>();
}
private void Update()
{
transform.rotation = Quaternion.LookRotation(Target.transform.position - transform.position);
transform.Translate(Vector3.forward * Time.deltaTime*Speed);
}
private void OnTriggerEnter(Collider collision)
{
if (collision.gameObject.tag == "Player")
{
Target.TakeDamage(1);
Destroy(gameObject);
//StartCoroutine(HitFreeze());
}
}
public override void TakeDamage(int T)
{
GameObject.FindGameObjectWithTag("GameController").GetComponent<Score_Manager>().AddScore(Score);
Target.GetComponent<AudioSource>().PlayOneShot(DeathSound);
Destroy(gameObject);
}
public override void SpawnRoutine(Vector3 T)
{
Instantiate(this.gameObject, new Vector3(T.x, 0, T.z), Quaternion.identity);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment