Add launcheffects for RocketLauncher and GrenadeLauncher

This commit is contained in:
Sofia 2019-08-22 00:47:08 +03:00
parent 81b8f13723
commit 0ec0584c01
5 changed files with 9568 additions and 6 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -23380,12 +23380,12 @@ PrefabInstance:
- target: {fileID: 592487110401094196, guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5,
type: 3}
propertyPath: m_LocalPosition.x
value: 1.54
value: -19.59
objectReference: {fileID: 0}
- target: {fileID: 592487110401094196, guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5,
type: 3}
propertyPath: m_LocalPosition.y
value: 0.35
value: 1.55
objectReference: {fileID: 0}
- target: {fileID: 592487110401094196, guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5,
type: 3}
@ -23435,12 +23435,12 @@ PrefabInstance:
- target: {fileID: 1801310824674407730, guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5,
type: 3}
propertyPath: m_LocalPosition.x
value: -21.04
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1801310824674407730, guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5,
type: 3}
propertyPath: m_LocalPosition.y
value: 2.02
value: 0
objectReference: {fileID: 0}
- target: {fileID: 592487111066334294, guid: 72a58ef1f50bfb946ae1af6e6b9fa1c5,
type: 3}

View File

@ -7,15 +7,23 @@ using Saltosion.OneWeapon.Effects;
namespace Saltosion.OneWeapon.Guns {
public class Gun : MonoBehaviour {
[Header("Essentials")]
public Bullet Bullet;
public SpriteRenderer Sprite;
public Transform BulletHole;
public float MaxCooldown = 0.5f;
public float MinCooldown = 0.2f;
[Header("Effects")]
public Transform BulletHole;
public Bobbing Bobbing;
public ParticleSystem LaunchExplosion;
public CustomLight LaunchLight;
public float LaunchLightIntensity = 2;
public float LaunchLightIntensityDegrade = 2;
private bool IsHeld = false;
private float CurrCooldown = 0;
private float CurrLaunchLight = 0;
private Bullet CurrentBullet;
private bool HasShotBullet = false;
@ -24,6 +32,9 @@ namespace Saltosion.OneWeapon.Guns {
void Start() {
BulletHoleOriginalY = BulletHole.localPosition.y;
if (LaunchExplosion != null) {
LaunchExplosion.Stop();
}
}
void Update() {
@ -36,6 +47,11 @@ namespace Saltosion.OneWeapon.Guns {
CurrentBullet = null;
HasShotBullet = false;
}
if (CurrLaunchLight > 0) {
CurrLaunchLight -= Time.deltaTime * LaunchLightIntensityDegrade;
LaunchLight.LightIntensity = CurrLaunchLight;
}
}
void OnCollisionEnter2D(Collision2D collision) {
@ -58,6 +74,14 @@ namespace Saltosion.OneWeapon.Guns {
} else {
if (CurrCooldown <= 0) {
CurrCooldown = MaxCooldown;
if (LaunchExplosion != null) {
LaunchExplosion.Play();
}
if (LaunchLight != null) {
CurrLaunchLight = LaunchLightIntensity;
LaunchLight.LightIntensity = CurrLaunchLight;
}
Bullet ShotBullet = Instantiate(Bullet, BulletHole.position, new Quaternion());
ShotBullet.Direction = direction.normalized;
ShotBullet.InitialRotation = rotation;

View File

@ -19,13 +19,22 @@ namespace Saltosion.OneWeapon.Utils {
float[] SizeList = new float[500];
Color[] ColorList = new Color[500];
List<int> ToRemove = new List<int>();
for (int i = 0; i < Lights.Count; i++) {
if (Lights[i] == null) {
ToRemove.Add(i);
continue;
}
PosList[i] = Lights[i].transform.position;
IntensityList[i] = Lights[i].LightIntensity;
SizeList[i] = Lights[i].LightSize;
ColorList[i] = Lights[i].LightTint;
}
foreach (int i in ToRemove) {
Lights.RemoveAt(i);
}
Material.SetInt("_LightCount", Lights.Count);
Material.SetVectorArray("_LightLocations", PosList);
Material.SetFloatArray("_LightIntensities", IntensityList);