From d8fd4b5a0afd3624b02ce5c1935f3828857fb4dc Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Mon, 11 Jan 2021 11:46:46 +0000 Subject: [PATCH] improve enemy collision, slidies, difficulty curve --- .../Accessibility/Accessibility Options.asset | 2 +- Assets/Materials/Enemy.mat | 4 +- Assets/Materials/Obstacle.mat | 2 +- Assets/Prefabs/Enemy.prefab | 27 ++++++------ Assets/Prefabs/Ship.prefab | 2 +- Assets/Scenes/Game.unity | 41 ++++++++++++++++++- Assets/Scripts/DisableOnDeath.cs | 2 +- Assets/Scripts/IncreaseDifficultyOverTime.cs | 18 ++++++++ .../IncreaseDifficultyOverTime.cs.meta | 11 +++++ Assets/Scripts/SlideSideways.cs | 16 ++++++++ Assets/Scripts/SpawnZone.cs | 7 ++-- Assets/Scripts/Weapon.cs | 1 + Assets/Shaders/enemy.shader | 8 +++- Assets/Shaders/obstacle.shader | 2 + Assets/Weapons/Enemy.asset | 22 ++++++++-- Assets/Weapons/Obstacle.asset | 18 +++++++- Assets/Weapons/PlayerWeapon.asset | 12 +++--- 17 files changed, 160 insertions(+), 35 deletions(-) create mode 100644 Assets/Scripts/IncreaseDifficultyOverTime.cs create mode 100644 Assets/Scripts/IncreaseDifficultyOverTime.cs.meta diff --git a/Assets/Accessibility/Accessibility Options.asset b/Assets/Accessibility/Accessibility Options.asset index 948e968..9ca6e5d 100644 --- a/Assets/Accessibility/Accessibility Options.asset +++ b/Assets/Accessibility/Accessibility Options.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c271cfa846431634db54fa41238b7b35, type: 3} m_Name: Accessibility Options m_EditorClassIdentifier: - _mode: 0 + _mode: 2 _calm: _value: 0 _tunnel: {fileID: 2100000, guid: e26770f868f0d0d44960f5354b21e17c, type: 2} diff --git a/Assets/Materials/Enemy.mat b/Assets/Materials/Enemy.mat index 54d24f0..277c11c 100644 --- a/Assets/Materials/Enemy.mat +++ b/Assets/Materials/Enemy.mat @@ -82,7 +82,7 @@ Material: m_Floats: - _Alpha: 1 - _AlphaClip: 0 - - _BaseScale: 0.8 + - _BaseScale: 1.2 - _Blend: 0 - _BumpScale: 1 - _C: 0 @@ -104,7 +104,7 @@ Material: - _Parallax: 0.005 - _PulseIntensity: 0.5 - _QueueOffset: 0 - - _RadiusWithDistance: 0.00005 + - _RadiusWithDistance: 0.00007 - _ReceiveShadows: 1 - _Smoothness: 0.5 - _SmoothnessTextureChannel: 0 diff --git a/Assets/Materials/Obstacle.mat b/Assets/Materials/Obstacle.mat index bf6ac5a..fb4ea1c 100644 --- a/Assets/Materials/Obstacle.mat +++ b/Assets/Materials/Obstacle.mat @@ -104,7 +104,7 @@ Material: - _Parallax: 0.005 - _PulseIntensity: 1 - _QueueOffset: 0 - - _RadiusWithDistance: 0.00005 + - _RadiusWithDistance: 0.00007 - _ReceiveShadows: 1 - _Smoothness: 0.5 - _SmoothnessTextureChannel: 0 diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab index f4c9b09..cfe5747 100644 --- a/Assets/Prefabs/Enemy.prefab +++ b/Assets/Prefabs/Enemy.prefab @@ -47,6 +47,20 @@ MonoBehaviour: m_EditorClassIdentifier: xMin: -10.1 xMax: 10.1 +--- !u!114 &1858863165099212332 +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: ea3f51bb4cd6c8146a185362df2fe451, type: 3} + m_Name: + m_EditorClassIdentifier: + _speedRange: {x: -10, y: 10} + _xBounds: {x: -10, y: 10} --- !u!1 &7094929575626237127 GameObject: m_ObjectHideFlags: 0 @@ -198,16 +212,3 @@ MonoBehaviour: m_EditorClassIdentifier: xMin: -10.1 xMax: 10.1 ---- !u!114 &1858863165099212332 -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: ea3f51bb4cd6c8146a185362df2fe451, type: 3} - m_Name: - m_EditorClassIdentifier: - _speedRange: {x: -5, y: 5} diff --git a/Assets/Prefabs/Ship.prefab b/Assets/Prefabs/Ship.prefab index a4e7c2e..f2a70b5 100644 --- a/Assets/Prefabs/Ship.prefab +++ b/Assets/Prefabs/Ship.prefab @@ -94,7 +94,7 @@ BoxCollider: m_IsTrigger: 0 m_Enabled: 1 serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} + m_Size: {x: 0.1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} --- !u!114 &8761754940900000814 MonoBehaviour: diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 1918878..1af1ab3 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -177,6 +177,7 @@ GameObject: m_Component: - component: {fileID: 84273095} - component: {fileID: 84273094} + - component: {fileID: 84273096} m_Layer: 0 m_Name: App m_TagString: Untagged @@ -221,6 +222,20 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &84273096 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 84273093} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 565df9595af1e6e4a9547067e1d23b5d, type: 3} + m_Name: + m_EditorClassIdentifier: + _base: 1 + _perBeatIncrease: 0.005 --- !u!1 &186457103 GameObject: m_ObjectHideFlags: 0 @@ -1614,12 +1629,16 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.size - value: 2 + value: 3 objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[1].m_Mode value: 0 objectReference: {fileID: 0} + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[2].m_Mode + value: 0 + objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[0].m_Target value: @@ -1628,22 +1647,42 @@ PrefabInstance: propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[1].m_Target value: objectReference: {fileID: 532372216} + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[2].m_Target + value: + objectReference: {fileID: 84273096} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[1].m_CallState value: 2 objectReference: {fileID: 0} + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[2].m_CallState + value: 2 + objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[1].m_MethodName value: OnBeat objectReference: {fileID: 0} + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[2].m_MethodName + value: OnBeat + objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[1].m_TargetAssemblyTypeName value: BeatSpawner, Assembly-CSharp objectReference: {fileID: 0} + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[2].m_TargetAssemblyTypeName + value: IncreaseDifficultyOverTime, Assembly-CSharp + objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[1].m_Arguments.m_ObjectArgumentAssemblyTypeName value: UnityEngine.Object, UnityEngine objectReference: {fileID: 0} + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[2].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} - target: {fileID: 2145967175348613561, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: m_Name value: Audio diff --git a/Assets/Scripts/DisableOnDeath.cs b/Assets/Scripts/DisableOnDeath.cs index e50b821..69a6c54 100644 --- a/Assets/Scripts/DisableOnDeath.cs +++ b/Assets/Scripts/DisableOnDeath.cs @@ -45,7 +45,7 @@ public class DisableOnDeath : MonoBehaviour private void Die() { var oldName = gameObject.name; - gameObject.name = "disabled"; + gameObject.transform.parent.name = "disabled"; _collider.enabled = false; float duration = 0.4f; diff --git a/Assets/Scripts/IncreaseDifficultyOverTime.cs b/Assets/Scripts/IncreaseDifficultyOverTime.cs new file mode 100644 index 0000000..845f6ad --- /dev/null +++ b/Assets/Scripts/IncreaseDifficultyOverTime.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using FMOD; +using UnityEngine; +using Debug = UnityEngine.Debug; + +public class IncreaseDifficultyOverTime : MonoBehaviour +{ + [SerializeField] private float _base; + [SerializeField] private float _perBeatIncrease; + + public void OnBeat(int beat) + { + var difficulty = _base * Mathf.Pow(1.0f+_perBeatIncrease, beat); + Debug.Log(difficulty); + Shader.SetGlobalFloat("_Difficulty", difficulty); + } +} diff --git a/Assets/Scripts/IncreaseDifficultyOverTime.cs.meta b/Assets/Scripts/IncreaseDifficultyOverTime.cs.meta new file mode 100644 index 0000000..92ff3f2 --- /dev/null +++ b/Assets/Scripts/IncreaseDifficultyOverTime.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 565df9595af1e6e4a9547067e1d23b5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SlideSideways.cs b/Assets/Scripts/SlideSideways.cs index 6a5970d..65d595f 100644 --- a/Assets/Scripts/SlideSideways.cs +++ b/Assets/Scripts/SlideSideways.cs @@ -7,8 +7,15 @@ using UnityEngine; public class SlideSideways : MonoBehaviour { [SerializeField] private Vector2 _speedRange; + [SerializeField] private Vector2 _xBounds; private float _speed; + private float _xDiff; + + private void Awake() + { + _xDiff = _xBounds.y - _xBounds.x; + } private void Start() { @@ -19,5 +26,14 @@ public class SlideSideways : MonoBehaviour private void LateUpdate() { transform.Translate(Vector3.right * _speed * Time.deltaTime); + + if (transform.position.x < _xBounds.x) + { + transform.position += Vector3.right * _xDiff; + } + else if (transform.position.x > _xBounds.y) + { + transform.position -= Vector3.right * _xDiff; + } } } diff --git a/Assets/Scripts/SpawnZone.cs b/Assets/Scripts/SpawnZone.cs index 440df51..7ed3762 100644 --- a/Assets/Scripts/SpawnZone.cs +++ b/Assets/Scripts/SpawnZone.cs @@ -4,6 +4,7 @@ using NUnit.Framework.Constraints; using UnityEditor.UIElements; using UnityEngine; using UnityEngine.Assertions; +using Utils; using Random = UnityEngine.Random; namespace Weapons.Spawning @@ -32,7 +33,7 @@ namespace Weapons.Spawning [SerializeField] private int numPerSide; [SerializeField] private bool flipVertical; - [SerializeField] private float radius; + [SerializeField] private ParticleSystem.MinMaxCurve radius; [SerializeField, Range(0, 360)] private float arc; [SerializeField] private SpawnZone[] composite; @@ -89,7 +90,7 @@ namespace Weapons.Spawning if (flipVertical) point.y = 1 - point.y; - point *= radius; + point *= radius.EvaluateMinMaxCurve(); if (spawnPlane == SpawnPlane.XZ) { @@ -168,7 +169,7 @@ namespace Weapons.Spawning dir = Random.insideUnitCircle.normalized; - onGetPoint((point * radius) + offset, dir); + onGetPoint((point * radius.EvaluateMinMaxCurve()) + offset, dir); } } diff --git a/Assets/Scripts/Weapon.cs b/Assets/Scripts/Weapon.cs index 097171e..665acc7 100644 --- a/Assets/Scripts/Weapon.cs +++ b/Assets/Scripts/Weapon.cs @@ -169,6 +169,7 @@ public class Weapon : ScriptableObject // if it's inactive, we haven't hit anything if (!instance.gameObject.activeSelf) return false; + if (instance.gameObject.name == "disabled") return false; // use the non allocating version so we don't have to allocate memory for every bullet numHits = Physics.OverlapCapsuleNonAlloc(prevPos, instance.position, size/2f, _results, collidesWith, QueryTriggerInteraction.Collide); diff --git a/Assets/Shaders/enemy.shader b/Assets/Shaders/enemy.shader index 3361bbc..becf149 100644 --- a/Assets/Shaders/enemy.shader +++ b/Assets/Shaders/enemy.shader @@ -68,6 +68,7 @@ Shader "custom/enemy" float4 _FarColor; float _Alpha; + float _Difficulty; float _SpeedMultiplier; float _RadiusWithDistance; @@ -143,8 +144,9 @@ Shader "custom/enemy" wpos.y += radius; float bounceStrength=5.0*_Intensity; - float bounce = (_SpeedMultiplier+bounceStrength*(_DistanceToNextBeat*_DistanceSinceLastBeat)); + float bounce = _SpeedMultiplier+bounceStrength*(_DistanceToNextBeat*_DistanceSinceLastBeat); wpos.z *= bounce; + wpos.z *= _Difficulty; // wpos.z *= max(1, (wpos.z-6)* _SpeedMultiplier); vpos = TransformWorldToObject(wpos); @@ -182,8 +184,10 @@ Shader "custom/enemy" // float4 c = float4(lerp(_Color1, _Color2, t).xyz, _Alpha); float4 c = _Color1; c = lerp(_Color1, _Color2, length(p)); - + c = lerp(c, _FarColor, normalised * _Intensity); + float4 nc = normalize(c); + c = lerp(nc, c, clamp(_Intensity + 0.02, 0, 1)); // float distanceAhead = IN.wpos.z - 6; // float ca = clamp(distanceAhead * 0.1,0,1); diff --git a/Assets/Shaders/obstacle.shader b/Assets/Shaders/obstacle.shader index efc08e2..3091f48 100644 --- a/Assets/Shaders/obstacle.shader +++ b/Assets/Shaders/obstacle.shader @@ -70,6 +70,7 @@ Shader "custom/obstacle" float _Alpha; float _PulseIntensity; + float _Difficulty; float _SpeedMultiplier; float _RadiusWithDistance; @@ -227,6 +228,7 @@ Shader "custom/obstacle" float boundsStrength = 5.0*_Intensity; float bounce = (_SpeedMultiplier+boundsStrength*(_DistanceToNextBeat*_DistanceSinceLastBeat)); wpos.z *= bounce; + wpos.z *= _Difficulty; vpos = TransformWorldToObject(wpos); diff --git a/Assets/Weapons/Enemy.asset b/Assets/Weapons/Enemy.asset index 703880d..4c1ae82 100644 --- a/Assets/Weapons/Enemy.asset +++ b/Assets/Weapons/Enemy.asset @@ -99,7 +99,7 @@ MonoBehaviour: m_PostInfinity: 2 m_RotationOrder: 4 m_ConstantMin: 0 - m_ConstantMax: 1 + m_ConstantMax: 0.1 damage: 1 collidesWith: serializedVersion: 2 @@ -116,9 +116,25 @@ MonoBehaviour: surfaceOnly: 0 evenDistribution: 0 numSides: 3 - numPerSide: 10 + numPerSide: 5 flipVertical: 0 - radius: 10 + radius: + m_Mode: 3 + m_CurveMultiplier: 0 + m_CurveMin: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_CurveMax: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ConstantMin: 7 + m_ConstantMax: 13 arc: 360 composite: [] manualFire: 1 diff --git a/Assets/Weapons/Obstacle.asset b/Assets/Weapons/Obstacle.asset index 42bb0a0..443877f 100644 --- a/Assets/Weapons/Obstacle.asset +++ b/Assets/Weapons/Obstacle.asset @@ -118,7 +118,23 @@ MonoBehaviour: numSides: 3 numPerSide: 10 flipVertical: 0 - radius: 5 + radius: + m_Mode: 3 + m_CurveMultiplier: 0 + m_CurveMin: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_CurveMax: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ConstantMin: 3 + m_ConstantMax: 9 arc: 360 composite: [] manualFire: 1 diff --git a/Assets/Weapons/PlayerWeapon.asset b/Assets/Weapons/PlayerWeapon.asset index 274b54b..d31eda5 100644 --- a/Assets/Weapons/PlayerWeapon.asset +++ b/Assets/Weapons/PlayerWeapon.asset @@ -81,10 +81,10 @@ MonoBehaviour: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - m_ConstantMin: 1.25 - m_ConstantMax: 1.5 + m_ConstantMin: 0.5 + m_ConstantMax: 0.75 bulletSize: - m_Mode: 3 + m_Mode: 0 m_CurveMultiplier: 0 m_CurveMin: serializedVersion: 2 @@ -98,8 +98,8 @@ MonoBehaviour: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - m_ConstantMin: 0.1 - m_ConstantMax: 0.4 + m_ConstantMin: 1 + m_ConstantMax: 3 damage: 1 collidesWith: serializedVersion: 2 @@ -111,7 +111,7 @@ MonoBehaviour: spawnType: 1 spawnDir: 0 spawnPlane: 1 - width: 0.75 + width: 1.5 height: 0 surfaceOnly: 1 evenDistribution: 1