MarisaMagicalStudy/Assets/Scripts/FireBullet.cs
2026-02-01 02:35:26 -08:00

36 lines
1.4 KiB
C#

using UnityEngine;
public class FireBullet : PlayerAbility
{
[Header("Stats")]
public float accuracy;
public float bulletLifetime;
public float damage;
public float projectileSpeed;
public enum FireMode {Angled, Offset};
[Header("Projectile")]
public FireMode fireMode = FireMode.Offset;
public float projectileCount;
public Vector2 offset;
public float angle;
[SerializeField] private Projectile projectile;
protected override void AbilityEffects()
{
for (int i = 0; i < projectileCount; i++)
{
Projectile newProjectile = Instantiate(projectile, thisPlayer.firingPointBase.position, transform.rotation);
newProjectile.RotateToTarget(thisPlayer.firingPoint.position);
newProjectile.transform.position = thisPlayer.firingPoint.position; //me when i set the position 3 times in a row. but it's to prevent the bullets firing behind marisa
if (fireMode == FireMode.Offset && projectileCount > 1)
{
newProjectile.transform.position += new Vector3(Random.Range(-offset.x, offset.x), Random.Range(-offset.y, offset.y));
}
newProjectile.damage = damage;
newProjectile.speed = projectileSpeed;
newProjectile.lifetime = bulletLifetime;
newProjectile.transform.Rotate(0, 0, Random.Range(-accuracy, accuracy));
newProjectile.tag = thisPlayer.tag;
}
}
}