From 99e949cd9b5e05e804349fe979443834cb6cb9c3 Mon Sep 17 00:00:00 2001 From: Dom Harris Date: Sun, 10 Jan 2021 17:15:58 +0000 Subject: [PATCH] score? Scoregit push --set-upstream origin score-n-shit --- Assets/Prefabs/Enemy.prefab | 16 ++++++++++++++- Assets/Scenes/Chief's Sandbox.unity | 23 ++++++++++++++++++++-- Assets/Scripts/AddScoreOnDie.cs | 29 ++++++++++++++++++++++++++++ Assets/Scripts/AddScoreOnDie.cs.meta | 11 +++++++++++ Assets/Scripts/DisableOnDeath.cs | 6 ++++-- Assets/Scripts/Score.cs | 17 ++++++++++++++++ Assets/Scripts/Score.cs.meta | 3 +++ Assets/Scripts/UpdateScore.cs | 27 ++++++++++++++++++++++++++ Assets/Scripts/UpdateScore.cs.meta | 3 +++ Assets/Weapons/Enemy.asset | 2 +- Assets/Weapons/PlayerWeapon.asset | 4 ++-- 11 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 Assets/Scripts/AddScoreOnDie.cs create mode 100644 Assets/Scripts/AddScoreOnDie.cs.meta create mode 100644 Assets/Scripts/Score.cs create mode 100644 Assets/Scripts/Score.cs.meta create mode 100644 Assets/Scripts/UpdateScore.cs create mode 100644 Assets/Scripts/UpdateScore.cs.meta diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab index 3d71938..c81ae66 100644 --- a/Assets/Prefabs/Enemy.prefab +++ b/Assets/Prefabs/Enemy.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 233269787904781725} - component: {fileID: 2766037370157449026} - component: {fileID: 2122656558574222561} + - component: {fileID: -3971665732303992234} m_Layer: 7 m_Name: Enemy m_TagString: Untagged @@ -109,7 +110,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d77551efeb20a4bdabb517c8351695ff, type: 3} m_Name: m_EditorClassIdentifier: - maxHealth: 1 + maxHealth: 4 --- !u!114 &2122656558574222561 MonoBehaviour: m_ObjectHideFlags: 0 @@ -122,3 +123,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5b2c8b098025f4e2f997759b5c00fef7, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &-3971665732303992234 +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: 1c18e41c4d38f4467bda24e543fec25f, type: 3} + m_Name: + m_EditorClassIdentifier: + value: 1000 diff --git a/Assets/Scenes/Chief's Sandbox.unity b/Assets/Scenes/Chief's Sandbox.unity index 870a536..4da9374 100644 --- a/Assets/Scenes/Chief's Sandbox.unity +++ b/Assets/Scenes/Chief's Sandbox.unity @@ -234,7 +234,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 186457103} m_LocalRotation: {x: -0, y: 1, z: -0, w: 0} - m_LocalPosition: {x: 0, y: -2, z: 100} + m_LocalPosition: {x: 0, y: -2, z: 200} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} @@ -1016,6 +1016,7 @@ GameObject: - component: {fileID: 1330494724} - component: {fileID: 1330494723} - component: {fileID: 1330494726} + - component: {fileID: 1330494725} m_Layer: 5 m_Name: Score m_TagString: Untagged @@ -1062,7 +1063,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: 1,234,567,898,765,432 + m_text: 0 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 0f0f54895994248b0bf34c4b4d27beef, type: 2} m_sharedMaterial: {fileID: -3347474280721358513, guid: 0f0f54895994248b0bf34c4b4d27beef, type: 2} @@ -1139,6 +1140,18 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1330494721} m_CullTransparentMesh: 1 +--- !u!114 &1330494725 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1330494721} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3da04f2795dd4afe8551debe01be4561, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!114 &1330494726 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1153,6 +1166,8 @@ MonoBehaviour: m_EditorClassIdentifier: timeSince: {fileID: 11400000, guid: 8f05f93192443bc42b8523048bde0dc4, type: 2} scale: 0.25 + ySquish: -0.15 + characterSpacing: 10 --- !u!1 &1395215960 GameObject: m_ObjectHideFlags: 0 @@ -1406,6 +1421,10 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} + propertyPath: bpm + value: 90 + objectReference: {fileID: 0} - target: {fileID: 2145967175348613560, guid: 88246464365fd0745b75edfcff208598, type: 3} propertyPath: _onBeat.m_PersistentCalls.m_Calls.Array.data[0].m_Target value: diff --git a/Assets/Scripts/AddScoreOnDie.cs b/Assets/Scripts/AddScoreOnDie.cs new file mode 100644 index 0000000..63ffe84 --- /dev/null +++ b/Assets/Scripts/AddScoreOnDie.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Weapons.Scripts; + +public class AddScoreOnDie : MonoBehaviour +{ + [SerializeField] private ulong value = 100; + private EntityHealth _health; + private void Awake() + { + _health = GetComponent(); + } + + private void OnEnable() + { + _health.Die += Die; + } + + private void OnDisable() + { + _health.Die -= Die; + } + + private void Die() + { + Score.Value += value + (ulong)Random.Range(-5, 5); + } +} \ No newline at end of file diff --git a/Assets/Scripts/AddScoreOnDie.cs.meta b/Assets/Scripts/AddScoreOnDie.cs.meta new file mode 100644 index 0000000..9f96eae --- /dev/null +++ b/Assets/Scripts/AddScoreOnDie.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1c18e41c4d38f4467bda24e543fec25f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/DisableOnDeath.cs b/Assets/Scripts/DisableOnDeath.cs index 19574fb..9f7567d 100644 --- a/Assets/Scripts/DisableOnDeath.cs +++ b/Assets/Scripts/DisableOnDeath.cs @@ -7,6 +7,7 @@ public class DisableOnDeath : MonoBehaviour { private EntityHealth _health; private Renderer _renderer; + private Collider _collider; private Color _color1; private Color _color2; @@ -21,6 +22,7 @@ public class DisableOnDeath : MonoBehaviour { _health = GetComponent(); _renderer = GetComponentInChildren(); + _collider = GetComponentInChildren(); _color1 = _renderer.material.GetColor(Color1); _color2 = _renderer.material.GetColor(Color2); @@ -29,7 +31,7 @@ public class DisableOnDeath : MonoBehaviour private void OnEnable() { _health.Die += Die; - + _collider.enabled = true; _renderer.material.SetColor(Color1, _color1); _renderer.material.SetColor(Color2, _color2); } @@ -43,7 +45,7 @@ public class DisableOnDeath : MonoBehaviour { var oldName = gameObject.name; gameObject.name = "disabled"; - + _collider.enabled = false; float x = 0; DOTween.To( () => x, diff --git a/Assets/Scripts/Score.cs b/Assets/Scripts/Score.cs new file mode 100644 index 0000000..43dbd58 --- /dev/null +++ b/Assets/Scripts/Score.cs @@ -0,0 +1,17 @@ +using System; + +public static class Score +{ + private static ulong _value; + public static ulong Value + { + get => _value; + set + { + _value = value; + ScoreUpdated?.Invoke(_value); + } + } + + public static event Action ScoreUpdated; +} \ No newline at end of file diff --git a/Assets/Scripts/Score.cs.meta b/Assets/Scripts/Score.cs.meta new file mode 100644 index 0000000..029eaef --- /dev/null +++ b/Assets/Scripts/Score.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 22e5c22e25d5491e9a6fdabcd5788ebf +timeCreated: 1610298027 \ No newline at end of file diff --git a/Assets/Scripts/UpdateScore.cs b/Assets/Scripts/UpdateScore.cs new file mode 100644 index 0000000..b63aa8e --- /dev/null +++ b/Assets/Scripts/UpdateScore.cs @@ -0,0 +1,27 @@ +using TMPro; +using UnityEngine; + +public class UpdateScore : MonoBehaviour +{ + private TextMeshProUGUI _text; + + private void Awake() + { + _text = GetComponent(); + } + + private void OnEnable() + { + Score.ScoreUpdated += OnScoreUpdated; + } + + private void OnDisable() + { + Score.ScoreUpdated -= OnScoreUpdated; + } + + private void OnScoreUpdated(ulong obj) + { + _text.text = $"{obj:n0}"; + } +} \ No newline at end of file diff --git a/Assets/Scripts/UpdateScore.cs.meta b/Assets/Scripts/UpdateScore.cs.meta new file mode 100644 index 0000000..cdaab5c --- /dev/null +++ b/Assets/Scripts/UpdateScore.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3da04f2795dd4afe8551debe01be4561 +timeCreated: 1610298154 \ No newline at end of file diff --git a/Assets/Weapons/Enemy.asset b/Assets/Weapons/Enemy.asset index 280a48d..f33f2a4 100644 --- a/Assets/Weapons/Enemy.asset +++ b/Assets/Weapons/Enemy.asset @@ -116,7 +116,7 @@ MonoBehaviour: surfaceOnly: 1 evenDistribution: 0 numSides: 3 - numPerSide: 5 + numPerSide: 10 flipVertical: 0 radius: 5 arc: 360 diff --git a/Assets/Weapons/PlayerWeapon.asset b/Assets/Weapons/PlayerWeapon.asset index 5f26453..274b54b 100644 --- a/Assets/Weapons/PlayerWeapon.asset +++ b/Assets/Weapons/PlayerWeapon.asset @@ -106,12 +106,12 @@ MonoBehaviour: m_Bits: 128 accuracy: 2 zone: - numToSpawn: 2 + numToSpawn: 4 offset: {x: 0, y: 0, z: 0} spawnType: 1 spawnDir: 0 spawnPlane: 1 - width: 1.5 + width: 0.75 height: 0 surfaceOnly: 1 evenDistribution: 1