i am looking respectfully
This commit is contained in:
parent
3160bff7a3
commit
084aada510
29 changed files with 2891 additions and 482 deletions
41
Assets/Scripts/Projectile.cs
Normal file
41
Assets/Scripts/Projectile.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
public float damage;
|
||||
public float speed;
|
||||
private int currentPierced;
|
||||
public int pierceAmount;
|
||||
public float lifetime;
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
|
||||
public void RotateToTarget(Vector3 target)
|
||||
{
|
||||
transform.Lookat2D(target);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(gameObject, lifetime);
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = transform.right * speed;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage);
|
||||
currentPierced++;
|
||||
if (currentPierced > pierceAmount)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue