Constant Weapons
Added script for constant weapons, which can start and stop firing at any time (unless they're reloading) Created Constant Laser Fixed exception when dragging to delete item
This commit is contained in:
parent
b779d7c0af
commit
8629b35fd6
13 changed files with 473 additions and 102 deletions
34
Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs
Normal file
34
Assets/Scripts/Gameplay/Weapons/ConstantLaserManager.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConstantLaserManager : ConstantWeaponEffectManager
|
||||
{
|
||||
public Prototype LaserPrototype;
|
||||
|
||||
private Dictionary<EquippedItem, ConstantLaser> _lasers = new Dictionary<EquippedItem, ConstantLaser>();
|
||||
|
||||
public override void StartFiring(WeaponData data, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
var p = LaserPrototype.Instantiate<ConstantLaser>();
|
||||
p.SourceEntity = source.Entity;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
p.Range = source.Entity.ItemManager.Evaluate(data.Range, item.EquippableItem, source.Entity);
|
||||
var t = p.transform;
|
||||
t.SetParent(barrel);
|
||||
t.forward = barrel.forward;
|
||||
t.position = barrel.position;
|
||||
p.Damage = source.Entity.ItemManager.Evaluate(data.Damage, item.EquippableItem, source.Entity);
|
||||
p.Penetration = source.Entity.ItemManager.Evaluate(data.Penetration, item.EquippableItem, source.Entity);
|
||||
p.Spread = source.Entity.ItemManager.Evaluate(data.DamageSpread, item.EquippableItem, source.Entity);
|
||||
p.DamageType = data.DamageType;
|
||||
_lasers.Add(item, p);
|
||||
}
|
||||
|
||||
public override void StopFiring(EquippedItem item)
|
||||
{
|
||||
_lasers[item].Stop();
|
||||
_lasers.Remove(item);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue