46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Lemon.GenericLib.VFX;
|
|
|
|
public class BoardVisuals : MonoBehaviour
|
|
{
|
|
|
|
[Header("Runtime")]
|
|
[Space]
|
|
[Header("Refereces")]
|
|
[SerializeField] private float shakeDuration = 0.1f;
|
|
private GameBoard gameBoard;
|
|
private CameraController cameraController;
|
|
|
|
|
|
private bool initialized = false;
|
|
|
|
private void CheckInit()
|
|
{
|
|
if (!initialized)
|
|
{
|
|
//initialization code here
|
|
gameBoard = GetComponent<GameBoard>();
|
|
cameraController = CameraController.instanceCC;
|
|
gameBoard.onDrop += shakeOnDrop;
|
|
initialized = true;
|
|
}
|
|
}
|
|
private void Start()
|
|
{
|
|
CheckInit();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
CheckInit();
|
|
gameBoard.onDrop -= shakeOnDrop;
|
|
}
|
|
|
|
private void shakeOnDrop() {
|
|
CheckInit();
|
|
if (gameBoard.controlledByPlayer) cameraController?.ApplyScreenShake(shakeDuration, true);
|
|
}
|
|
}
|