Files
2026-02-21 16:45:37 +08:00

88 lines
1.7 KiB
C#

using BitStrap;
using UnityEngine;
public class Junk : MonoBehaviour
{
public enum JunkType
{
NEUTRAL = 0,
GOOD = 1,
BAD = 2,
HOOK_MATERIAL = 3,
COUNT = 4
}
public enum JunkSize
{
SMALL = 0,
MEDIUM = 1
}
public enum JunkItem
{
NONE = 0,
BEER = 1,
GRENADE = 2,
MISSILE = 3,
HOOK_MATERIAL = 4
}
public JunkType junkType;
public JunkSize junkSize = JunkSize.MEDIUM;
public JunkItem junkItem;
public string junkItemId = string.Empty;
public string junkName = "Junk";
public Transform hookPosition;
public float weight = 1f;
public float price = 10f;
[ReadOnly]
public int experience = 10;
public float cost;
public float parameter;
public ParticleSystem particleExplosion;
public string soundExplosion = "Explosion_01";
[HideInInspector]
public bool isExploding;
[Space(10f)]
public Vector3 watchRotation = Vector3.zero;
public Vector3 rotationAxis = new Vector3(0f, 1f, 0f);
private void Start()
{
experience = Mathf.RoundToInt(weight * 10f);
}
public void Explode()
{
isExploding = true;
MeshRenderer[] componentsInChildren = GetComponentsInChildren<MeshRenderer>();
MeshRenderer[] array = componentsInChildren;
foreach (MeshRenderer meshRenderer in array)
{
meshRenderer.gameObject.SetActive(false);
}
ParticleSystem particleSystem = Object.Instantiate(particleExplosion);
particleSystem.transform.parent = base.transform;
particleSystem.transform.localPosition = Vector3.zero;
particleSystem.transform.localRotation = Quaternion.identity;
Utilities.SetLayerRecursively(particleSystem.gameObject, "Weapon");
particleSystem.Play(true);
AudioController.Play(soundExplosion, base.transform);
}
}