Merge branch 'main' into enemy-graphics

This commit is contained in:
Cat Flynn 2021-01-09 17:42:19 +00:00
commit 3eab5bfde7
29 changed files with 952 additions and 515 deletions

View File

@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d86361ffc5ae478d9e976629c5d651bd, type: 3}
m_Name: HorizontalInput
m_EditorClassIdentifier:
_initialValue: 0
_readOnly: 0

View File

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

View File

@ -155,6 +155,17 @@ namespace Input
""action"": ""Shoot"", ""action"": ""Shoot"",
""isComposite"": false, ""isComposite"": false,
""isPartOfComposite"": false ""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""6c7bd30a-0e04-4215-b3bd-2be74887a139"",
""path"": ""<Keyboard>/space"",
""interactions"": """",
""processors"": """",
""groups"": ""Default"",
""action"": ""Shoot"",
""isComposite"": false,
""isPartOfComposite"": false
} }
] ]
} }

View File

@ -140,6 +140,17 @@
"action": "Shoot", "action": "Shoot",
"isComposite": false, "isComposite": false,
"isPartOfComposite": false "isPartOfComposite": false
},
{
"name": "",
"id": "6c7bd30a-0e04-4215-b3bd-2be74887a139",
"path": "<Keyboard>/space",
"interactions": "",
"processors": "",
"groups": "Default",
"action": "Shoot",
"isComposite": false,
"isPartOfComposite": false
} }
] ]
} }

View File

@ -12,5 +12,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d86361ffc5ae478d9e976629c5d651bd, type: 3} m_Script: {fileID: 11500000, guid: d86361ffc5ae478d9e976629c5d651bd, type: 3}
m_Name: PlayerSpeed m_Name: PlayerSpeed
m_EditorClassIdentifier: m_EditorClassIdentifier:
_initialValue: 12 _initialValue: 24
_readOnly: 0 _readOnly: 0

View File

@ -92,6 +92,7 @@ Material:
- _DstBlend: 0 - _DstBlend: 0
- _EnvironmentReflections: 1 - _EnvironmentReflections: 1
- _FadeStrength: 0.9 - _FadeStrength: 0.9
- _FlashAmount: 0
- _GlossMapScale: 0 - _GlossMapScale: 0
- _Glossiness: 0 - _Glossiness: 0
- _GlossyReflections: 0 - _GlossyReflections: 0
@ -114,6 +115,7 @@ Material:
- _Color1: {r: 0.5411765, g: 1.8509804, b: 2, a: 1} - _Color1: {r: 0.5411765, g: 1.8509804, b: 2, a: 1}
- _Color2: {r: 1.2078432, g: 0, b: 1.1058824, a: 1} - _Color2: {r: 1.2078432, g: 0, b: 1.1058824, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _FlashColor: {r: 1.1, g: 1.1, b: 1.1, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} - _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_BuildTextureStacks: [] m_BuildTextureStacks: []
--- !u!114 &1642389398374086642 --- !u!114 &1642389398374086642

View File

@ -9,6 +9,8 @@ public class MovePlayer : MonoBehaviour
{ {
[SerializeField] private SerialFloat speed; [SerializeField] private SerialFloat speed;
[SerializeField] private RectOffset extents; [SerializeField] private RectOffset extents;
[SerializeField] private float lerpAmount = 0.95f;
[SerializeField] private SerialFloat horizontalInput;
private PlayerInput _input; private PlayerInput _input;
@ -18,9 +20,14 @@ public class MovePlayer : MonoBehaviour
private Rect _pos; private Rect _pos;
private float _yPos;
private float _zPos;
private void Awake() private void Awake()
{ {
_transform = transform; _transform = transform;
_yPos = _transform.localPosition.y;
_zPos = _transform.localPosition.z;
} }
private void OnEnable() private void OnEnable()
@ -40,15 +47,18 @@ public class MovePlayer : MonoBehaviour
private void Update() private void Update()
{ {
_transform.localPosition += (Vector3) _currentInput * speed * Time.deltaTime; _transform.localPosition += (Vector3) _currentInput * speed * Time.deltaTime;
_transform.localPosition = new Vector3( _transform.localPosition = new Vector3(
Mathf.Clamp(_transform.localPosition.x, extents.left, extents.right), Mathf.Clamp(_transform.localPosition.x, extents.left, extents.right),
Mathf.Clamp(_transform.localPosition.y, extents.bottom, extents.top), _yPos,
_transform.localPosition.z); _zPos);
horizontalInput.Value = _currentInput.x;
} }
private void DoMove(InputAction.CallbackContext context) private void DoMove(InputAction.CallbackContext context)
{ {
var value = context.ReadValue<Vector2>(); var value = context.ReadValue<Vector2>();
_currentInput = value; _currentInput = Vector2.Lerp(_currentInput, value, lerpAmount);
} }
} }

View File

@ -0,0 +1,82 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2145967175348613561
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2145967175348613567}
- component: {fileID: 2145967175348613560}
- component: {fileID: 2145967175348613565}
m_Layer: 0
m_Name: Audio
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2145967175348613567
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2145967175348613561}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2145967175348613560
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2145967175348613561}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30d54cd9cbc0b4024b4c5af11532f553, type: 3}
m_Name:
m_EditorClassIdentifier:
_distanceToNextBeat: {fileID: 11400000, guid: 8f05f93192443bc42b8523048bde0dc4, type: 2}
_distanceSinceLastBeat: {fileID: 11400000, guid: 8d22f3ed946820445adcc586d2cc6e5a, type: 2}
bpm: 90
_onBeat:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: BeatSpawner, Assembly-CSharp
m_MethodName: OnBeat
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
--- !u!114 &2145967175348613565
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2145967175348613561}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b9468c5f457ace64f8d4df6d642b107f, type: 3}
m_Name:
m_EditorClassIdentifier:
LoadEvent: 1
UnloadEvent: 2
Banks:
- Master
CollisionTag:
PreloadSamples: 1

View File

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

View File

@ -14,7 +14,6 @@ GameObject:
- component: {fileID: 233269787904781725} - component: {fileID: 233269787904781725}
- component: {fileID: 2766037370157449026} - component: {fileID: 2766037370157449026}
- component: {fileID: 2122656558574222561} - component: {fileID: 2122656558574222561}
- component: {fileID: 499203000553078885}
m_Layer: 7 m_Layer: 7
m_Name: Enemy m_Name: Enemy
m_TagString: Untagged m_TagString: Untagged
@ -123,18 +122,3 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5b2c8b098025f4e2f997759b5c00fef7, type: 3} m_Script: {fileID: 11500000, guid: 5b2c8b098025f4e2f997759b5c00fef7, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!114 &499203000553078885
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1738226812227614583}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 331122d8907f44ed9b0f8f2337d176b9, type: 3}
m_Name:
m_EditorClassIdentifier:
beatsBeforeMove: 16
scaleAmount: 1.5
numBeatsAfterScale: 0

View File

@ -487,6 +487,7 @@ Transform:
m_Children: m_Children:
- {fileID: 3397488661354499723} - {fileID: 3397488661354499723}
- {fileID: 3397488661916228001} - {fileID: 3397488661916228001}
- {fileID: 9171119707973959464}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -571,3 +572,51 @@ Transform:
m_Father: {fileID: 3397488660859550701} m_Father: {fileID: 3397488660859550701}
m_RootOrder: 1 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &3859152818583472155
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9171119707973959464}
- component: {fileID: 7219052837562198912}
m_Layer: 0
m_Name: PostProcessing
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9171119707973959464
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3859152818583472155}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 105.96986, y: -9.773619, z: -43.163918}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3397488660859550701}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7219052837562198912
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3859152818583472155}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3}
m_Name:
m_EditorClassIdentifier:
isGlobal: 1
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 7cf7c4ef7a9fb45c0b93cb37aa1b1917, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5d8131bcfdc1241c8ad61ac6e83826ab
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-3395606675299854484
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
threshold:
m_OverrideState: 1
m_Value: 3
min: 0
intensity:
m_OverrideState: 1
m_Value: 4
min: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
min: 0
max: 1
clamp:
m_OverrideState: 0
m_Value: 65472
min: 0
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
hdr: 0
showAlpha: 0
showEyeDropper: 1
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
skipIterations:
m_OverrideState: 0
m_Value: 1
min: 0
max: 16
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dirtIntensity:
m_OverrideState: 0
m_Value: 0
min: 0
--- !u!114 &-142191583213071455
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 29fa0085f50d5e54f8144f766051a691, type: 3}
m_Name: FilmGrain
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
type:
m_OverrideState: 1
m_Value: 0
intensity:
m_OverrideState: 1
m_Value: 1
min: 0
max: 1
response:
m_OverrideState: 0
m_Value: 0.8
min: 0
max: 1
texture:
m_OverrideState: 0
m_Value: {fileID: 0}
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: PostProcessing Profile
m_EditorClassIdentifier:
components:
- {fileID: -3395606675299854484}
- {fileID: -142191583213071455}
- {fileID: 7557782805353103494}
--- !u!114 &7557782805353103494
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 81180773991d8724ab7f2d216912b564, type: 3}
m_Name: ChromaticAberration
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
intensity:
m_OverrideState: 1
m_Value: 1
min: 0
max: 1

View File

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

View File

@ -20,13 +20,13 @@ public class AudioBeatManager : MonoBehaviour, IAudioBeatManager
// [SerializeField] private SerialFloat _distanceSinceMeasure; // [SerializeField] private SerialFloat _distanceSinceMeasure;
[SerializeField] private float bpm; [SerializeField] private float bpm;
private float _secPerBeat;
public float TimeBetweenBeats => _secPerBeat; public float TimeBetweenBeats => _secPerBeat;
private float _bps;
private int _currentBeat = 0; private int _currentBeat = 0;
private float _timer; private float _timer;
private float _secPerBeat;
[SerializeField] [FormerlySerializedAs("OnBeat")] [SerializeField] [FormerlySerializedAs("OnBeat")]
private IntEvent _onBeat; private IntEvent _onBeat;
@ -43,7 +43,6 @@ public class AudioBeatManager : MonoBehaviour, IAudioBeatManager
private void Awake() private void Awake()
{ {
_bps = bpm / 60f;
_secPerBeat = 60f / bpm; _secPerBeat = 60f / bpm;
RuntimeManager.CoreSystem.getMasterChannelGroup(out _channelGroup); RuntimeManager.CoreSystem.getMasterChannelGroup(out _channelGroup);
RuntimeManager.CoreSystem.getSoftwareFormat(out _sampleRate, out _, out _); RuntimeManager.CoreSystem.getSoftwareFormat(out _sampleRate, out _, out _);

View File

@ -33,7 +33,7 @@ namespace Weapons.Editor
AddRelativeProperty( property, "numToSpawn", space, ref currentPos); AddRelativeProperty( property, "numToSpawn", space, ref currentPos);
AddRelativeProperty( property, "spawnDir", space, ref currentPos); AddRelativeProperty( property, "spawnDir", space, ref currentPos);
AddRelativeProperty( property, "spawnPlane", space, ref currentPos);
AddRelativeProperty( property, "surfaceOnly", space, ref currentPos); AddRelativeProperty( property, "surfaceOnly", space, ref currentPos);
AddRelativeProperty(property, "offset", space, ref currentPos); AddRelativeProperty(property, "offset", space, ref currentPos);
@ -61,6 +61,7 @@ namespace Weapons.Editor
AddRelativeProperty(property, "numSides", space, ref currentPos); AddRelativeProperty(property, "numSides", space, ref currentPos);
AddRelativeProperty(property, "numPerSide", space, ref currentPos); AddRelativeProperty(property, "numPerSide", space, ref currentPos);
AddRelativeProperty( property, "radius", space, ref currentPos); AddRelativeProperty( property, "radius", space, ref currentPos);
AddRelativeProperty(property, "flipVertical", space, ref currentPos);
} }
EditorGUI.indentLevel--; EditorGUI.indentLevel--;

View File

@ -17,7 +17,9 @@ public class EnemyAppearBehaviour : BaseBulletBehaviour
bullet.localScale = Vector3.zero; bullet.localScale = Vector3.zero;
bullet.localPosition = new Vector3(pos.x, pos.y, zPos); bullet.localPosition = new Vector3(pos.x, pos.y, zPos);
DOTween.Sequence() DOTween.Sequence()
.Append(bullet.DOMove(pos, moveInDuration).SetEase(Ease.OutQuint)) //.Append(bullet.DOMove(pos, moveInDuration).SetEase(Ease.OutQuint))
.Insert(scaleUpDelay, bullet.DORotate(new Vector3(0,0,45), moveInDuration/2f))
.Insert(scaleUpDelay + moveInDuration/2f, bullet.DORotate(Vector3.zero, moveInDuration/2f))
.Insert(scaleUpDelay, bullet.DOScale(Vector3.one * size, scaleUpDuration).SetEase(Ease.OutQuint)); .Insert(scaleUpDelay, bullet.DOScale(Vector3.one * size, scaleUpDuration).SetEase(Ease.OutQuint));
} }
} }

View File

@ -0,0 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Utils;
public class HitStopOnDie : MonoBehaviour
{
[SerializeField] private float lengthInSeconds = 0.1f;
private WaitForSecondsRealtime wait;
private void Awake()
{
wait = new WaitForSecondsRealtime(lengthInSeconds);
}
public void OnDie()
{
Wait().Run();
}
private IEnumerator Wait()
{
//Time.timeScale = 0;
yield return wait;
Time.timeScale = 1;
}
}

View File

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

View File

@ -9,34 +9,18 @@ public class LoseLife : MonoBehaviour
{ {
[SerializeField] private Renderer[] healthMarkers; [SerializeField] private Renderer[] healthMarkers;
[SerializeField] private Renderer polygon; [SerializeField] private Renderer polygon;
[SerializeField] private WeaponHandler weapon;
private Color[] _markerColors;
private EntityHealth _health; private EntityHealth _health;
private Color _polygonColor;
private Color _polygonColorClear;
private void Awake() private void Awake()
{ {
_health = GetComponent<EntityHealth>(); _health = GetComponent<EntityHealth>();
_polygonColor = polygon.material.color;
_polygonColorClear = _polygonColor;
_polygonColorClear.a = 0;
_markerColors = new Color[healthMarkers.Length];
for (int i = 0; i < healthMarkers.Length; i++)
{
_markerColors[i] = healthMarkers[i].material.color;
_markerColors[i].a = 0;
}
} }
public void LifeLost(int livesLeft) public void LifeLost(int livesLeft)
{ {
healthMarkers[livesLeft].transform.DOScale(Vector3.one * 5f, 1f).SetEase(Ease.InQuint).SetUpdate(true); healthMarkers[livesLeft].transform.DOScale(Vector3.zero, 1f).SetEase(Ease.InBack).SetUpdate(true);
healthMarkers[livesLeft].material.DOColor(_markerColors[livesLeft], 1f).SetDelay(0.25f).SetUpdate(true);
_health.enabled = false; _health.enabled = false;
weapon.enabled = false;
var timeVal = Time.timeScale; var timeVal = Time.timeScale;
Time.timeScale = 0; Time.timeScale = 0;
WaitUtils.Wait(0.1f, false, () => Time.timeScale = timeVal); WaitUtils.Wait(0.1f, false, () => Time.timeScale = timeVal);
@ -44,13 +28,12 @@ public class LoseLife : MonoBehaviour
var sequence = DOTween.Sequence(); var sequence = DOTween.Sequence();
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
sequence.Append(polygon.material.DOColor(_polygonColorClear, 0.2f).SetUpdate(true)); sequence.Append(polygon.material.DOFloat(1,"_FlashAmount", 0.2f).SetUpdate(true));
sequence.Append(polygon.material.DOColor(_polygonColor, 0.2f).SetUpdate(true)); sequence.Append(polygon.material.DOFloat(0,"_FlashAmount", 0.2f).SetUpdate(true));
} }
sequence.Play().OnComplete(() => sequence.Play().OnComplete(() =>
{ {
weapon.enabled = true;
_health.enabled = true; _health.enabled = true;
}); });
} }

View File

@ -9,15 +9,18 @@ using Random = UnityEngine.Random;
namespace Weapons.Spawning namespace Weapons.Spawning
{ {
public enum SpawnType { Circle, Square, Polygon, Composite } public enum SpawnType { Circle, Square, Polygon, Composite }
public enum SpawnPlane { XY, XZ }
public enum SpawnDir { None, Randomised, Spherised, Directional} public enum SpawnDir { None, Randomised, Spherised, Directional}
[Serializable] [Serializable]
public struct SpawnZone public struct SpawnZone
{ {
[SerializeField] private int numToSpawn; [SerializeField] private int numToSpawn;
[SerializeField] private Vector2 offset; [SerializeField] private Vector3 offset;
[SerializeField] private SpawnType spawnType; [SerializeField] private SpawnType spawnType;
[SerializeField] private SpawnDir spawnDir; [SerializeField] private SpawnDir spawnDir;
[SerializeField] private SpawnPlane spawnPlane;
[SerializeField] private float width; [SerializeField] private float width;
[SerializeField] private float height; [SerializeField] private float height;
@ -27,6 +30,7 @@ namespace Weapons.Spawning
[SerializeField] private int numSides; [SerializeField] private int numSides;
[SerializeField] private int numPerSide; [SerializeField] private int numPerSide;
[SerializeField] private bool flipVertical;
[SerializeField] private float radius; [SerializeField] private float radius;
[SerializeField, Range(0, 360)] private float arc; [SerializeField, Range(0, 360)] private float arc;
@ -37,7 +41,7 @@ namespace Weapons.Spawning
public int NumToSpawn => numToSpawn; public int NumToSpawn => numToSpawn;
public void GetPoint(Transform transform, Action<Vector2, Vector2> onGetPoint) public void GetPoint(Transform transform, Action<Vector3, Vector3> onGetPoint)
{ {
switch (spawnType) switch (spawnType)
{ {
@ -58,7 +62,7 @@ namespace Weapons.Spawning
} }
} }
private void SpawnPoly(Transform transform, Action<Vector2, Vector2> onGetPoint) private void SpawnPoly(Transform transform, Action<Vector3, Vector3> onGetPoint)
{ {
var points = new Vector2[numSides]; var points = new Vector2[numSides];
for (int i = 0; i < numSides; i++) for (int i = 0; i < numSides; i++)
@ -81,10 +85,20 @@ namespace Weapons.Spawning
{ {
var t = j / (float) numPerSide; var t = j / (float) numPerSide;
t += (1f / numPerSide)/2f; t += (1f / numPerSide)/2f;
var point = Vector2.Lerp(points[i], points[next], t); var point = Vector3.Lerp(points[i], points[next], t);
if (flipVertical)
point.y = 1 - point.y;
point *= radius; point *= radius;
var dir = Vector2.up; if (spawnPlane == SpawnPlane.XZ)
{
point.z = point.y;
point.y = 0;
}
var dir = Vector3.up;
if (spawnDir == SpawnDir.Directional) if (spawnDir == SpawnDir.Directional)
dir = direction; dir = direction;
else if (spawnDir == SpawnDir.Spherised) else if (spawnDir == SpawnDir.Spherised)
@ -92,12 +106,17 @@ namespace Weapons.Spawning
else if (spawnDir == SpawnDir.Randomised) else if (spawnDir == SpawnDir.Randomised)
dir = Random.insideUnitCircle.normalized; dir = Random.insideUnitCircle.normalized;
if (!surfaceOnly)
point = Vector2.Lerp(point, Vector3.zero, Random.Range(0, 1f));
onGetPoint?.Invoke(point, dir); onGetPoint?.Invoke(point, dir);
} }
} }
} }
private void SpawnComposite(Transform transform, Action<Vector2, Vector2> onGetPoint) private void SpawnComposite(Transform transform, Action<Vector3, Vector3> onGetPoint)
{ {
for (int i = 0; i < numToSpawn; i++) for (int i = 0; i < numToSpawn; i++)
{ {
@ -105,13 +124,14 @@ namespace Weapons.Spawning
} }
} }
private void SpawnCircle(Transform transform, Action<Vector2, Vector2> onGetPoint) private void SpawnCircle(Transform transform, Action<Vector3, Vector3> onGetPoint)
{ {
Assert.IsNotNull(onGetPoint); Assert.IsNotNull(onGetPoint);
for (int i = 0; i < numToSpawn; i++) for (int i = 0; i < numToSpawn; i++)
{ {
Vector2 point; var point = Vector3.zero;
if (!evenDistribution) if (!evenDistribution)
{ {
var angle = (Random.Range(-arc / 2f, arc / 2f) + 90 - transform.eulerAngles.y) * Mathf.Deg2Rad; var angle = (Random.Range(-arc / 2f, arc / 2f) + 90 - transform.eulerAngles.y) * Mathf.Deg2Rad;
@ -135,8 +155,13 @@ namespace Weapons.Spawning
} }
if (spawnPlane == SpawnPlane.XZ)
{
point.z = point.y;
point.y = 0;
}
var dir = Vector2.up; var dir = Vector3.up;
if (spawnDir == SpawnDir.Spherised || spawnDir == SpawnDir.Directional) if (spawnDir == SpawnDir.Spherised || spawnDir == SpawnDir.Directional)
dir = point.normalized; dir = point.normalized;
else if (spawnDir == SpawnDir.Randomised) else if (spawnDir == SpawnDir.Randomised)
@ -147,13 +172,13 @@ namespace Weapons.Spawning
} }
} }
private void SpawnSquare(Transform transform, Action<Vector2, Vector2> onGetPoint) private void SpawnSquare(Transform transform, Action<Vector3, Vector3> onGetPoint)
{ {
Assert.IsNotNull(onGetPoint); Assert.IsNotNull(onGetPoint);
for (int i = 0; i < numToSpawn; i++) for (int i = 0; i < numToSpawn; i++)
{ {
var point = new Vector2 var point = new Vector3
{ {
x = Random.Range(-.5f, .5f), x = Random.Range(-.5f, .5f),
y = Random.Range(-.5f, .5f) y = Random.Range(-.5f, .5f)
@ -168,14 +193,18 @@ namespace Weapons.Spawning
point.x *= width; point.x *= width;
point.y *= height; point.y *= height;
if (spawnPlane == SpawnPlane.XZ)
{
point.z = point.y;
point.y = 0;
}
var dir = Vector2.up; var dir = Vector3.up;
if (spawnDir == SpawnDir.Spherised || spawnDir == SpawnDir.Directional) if (spawnDir == SpawnDir.Spherised || spawnDir == SpawnDir.Directional)
dir = point.normalized; dir = point.normalized;
else if (spawnDir == SpawnDir.Randomised) else if (spawnDir == SpawnDir.Randomised)
dir = Random.insideUnitCircle.normalized; dir = Random.insideUnitCircle.normalized;
onGetPoint(point + offset, dir); onGetPoint(point + offset, dir);
} }
} }
@ -212,9 +241,9 @@ namespace Weapons.Spawning
Gizmos.color = color; Gizmos.color = color;
SpawnCircle(transform, (point, dir) => SpawnCircle(transform, (point, dir) =>
{ {
Gizmos.DrawSphere(new Vector3(point.x, 0, point.y), 0.25f); Gizmos.DrawSphere( transform.position + point, 0.25f);
if (color.a > 0.5f) if (color.a > 0.5f)
Gizmos.DrawRay(new Vector3(point.x, 0, point.y), new Vector3(dir.x, 0, dir.y)); Gizmos.DrawRay( transform.position + point, new Vector3(dir.x, 0, dir.y));
}); });
} }
@ -223,9 +252,9 @@ namespace Weapons.Spawning
Gizmos.color = color; Gizmos.color = color;
SpawnPoly(transform, (point, dir) => SpawnPoly(transform, (point, dir) =>
{ {
Gizmos.DrawSphere(transform.position + new Vector3(point.x, 0, point.y), 0.25f); Gizmos.DrawSphere(transform.position + point, 0.25f);
if (color.a > 0.5f) if (color.a > 0.5f)
Gizmos.DrawRay(transform.position + new Vector3(point.x, 0, point.y), new Vector3(dir.x, 0, dir.y)); Gizmos.DrawRay(transform.position + point, new Vector3(dir.x, 0, dir.y));
}); });
} }
@ -234,9 +263,9 @@ namespace Weapons.Spawning
Gizmos.color = color; Gizmos.color = color;
SpawnSquare(transform, (point, dir) => SpawnSquare(transform, (point, dir) =>
{ {
Gizmos.DrawSphere(new Vector3(point.x, 0, point.y), 0.25f); Gizmos.DrawSphere(transform.position + point, 0.25f);
if (color.a > 0.5f) if (color.a > 0.5f)
Gizmos.DrawRay(new Vector3(point.x, 0, point.y), new Vector3(dir.x, 0, dir.y)); Gizmos.DrawRay(transform.position + point, new Vector3(dir.x, 0, dir.y));
}); });
} }
} }

View File

@ -60,8 +60,13 @@ public class TargetLockOn : MonoBehaviour
for (int i = 0; i < numHits; i++) for (int i = 0; i < numHits; i++)
{ {
if (_targets.Contains(_colliders[i].transform)) continue; if (_targets.Contains(_colliders[i].transform)) continue;
_targets.Add(_colliders[i].transform); if (_targets.Count < maxTargets)
OnTargetFound?.Invoke(_colliders[i].transform); {
_targets.Add(_colliders[i].transform);
OnTargetFound?.Invoke(_colliders[i].transform);
}
if (_targets.Count >= maxTargets) if (_targets.Count >= maxTargets)
break; break;

View File

@ -35,6 +35,7 @@ public class Weapon : ScriptableObject
private struct Bullet private struct Bullet
{ {
public Vector3 Direction; public Vector3 Direction;
public Vector3 PrevPos;
public float Speed; public float Speed;
public float Lifetime; public float Lifetime;
public bool IsAlive; public bool IsAlive;
@ -53,7 +54,6 @@ public class Weapon : ScriptableObject
[SerializeField] private SpawnZone zone; [SerializeField] private SpawnZone zone;
[SerializeField] private bool manualFire; [SerializeField] private bool manualFire;
[SerializeField] private BaseBulletBehaviour behaviour; [SerializeField] private BaseBulletBehaviour behaviour;
[SerializeField] private bool useDeltaTime;
private List<Bullet> _bullets; private List<Bullet> _bullets;
private List<Transform> _bulletTransforms; private List<Transform> _bulletTransforms;
@ -75,13 +75,20 @@ public class Weapon : ScriptableObject
_job = new BulletMoveJob(); _job = new BulletMoveJob();
_bullets = new List<Bullet>(); _bullets = new List<Bullet>();
_bulletTransforms = new List<Transform>(); _bulletTransforms = new List<Transform>();
_currentCooldown = fireRate * Time.deltaTime; _currentCooldown = fireRate;
} }
public void Update() public void Update()
{ {
_currentCooldown += Time.deltaTime; _currentCooldown += Time.deltaTime;
for (int i = 0; i < _bulletTransforms.Count; i++)
{
_currentBullet = _bullets[i];
_currentBullet.PrevPos = _bulletTransforms[i].position;
_bullets[i] = _currentBullet;
}
_job.DeltaTime = Time.deltaTime; _job.DeltaTime = Time.deltaTime;
_job.Bullets = _bullets.ToNativeArray(Allocator.Persistent); _job.Bullets = _bullets.ToNativeArray(Allocator.Persistent);
@ -101,9 +108,11 @@ public class Weapon : ScriptableObject
_currentBullet.Lifetime -= Time.deltaTime; _currentBullet.Lifetime -= Time.deltaTime;
if (_currentBullet.Lifetime <= 0) if (_currentBullet.Lifetime <= 0)
_currentBullet.IsAlive = false; _currentBullet.IsAlive = false;
_bullets[i] = _currentBullet; _bullets[i] = _currentBullet;
if (_bullets[i].IsAlive) continue; if (_bullets[i].IsAlive && _bulletTransforms[i].gameObject.activeSelf) continue;
_bulletTransforms[i].gameObject.SetActive(false); _bulletTransforms[i].gameObject.SetActive(false);
_pool.ReturnObject(_bulletTransforms[i], _bullets[i].Idx); _pool.ReturnObject(_bulletTransforms[i], _bullets[i].Idx);
@ -124,7 +133,7 @@ public class Weapon : ScriptableObject
if (!_currentTransform.gameObject.activeSelf || !_currentBullet.IsAlive) continue; if (!_currentTransform.gameObject.activeSelf || !_currentBullet.IsAlive) continue;
// if it has hit something // if it has hit something
if (CheckCollision(_currentTransform, _currentTransform.localScale.x, out var numHits)) if (CheckCollision(_currentTransform, _currentBullet.PrevPos, _currentTransform.localScale.x, out var numHits))
{ {
// send the event // send the event
BulletCollision?.Invoke(_currentTransform.position); BulletCollision?.Invoke(_currentTransform.position);
@ -138,6 +147,10 @@ public class Weapon : ScriptableObject
// deactivate the bullet // deactivate the bullet
_currentBullet.IsAlive = false; _currentBullet.IsAlive = false;
_currentTransform.gameObject.SetActive(false);
_pool.ReturnObject(_currentTransform, _currentBullet.Idx);
_bullets.RemoveAt(i);
_bulletTransforms.RemoveAt(i);
} }
// apply the changes we made // apply the changes we made
@ -145,7 +158,7 @@ public class Weapon : ScriptableObject
} }
} }
private bool CheckCollision(Transform instance, float size, out int numHits) private bool CheckCollision(Transform instance, Vector3 prevPos, float size, out int numHits)
{ {
numHits = 0; numHits = 0;
@ -153,7 +166,7 @@ public class Weapon : ScriptableObject
if (!instance.gameObject.activeSelf) return false; if (!instance.gameObject.activeSelf) return false;
// use the non allocating version so we don't have to allocate memory for every bullet // use the non allocating version so we don't have to allocate memory for every bullet
numHits = Physics.OverlapSphereNonAlloc(instance.position, size/2f, _results, collidesWith, QueryTriggerInteraction.Collide); numHits = Physics.OverlapCapsuleNonAlloc(prevPos, instance.position, size/2f, _results, collidesWith, QueryTriggerInteraction.Collide);
return numHits > 0; return numHits > 0;
} }
@ -165,7 +178,7 @@ public class Weapon : ScriptableObject
if (!manualFire) if (!manualFire)
{ {
if (_currentCooldown > fireRate * (useDeltaTime ? Time.deltaTime : 1)) return false; if (_currentCooldown < fireRate) return false;
_currentCooldown = 0; _currentCooldown = 0;
} }
@ -192,12 +205,11 @@ public class Weapon : ScriptableObject
// enable the bullet // enable the bullet
bullet.gameObject.SetActive(true); bullet.gameObject.SetActive(true);
var newPos = new Vector3(point.x, point.y); var newPos = point;
newPos = Vector3.Lerp(newPos, Vector3.zero, Random.Range(0, 1f));
bullet.position = transform.position + newPos; bullet.position = transform.position + newPos;
// point the bullet in the right direction // point the bullet in the right direction
bullet.forward = new Vector3(dir.x, dir.y); bullet.forward = dir;
bullet.transform.localScale = Vector3.one * bulletSize.EvaluateMinMaxCurve(); bullet.transform.localScale = Vector3.one * bulletSize.EvaluateMinMaxCurve();
behaviour.DoBehaviour(bullet, bulletSize.EvaluateMinMaxCurve(), bullet.position); behaviour.DoBehaviour(bullet, bulletSize.EvaluateMinMaxCurve(), bullet.position);
if (zone.SpawnDir != SpawnDir.Spherised) if (zone.SpawnDir != SpawnDir.Spherised)
@ -214,6 +226,7 @@ public class Weapon : ScriptableObject
_bullets.Add(new Bullet _bullets.Add(new Bullet
{ {
Direction = bullet.forward, Direction = bullet.forward,
PrevPos = bullet.position,
IsAlive = true, IsAlive = true,
Speed = bulletSpeed.EvaluateMinMaxCurve(), Speed = bulletSpeed.EvaluateMinMaxCurve(),
Lifetime = bulletLifetime.EvaluateMinMaxCurve(), Lifetime = bulletLifetime.EvaluateMinMaxCurve(),
@ -232,10 +245,16 @@ public class Weapon : ScriptableObject
color.a = Selection.activeObject == this ? 1 : 0.05f; color.a = Selection.activeObject == this ? 1 : 0.05f;
zone.DrawGizmos(color, transform); zone.DrawGizmos(color, transform);
Gizmos.color = Color.white;
if (_bullets == null) return; if (_bullets == null) return;
foreach (var b in _bulletTransforms.Where(b => b != null)) for (int i = 0; i < _bulletTransforms.Count; i++)
{ {
Gizmos.DrawWireSphere(b.position, b.localScale.x/2f * bulletSize.EvaluateMinMaxCurve()); var b = _bulletTransforms[i];
if (b == null) continue;
Gizmos.DrawSphere(b.position, b.localScale.x/2f * bulletSize.EvaluateMinMaxCurve());
Gizmos.DrawSphere(_bullets[i].PrevPos, b.localScale.x/2f * bulletSize.EvaluateMinMaxCurve());
Gizmos.DrawLine(b.position, _bullets[i].PrevPos);
} }
#endif #endif
} }

View File

@ -12,6 +12,7 @@ public class WeaponHandler : MonoBehaviour
[SerializeField] private UnityEvent OnFire; [SerializeField] private UnityEvent OnFire;
[SerializeField] private Vector3Event OnBulletCollide; [SerializeField] private Vector3Event OnBulletCollide;
private bool _canShoot = false; private bool _canShoot = false;
private void Awake() private void Awake()

View File

@ -7,9 +7,10 @@ Shader "custom/ship"
{ {
[HDR] _Color1("Color 1", Color) = (1,1,1,1) [HDR] _Color1("Color 1", Color) = (1,1,1,1)
[HDR] _Color2("Color 2", Color) = (1,1,1,1) [HDR] _Color2("Color 2", Color) = (1,1,1,1)
[HDR] _FlashColor("Flash Color", Color) = (1.1,1.1,1.1,1)
_FadeStrength("Fade Strength", Float) = 0.1 _FadeStrength("Fade Strength", Float) = 0.1
_VertexScale("Vertex Scale", Float) = 0 _VertexScale("Vertex Scale", Float) = 0
_FlashAmount("Flash Amount", Float) = 0
_NoiseMap("Noise Map", 2D) = "black" _NoiseMap("Noise Map", 2D) = "black"
} }
@ -43,8 +44,10 @@ Shader "custom/ship"
float4 _Color1; float4 _Color1;
float4 _Color2; float4 _Color2;
float4 _FlashColor;
float _VertexScale; float _VertexScale;
float _FadeStrength; float _FadeStrength;
float _FlashAmount;
// This macro declares _BaseMap as a Texture2D object. // This macro declares _BaseMap as a Texture2D object.
TEXTURE2D(_BaseMap); TEXTURE2D(_BaseMap);
@ -92,7 +95,8 @@ Shader "custom/ship"
float2 p = -1.0+2.0*IN.positionHCS.xy/res.xy; float2 p = -1.0+2.0*IN.positionHCS.xy/res.xy;
float t = length(p); float t = length(p);
return lerp(_Color1,_Color2,t * _FadeStrength); float4 shaderColor = lerp(_Color1,_Color2,t * _FadeStrength);
return lerp(shaderColor, _FlashColor, _FlashAmount);
} }
ENDHLSL ENDHLSL
} }

View File

@ -64,10 +64,10 @@ MonoBehaviour:
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
m_ConstantMin: 0 m_ConstantMin: 20
m_ConstantMax: 0 m_ConstantMax: 30
bulletLifetime: bulletLifetime:
m_Mode: 3 m_Mode: 0
m_CurveMultiplier: 0 m_CurveMultiplier: 0
m_CurveMin: m_CurveMin:
serializedVersion: 2 serializedVersion: 2
@ -82,7 +82,7 @@ MonoBehaviour:
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
m_ConstantMin: 15 m_ConstantMin: 15
m_ConstantMax: 20 m_ConstantMax: 5
bulletSize: bulletSize:
m_Mode: 0 m_Mode: 0
m_CurveMultiplier: 0 m_CurveMultiplier: 0
@ -107,18 +107,19 @@ MonoBehaviour:
accuracy: 0 accuracy: 0
zone: zone:
numToSpawn: 10 numToSpawn: 10
offset: {x: 0, y: 0} offset: {x: 0, y: 0, z: 0}
spawnType: 0 spawnType: 0
spawnDir: 0 spawnDir: 0
spawnPlane: 1
width: 0 width: 0
height: 0 height: 0
surfaceOnly: 0 surfaceOnly: 0
evenDistribution: 0 evenDistribution: 0
numSides: 5 numSides: 5
numPerSide: 80 numPerSide: 10
radius: 15 flipVertical: 0
radius: 10
arc: 360 arc: 360
composite: [] composite: []
manualFire: 1 manualFire: 1
behaviour: {fileID: 11400000, guid: bb1cb2a77c68c42d4900953d18b23a49, type: 2} behaviour: {fileID: 11400000, guid: bb1cb2a77c68c42d4900953d18b23a49, type: 2}
useDeltaTime: 0

View File

@ -12,5 +12,5 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 8d6fb9bb806b4efcbd8aefb293811842, type: 3} m_Script: {fileID: 11500000, guid: 8d6fb9bb806b4efcbd8aefb293811842, type: 3}
m_Name: PlayerBulletScale m_Name: PlayerBulletScale
m_EditorClassIdentifier: m_EditorClassIdentifier:
scaleTime: 0.5 scaleTime: 0.25
scaleEase: 15 scaleEase: 15

View File

@ -104,7 +104,7 @@ MonoBehaviour:
collidesWith: collidesWith:
serializedVersion: 2 serializedVersion: 2
m_Bits: 128 m_Bits: 128
accuracy: 0 accuracy: 5
zone: zone:
numToSpawn: 1 numToSpawn: 1
offset: {x: 0, y: 0} offset: {x: 0, y: 0}
@ -116,8 +116,9 @@ MonoBehaviour:
evenDistribution: 1 evenDistribution: 1
numSides: 3 numSides: 3
numPerSide: 5 numPerSide: 5
flipVertical: 1
radius: 1.25 radius: 1.25
arc: 360 arc: 360
composite: [] composite: []
manualFire: 1 manualFire: 0
behaviour: {fileID: 11400000, guid: 20de5bc0e86bc4037a85f6c46356a227, type: 2} behaviour: {fileID: 11400000, guid: 20de5bc0e86bc4037a85f6c46356a227, type: 2}