Charged Weapons & Hitscan Weapons

Implemented two new weapon types and created the Railgun (which is both) and accompanying VFX
This commit is contained in:
Reinier Vens 2021-01-30 01:02:11 +00:00
commit 2a0fe34611
36 changed files with 49495 additions and 25 deletions

View file

@ -236,16 +236,21 @@
<e p="ThrusterHardpoint.cs" t="Include" />
<e p="WeaponHardpoint.cs" t="Include" />
<e p="Weapons" t="Include">
<e p="ChargeEffectManager.cs" t="Include" />
<e p="ConstantLaser.cs" t="Include" />
<e p="ConstantLaserManager.cs" t="Include" />
<e p="ConstantWeaponEffectManager.cs" t="Include" />
<e p="GuidedProjectile.cs" t="Include" />
<e p="GuidedProjectileManager.cs" t="Include" />
<e p="HitscanEffect.cs" t="Include" />
<e p="HitscanManager.cs" t="Include" />
<e p="InstantWeaponEffectManager.cs" t="Include" />
<e p="Laser.cs" t="Include" />
<e p="LaserManager.cs" t="Include" />
<e p="ParticleChargeEffect.cs" t="Include" />
<e p="Projectile.cs" t="Include" />
<e p="ProjectileManager.cs" t="Include" />
<e p="WeaponChargeEffect.cs" t="Include" />
</e>
</e>
<e p="Gravity.cs" t="Include" />

View file

@ -726,6 +726,11 @@
<Compile Include="Assets\Scripts\Gameplay\RadiatorHardpoint.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\ConstantLaserManager.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\ConstantLaser.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\ChargeEffectManager.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\ParticleChargeEffect.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\WeaponChargeEffect.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\HitscanManager.cs" />
<Compile Include="Assets\Scripts\Gameplay\Weapons\HitscanEffect.cs" />
<None Include="Assets\com.unity.uiextensions\Runtime\Resources\Shaders\UIAdditive.shader" />
<None Include="Assets\TextMesh Pro\Resources\Shaders\TMPro.cginc" />
<None Include="Assets\TextMesh Pro\Resources\Shaders\TMP_SDF-Mobile Overlay.shader" />

View file

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dithered Particle Blob
m_Shader: {fileID: 4800000, guid: 46776b9fa35a437448f683f31b04d68d, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 014f8223958fab24583f73350dca0c8c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 47.937256, g: 47.937256, b: 47.937256, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 242a72fcf2cf3cd4b8529d07dff9c18d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -7,7 +7,7 @@ Material:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dithered Particle
m_Name: Dithered Particle Mote
m_Shader: {fileID: 4800000, guid: 46776b9fa35a437448f683f31b04d68d, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4

View file

@ -0,0 +1,78 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dithered Particle Ring
m_Shader: {fileID: 4800000, guid: 46776b9fa35a437448f683f31b04d68d, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 6637e57ef9fa8254a9ba89c991f9d62e, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 5.992157, g: 5.992157, b: 5.992157, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c743050056b7f9a409136c378f3f62b8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View file

@ -73,6 +73,6 @@ Material:
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 15.999998, g: 15.999998, b: 15.999998, a: 1}
- _Color: {r: 63.999992, g: 63.999992, b: 63.999992, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View file

@ -0,0 +1,98 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ExplosionDistortionBlue
m_Shader: {fileID: 211, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: EFFECT_BUMP _ALPHABLEND_ON _COLOROVERLAY_ON _FADING_ON _NORMALMAP
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 2800000, guid: b7de68a779f91264e8da00162a6b7168, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 2800000, guid: 492f3349f92767645a752364a5d18422, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 492f3349f92767645a752364a5d18422, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendOp: 0
- _BumpScale: 1
- _CameraFadingEnabled: 0
- _CameraFarFadeDistance: 2
- _CameraNearFadeDistance: 1
- _ColorMode: 3
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionBlend: 0.552
- _DistortionEnabled: 1
- _DistortionStrength: 13.14
- _DistortionStrengthScaled: 1.314
- _DstBlend: 10
- _EmissionEnabled: 0
- _FlipbookMode: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _LightingEnabled: 0
- _Metallic: 0
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 1
- _SoftParticlesFarFadeDistance: 1
- _SoftParticlesNearFadeDistance: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 0.43568492, g: 0.54840267, b: 1.1887974, a: 1}
- _ColorAddSubDiff: {r: 1, g: 0, b: 0, a: 0}
- _EmissionColor: {r: 0.5, g: 0.33138573, b: 0.2287736, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 1, b: 0, a: 0}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 681df1d8031e0774b9dc7c3ee0728458
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,97 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: FireExplosionBlue
m_Shader: {fileID: 4800000, guid: 46776b9fa35a437448f683f31b04d68d, type: 3}
m_ShaderKeywords: _ALPHABLEND_ON _EMISSION _FADING_ON _REQUIRE_UV2
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 2800000, guid: 59459fa5f4874d34c8a955afad00260b, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 409ef26b64696f340b2f62b41d2fc11f, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BlendOp: 0
- _BumpScale: 1
- _CameraFadingEnabled: 0
- _CameraFarFadeDistance: 2
- _CameraNearFadeDistance: 1
- _ColorMode: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DistortionBlend: 0.5
- _DistortionEnabled: 0
- _DistortionStrength: 1
- _DistortionStrengthScaled: 0
- _DstBlend: 10
- _EmissionEnabled: 1
- _FlipbookMode: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _LightingEnabled: 0
- _Metallic: 0
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 1
- _SoftParticlesFarFadeDistance: 4
- _SoftParticlesNearFadeDistance: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 2.509804, g: 2.509804, b: 23.968628, a: 1}
- _ColorAddSubDiff: {r: -1, g: 1, b: 0, a: 0}
- _EmissionColor: {r: 2.9960785, g: 0.972549, b: 0.36078432, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0.25, b: 0, a: 0}
m_BuildTextureStacks: []

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b2b9914fda5088a4d833db5a6f05c9d6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 57ac85c583dd3cf4eb11d09aa058e940
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7e93c4b7591a8b24e886261e8bb2ee7c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -17475,7 +17475,7 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 55.675
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
@ -18331,7 +18331,7 @@ PrefabInstance:
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 60.98
value: 0
objectReference: {fileID: 0}
- target: {fileID: 878382121558056004, guid: 2758dfa2744d7ad4d8877545189d116e,
type: 3}

View file

@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChargeEffectManager : MonoBehaviour
{
public Prototype EffectPrototype;
private Dictionary<ChargedWeapon, WeaponChargeEffect> ActiveEffects = new Dictionary<ChargedWeapon, WeaponChargeEffect>();
public void StartCharging(ChargedWeapon weapon, EquippedItem item, EntityInstance source)
{
var effect = EffectPrototype.Instantiate<WeaponChargeEffect>();
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
var barrel = source.GetBarrel(hp);
var t = effect.transform;
t.SetParent(barrel);
t.forward = barrel.forward;
t.position = barrel.position;
effect.Weapon = weapon;
ActiveEffects[weapon] = effect;
}
public void StopCharging(ChargedWeapon weapon)
{
ActiveEffects[weapon].StopCharging();
}
public void Charged(ChargedWeapon weapon)
{
ActiveEffects[weapon].Charged();
}
public void Failed(ChargedWeapon weapon)
{
ActiveEffects[weapon].Failed();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: acaf148dd74205a4098665bb4be3f3a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: 70
icon: {instanceID: 0}
userData:
assetBundleName:

View file

@ -0,0 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HitscanEffect : MonoBehaviour
{
public float Duration;
public AnimationCurve IntensityCurve;
public LineRenderer Line;
public ParticleSystem LineEffect;
public Prototype HitEffect;
public Zone Zone { get; set; }
public float Damage { get; set; }
public float Penetration { get; set; }
public float Spread { get; set; }
public DamageType DamageType { get; set; }
public Entity SourceEntity { get; set; }
public float Range { get; set; }
private float _startTime;
private bool _active = false;
public void Fire()
{
_startTime = Time.time;
RaycastHit hit;
if (Physics.Raycast(new Ray(transform.position, transform.forward), out hit, Range, 1))
{
var hull = hit.collider.GetComponent<HullCollider>();
if (hull)
{
if (hull.Entity != SourceEntity)
{
hull.SendHit(Damage, Penetration, Spread, DamageType, SourceEntity, hit, transform.forward);
}
}
var length = (hit.point - transform.position).magnitude;
Line.SetPosition(1, Vector3.forward * length);
var emission = LineEffect.emission;
emission.rateOverTimeMultiplier = length;
var shape = LineEffect.shape;
shape.position = Vector3.forward * (length / 2);
shape.scale = Vector3.one * (length / 2);
}
else
{
Line.SetPosition(1, Vector3.forward * Range);
var emission = LineEffect.emission;
emission.rateOverTimeMultiplier = Range;
var shape = LineEffect.shape;
shape.position = Vector3.forward * (Range / 2);
shape.scale = Vector3.one * (Range / 2);
}
LineEffect.Play(true);
_active = true;
}
void Update()
{
if (!_active) return;
var lerp = (Time.time - _startTime) / Duration;
if (lerp > 1)
{
GetComponent<Prototype>().ReturnToPool();
return;
}
Line.widthMultiplier = IntensityCurve.Evaluate(lerp);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8555514e892b2c438fe085da1fdf89d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
public class HitscanManager : InstantWeaponEffectManager
{
public Prototype Prototype;
public override void Fire(WeaponData data, EquippedItem item, EntityInstance source, EntityInstance target)
{
var p = Prototype.Instantiate<HitscanEffect>();
p.SourceEntity = source.Entity;
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
var barrel = source.GetBarrel(hp);
var t = p.transform;
t.position = barrel.position;
t.forward = barrel.forward;
p.Range = source.Entity.ItemManager.Evaluate(data.Range, item.EquippableItem, source.Entity);
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;
p.Zone = source.Entity.Zone;
p.Fire();
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 90fe995fff18457987112f6f96b45a17
timeCreated: 1611954267

View file

@ -5,4 +5,4 @@ using UnityEngine;
public abstract class InstantWeaponEffectManager : MonoBehaviour
{
public abstract void Fire(WeaponData data, EquippedItem item, EntityInstance source, EntityInstance target);
}
}

View file

@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParticleChargeEffect : WeaponChargeEffect
{
public ParticleSystem ChargeEffect;
public ParticleSystem OverchargeEffect;
public ParticleSystem FailureEffect;
private float _charge;
private bool _overloaded;
private void OnEnable()
{
ChargeEffect.Stop(true);
OverchargeEffect.Stop(true);
FailureEffect.Stop(true);
ChargeEffect.Clear(true);
OverchargeEffect.Clear(true);
FailureEffect.Clear(true);
ChargeEffect.Play(true);
ChargeEffect.enableEmission = true;
_overloaded = false;
_charge = 0;
}
public override void StopCharging()
{
if (_overloaded)
OverchargeEffect.enableEmission = false;
else
ChargeEffect.enableEmission = false;
StartCoroutine(Kill());
}
public override void Charged()
{
ChargeEffect.enableEmission = false;
OverchargeEffect.Play(true);
OverchargeEffect.enableEmission = true;
_overloaded = true;
}
public override void Failed()
{
OverchargeEffect.enableEmission = false;
FailureEffect.Play(true);
}
private void Update()
{
if (Weapon == null) return;
_charge = Weapon.Charge;
if (!_overloaded)
{
ChargeEffect.playbackSpeed = _charge;
}
}
IEnumerator Kill()
{
while (ChargeEffect.particleCount > 0 || OverchargeEffect.particleCount > 0 || FailureEffect.particleCount > 0)
{
yield return null;
}
GetComponent<Prototype>().ReturnToPool();
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d17593d3a68cb7b48905eb55ea270238
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -55,13 +55,6 @@ public class Projectile : MonoBehaviour
hull.SendHit(Damage, Penetration, Spread, DamageType, SourceEntity, hit, Velocity.normalized);
transform.position = hit.point;
StartCoroutine(Kill());
if (HitEffect != null)
{
var t = HitEffect.Instantiate<Transform>();
t.SetParent(hit.collider.transform);
t.position = hit.point;
return;
}
}
}
else// if (hit.transform.gameObject.layer == 1)

View file

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: 60
icon: {instanceID: 0}
userData:
assetBundleName:

View file

@ -0,0 +1,10 @@
using UnityEngine;
public abstract class WeaponChargeEffect : MonoBehaviour
{
public ChargedWeapon Weapon { get; set; }
public abstract void StopCharging();
public abstract void Charged();
public abstract void Failed();
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 788d655faf774be58c5918914b610e01
timeCreated: 1611952470

View file

@ -220,6 +220,18 @@ public class SectorRenderer : MonoBehaviour
instantWeapon.OnFire += () =>
_instantWeaponManagers[data].Fire(data, item, instance, entity.Target.Value != null ? EntityInstances[entity.Target.Value] : null);
if (behavior is ChargedWeapon chargedWeapon)
{
var chargeManager = _instantWeaponManagers[data].GetComponent<ChargeEffectManager>();
if (chargeManager)
{
chargedWeapon.OnStartCharging += () => chargeManager.StartCharging(chargedWeapon, item, instance);
chargedWeapon.OnStopCharging += () => chargeManager.StopCharging(chargedWeapon);
chargedWeapon.OnCharged += () => chargeManager.Charged(chargedWeapon);
chargedWeapon.OnFailed += () => chargeManager.Failed(chargedWeapon);
}
}
}
if (behavior is ConstantWeapon constantWeapon)

View file

@ -9,19 +9,19 @@ using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ChargedWeaponData : InstantWeaponData
{
[InspectableField, JsonProperty("chargeTime"), Key(13), RuntimeInspectable]
[InspectableField, JsonProperty("chargeTime"), Key(16), RuntimeInspectable]
public PerformanceStat ChargeTime = new PerformanceStat();
[InspectableField, JsonProperty("chargeEnergy"), Key(14), RuntimeInspectable]
[InspectableField, JsonProperty("chargeEnergy"), Key(17), RuntimeInspectable]
public PerformanceStat ChargeEnergy = new PerformanceStat();
[InspectableField, JsonProperty("canFireEarly"), Key(15)]
[InspectableField, JsonProperty("canFireEarly"), Key(18)]
public bool CanFireEarly;
[InspectableField, JsonProperty("failureCharge"), Key(16)]
[InspectableField, JsonProperty("failureCharge"), Key(19)]
public float FailureCharge;
[InspectableField, JsonProperty("failureDamage"), Key(17)]
[InspectableField, JsonProperty("failureDamage"), Key(20)]
public float FailureDamage;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
@ -38,6 +38,8 @@ public class ChargedWeapon : InstantWeapon
private float _charge;
private float _progress;
public event Action OnStartCharging;
public event Action OnStopCharging;
public event Action OnCharged;
public event Action OnFailed;
@ -63,10 +65,12 @@ public class ChargedWeapon : InstantWeapon
_charged = true;
OnCharged?.Invoke();
}
if (_charge > _data.FailureCharge)
if (_data.FailureCharge > 1 && _charge > _data.FailureCharge)
{
_charging = false;
_cooldown = 1;
_coolingDown = true;
_charge = 0;
OnFailed?.Invoke();
Item.EquippableItem.Durability -= _data.FailureDamage;
}
@ -76,8 +80,9 @@ public class ChargedWeapon : InstantWeapon
public override void Activate()
{
if(_cooldown < 0)
if(!_coolingDown)
{
OnStartCharging?.Invoke();
_charging = true;
_charged = false;
}
@ -85,10 +90,15 @@ public class ChargedWeapon : InstantWeapon
public override void Deactivate()
{
if (_charging && (_data.CanFireEarly || _charge > 1))
if (_charging)
{
Trigger();
_charge = 0;
if (_data.CanFireEarly || _charge > 1)
{
Trigger();
_charge = 0;
}
OnStopCharging?.Invoke();
_charging = false;
}
}
}

View file

@ -33,7 +33,7 @@ public class InstantWeapon : Weapon, IProgressBehavior
private float _burstInterval;
protected float _cooldown; // Normalized
private int _ammo = 1;
private bool _coolingDown;
protected bool _coolingDown;
public override int Ammo
{

Binary file not shown.