using System.Collections; using System.Collections.Generic; using UnityEngine; using Random = UnityEngine.Random; public class ProjectileManager : InstantWeaponEffectManager { public Prototype ProjectilePrototype; public bool InheritVelocity; public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target, int shotId) { var p = ProjectilePrototype.Instantiate(); var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y]; var barrel = source.GetBarrel(hp); var angle = weapon.Spread / 2; p.ShotId = shotId; p.SourceEntity = source.Entity; p.Velocity = Quaternion.Euler( Random.Range(-angle, angle), Random.Range(-angle, angle), Random.Range(-angle, angle)) * barrel.forward * weapon.Velocity; p.StartPosition = p.transform.position = barrel.position + p.Velocity * (Random.value * Time.deltaTime); if(InheritVelocity) p.Velocity += new Vector3(source.Entity.Velocity.x, 0, source.Entity.Velocity.y); p.Range = weapon.Range; p.Zone = source.Entity.Zone; p.Trail.Clear(); } }