literally half of the game
This commit is contained in:
parent
1590b5faa6
commit
b842289076
77 changed files with 11904 additions and 72 deletions
40
Assets/Scripts/Projectiles/Projectile.cs
Normal file
40
Assets/Scripts/Projectiles/Projectile.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
[Header("Base Stats")]
|
||||
public float lifetime;
|
||||
public float damage;
|
||||
|
||||
[Header("Piercing")]
|
||||
public int pierceAmount;
|
||||
public int currentPierce;
|
||||
|
||||
[Header("Movement")]
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
public float speed;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(gameObject, lifetime);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = transform.right * speed;
|
||||
}
|
||||
|
||||
protected void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out CombatEntity isEntity))
|
||||
{
|
||||
currentPierce++;
|
||||
isEntity.TakeDamage(damage);
|
||||
if (currentPierce > pierceAmount) //if 0 then no one pierced. if 1 then can pierce 1 enemy and gets destroyed by second enemy, and so on...
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue