Fix vending machine particles

This commit is contained in:
Jens Pitkänen 2019-08-14 23:20:54 +03:00
parent 97f29b1ad4
commit 9666cd5c8a
4 changed files with 26 additions and 20 deletions

View File

@ -172,8 +172,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7d43d0a4a6d1e2d46a74083bdecde13e, type: 3}
m_Name:
m_EditorClassIdentifier:
MaxHealth: 30
CurrentHealth: 30
MaxHealth: 15
CurrentHealth: 15
--- !u!114 &5951030530186631518
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -92,7 +92,7 @@ Animator:
m_GameObject: {fileID: 11699643643052994}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: e29dc16ffb250b742820ca64a9b6886f, type: 2}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
@ -230,7 +230,7 @@ MonoBehaviour:
- {fileID: 90224928841595158, guid: 09e75a2e394f38f42bd5a1437c8be0d9, type: 3}
- {fileID: 90224928841595158, guid: 7639604b8e230d5458302c542e81934d, type: 3}
DebugExplode: 0
KillOnZeroHealth: 1
Type: 1
--- !u!1 &11699643844798482
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,20 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using Saltosion.OneWeapon.Utils;
using Saltosion.OneWeapon.Player;
using Saltosion.OneWeapon.Enemies;
namespace Saltosion.OneWeapon.Effects {
public enum ExplodableType {
Blood, Debris
}
public class Explodable : MonoBehaviour {
public GameObject[] BodypartPrefabs;
public bool DebugExplode = false;
[Tooltip("This only applies if this GameObject also has the Health component.")]
public bool KillOnZeroHealth = true;
public int ParticlesPerBodypart = 70;
public ExplodableType Type;
private CameraFX CameraFX;
private PlayerFun PlayerFun;
private Health Health;
private void Start() {
foreach (GameObject Obj in BodypartPrefabs) {
@ -28,7 +28,6 @@ namespace Saltosion.OneWeapon.Effects {
CameraFX = Camera.main.GetComponent<CameraFX>();
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
Health = GetComponent<Health>();
}
private void Update() {
@ -36,10 +35,6 @@ namespace Saltosion.OneWeapon.Effects {
DebugExplode = false;
Explode(false);
}
if (Health != null && Health.CurrentHealth <= 0 && KillOnZeroHealth) {
Explode(true);
}
}
public void Explode(bool destroyGameObject) {
@ -47,10 +42,9 @@ namespace Saltosion.OneWeapon.Effects {
for (int i = 0; i < Count; i++) {
GameObject Obj = BodypartPrefabs[i];
// No body parts flying in censored mode
float DirectionRadians = Random.value * Mathf.PI * 2.0f;
Vector2 Direction = new Vector2(Mathf.Cos(DirectionRadians), Mathf.Sin(DirectionRadians));
if (!Options.CensorGore) {
if (!Options.CensorGore || Type != ExplodableType.Blood) {
GameObject NewObj = Instantiate(Obj, transform.position, new Quaternion(), null);
Rigidbody2D Bodypart = NewObj.GetComponent<Rigidbody2D>();
if (Bodypart == null) {
@ -61,8 +55,14 @@ namespace Saltosion.OneWeapon.Effects {
Bodypart.AddTorque((Random.value - 0.5f) * Force, ForceMode2D.Impulse);
}
// Blood is replaced by flowers though, no problem with that
BloodLauncher.Splatter(transform.position + (Vector3)Direction * 0.5f, Vector2.zero, 70, 50f, 360f);
switch (Type) {
case ExplodableType.Blood:
BloodLauncher.Splatter(transform.position + (Vector3)Direction * 0.5f, Vector2.zero, ParticlesPerBodypart, 50f, 360f);
break;
case ExplodableType.Debris:
BloodLauncher.DebrisExplode(transform.position + (Vector3)Direction * 0.5f, Vector2.zero, ParticlesPerBodypart, 60f, 360f);
break;
}
}
PlayerFun.Explosion(false);

View File

@ -5,19 +5,25 @@ using Saltosion.OneWeapon.Player;
using Saltosion.OneWeapon.Effects;
namespace Saltosion.OneWeapon.Enemies {
[RequireComponent(typeof(Explodable))]
public class Health : MonoBehaviour {
public float MaxHealth;
public float CurrentHealth;
private PlayerFun PlayerFun;
private Explodable Explodable;
private void Start() {
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
Explodable = GetComponent<Explodable>();
}
public void Damage(float amount, Vector2 fromDirection, bool applyPlayerDamageBoost) {
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
CurrentHealth -= amount * (1 + (applyPlayerDamageBoost ? PlayerFun.CurrentDamageBoost : 0.0f));
if (CurrentHealth <= 0) {
Explodable.Explode(true);
}
}
}
}