Created
May 6, 2020 07:58
-
-
Save SenpaiRar/f4e19d3697bbbf07dbf82f68a4bab91b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class CircleWeapon : Bullet | |
{ | |
public int DamageValue; | |
public int Speed; | |
public float Lifetime; | |
private void Start(){ | |
StartCoroutine(Lifespan()); | |
} | |
void FixedUpdate(){ | |
transform.Translate(Vector3.forward*Speed*Time.deltaTime, Space.Self); | |
} | |
void OnTriggerEnter(Collider col){ | |
if(col.tag == "Enemy"||col.tag=="Enemy_Bullet"){ | |
col.GetComponent<Entity>().TakeDamage(DamageValue); | |
} | |
} | |
public override int GetDamage(){ | |
return DamageValue; | |
} | |
IEnumerator Lifespan(){ | |
yield return new WaitForSecondsRealtime(Lifetime); | |
Destroy(gameObject); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment