Add capability to have multiple blood sprites

This commit is contained in:
Jens Pitkänen 2019-08-07 21:24:22 +03:00
parent a24880784a
commit 41deb9511d
3 changed files with 12 additions and 0 deletions

View File

@ -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}

View File

@ -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}

View File

@ -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() {