52 lines
1.0 KiB
C#
52 lines
1.0 KiB
C#
using UnityEngine;
|
|
|
|
public class Deck : MonoBehaviour
|
|
{
|
|
public bool isHit = false;
|
|
|
|
private int playerId = 1;
|
|
|
|
[Header("Ýôôåêòû")]
|
|
[SerializeField] private ParticleSystem[] fireEffects;
|
|
|
|
public void ApplyHit()
|
|
{
|
|
if (isHit) return;
|
|
isHit = true;
|
|
|
|
var player = transform.root.GetComponent<Player>();
|
|
if (player != null)
|
|
playerId = player.PlayerId;
|
|
|
|
SoundManager.Instance.PlayExplosion(playerId);
|
|
|
|
Ship ship = GetComponentInParent<Ship>();
|
|
if (ship != null)
|
|
ship.ExplodeDeck(transform.position);
|
|
|
|
Ignite(); // çàïóñêàåì îãîíü/äûì
|
|
}
|
|
|
|
public void Ignite()
|
|
{
|
|
foreach (var ps in fireEffects)
|
|
{
|
|
if (ps == null) continue;
|
|
|
|
ps.gameObject.SetActive(true); // åñëè èçíà÷àëüíî âûêëþ÷åíû
|
|
ps.Play();
|
|
}
|
|
}
|
|
|
|
public void Extinguish()
|
|
{
|
|
foreach (var ps in fireEffects)
|
|
{
|
|
if (ps == null) continue;
|
|
|
|
ps.Stop();
|
|
ps.Clear();
|
|
}
|
|
}
|
|
}
|