From 41deb9511d718295b99df3632e9664680ba8ef87 Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Wed, 7 Aug 2019 21:24:22 +0300 Subject: [PATCH] Add capability to have multiple blood sprites --- Assets/Prefabs/Particles/BloodParticle (Censored).prefab | 3 +++ Assets/Prefabs/Particles/BloodParticle.prefab | 3 +++ Assets/Scripts/Effects/BloodParticle.cs | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/Assets/Prefabs/Particles/BloodParticle (Censored).prefab b/Assets/Prefabs/Particles/BloodParticle (Censored).prefab index 24e4e4f..88d1cce 100644 --- a/Assets/Prefabs/Particles/BloodParticle (Censored).prefab +++ b/Assets/Prefabs/Particles/BloodParticle (Censored).prefab @@ -124,5 +124,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3} m_Name: m_EditorClassIdentifier: + Renderer: {fileID: 1882677610630750274} LaunchForce: {x: 0, y: 0} Settled: 0 + Sprites: + - {fileID: 21300000, guid: 1a2ef685debc2114187302af36eac8fb, type: 3} diff --git a/Assets/Prefabs/Particles/BloodParticle.prefab b/Assets/Prefabs/Particles/BloodParticle.prefab index ea8a91d..5b8917a 100644 --- a/Assets/Prefabs/Particles/BloodParticle.prefab +++ b/Assets/Prefabs/Particles/BloodParticle.prefab @@ -124,5 +124,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 80990fbdf3a57074b86edf353dcec609, type: 3} m_Name: m_EditorClassIdentifier: + Renderer: {fileID: 5625006176639346186} LaunchForce: {x: 0, y: 0} Settled: 0 + Sprites: + - {fileID: 21300000, guid: ff1fce077e0aafb45be2c369b110d6e0, type: 3} diff --git a/Assets/Scripts/Effects/BloodParticle.cs b/Assets/Scripts/Effects/BloodParticle.cs index f1486c9..673df37 100644 --- a/Assets/Scripts/Effects/BloodParticle.cs +++ b/Assets/Scripts/Effects/BloodParticle.cs @@ -4,8 +4,11 @@ using UnityEngine; namespace Saltosion.OneWeapon { public class BloodParticle : MonoBehaviour { + public SpriteRenderer Renderer; + public Vector2 LaunchForce = new Vector2(); public bool Settled = false; + public Sprite[] Sprites; private Rigidbody2D CurrentlyStuckOn = null; private Vector2 Velocity; @@ -15,6 +18,9 @@ namespace Saltosion.OneWeapon { transform.localScale = new Vector2(0.02f, 0.02f) + Random.value * new Vector2(0.10f, 0.10f); Velocity = LaunchForce + new Vector2(Random.value - 0.5f, Random.value - 0.5f); GetsStuck = Random.value > 0.5; + if (Sprites.Length > 0) { + Renderer.sprite = Sprites[(int)(Random.value * int.MaxValue) % Sprites.Length]; + } } private void FixedUpdate() {