2022-05-16 23:38:40 +02:00
|
|
|
using UnityEngine;
|
|
|
|
using System.IO.Ports;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Collections;
|
|
|
|
|
2022-10-03 22:48:09 +02:00
|
|
|
public class ColliderToTouch : MonoBehaviour
|
2022-05-16 23:38:40 +02:00
|
|
|
{
|
2022-10-03 02:04:54 +02:00
|
|
|
public LightManager LightManager;
|
2022-05-16 23:38:40 +02:00
|
|
|
private int _insideColliderCount = 0;
|
2022-05-25 01:29:59 +02:00
|
|
|
public static event Action touchDidChange;
|
2022-06-07 02:07:08 +02:00
|
|
|
private int Area;
|
|
|
|
private void Start()
|
2022-05-23 07:00:35 +02:00
|
|
|
{
|
2022-06-07 02:07:08 +02:00
|
|
|
Area = Convert.ToInt32(gameObject.name);
|
2022-05-23 07:00:35 +02:00
|
|
|
}
|
2022-11-07 22:31:18 +01:00
|
|
|
private void OnTriggerEnter(Collider collider)
|
2022-05-16 23:38:40 +02:00
|
|
|
{
|
|
|
|
_insideColliderCount += 1;
|
2022-10-03 22:48:09 +02:00
|
|
|
TouchManager.SetTouch(Area, true);
|
2022-05-25 01:29:59 +02:00
|
|
|
touchDidChange?.Invoke();
|
2022-10-05 22:47:49 +02:00
|
|
|
LightManager.UpdateFadeLight(Area, true);
|
2022-05-16 23:38:40 +02:00
|
|
|
}
|
|
|
|
|
2022-11-07 22:31:18 +01:00
|
|
|
private void OnTriggerExit(Collider collider)
|
2022-05-16 23:38:40 +02:00
|
|
|
{
|
|
|
|
_insideColliderCount -= 1;
|
|
|
|
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
|
|
|
|
if (_insideColliderCount == 0)
|
|
|
|
{
|
2022-10-03 22:48:09 +02:00
|
|
|
TouchManager.SetTouch(Area, false);
|
2022-05-25 01:29:59 +02:00
|
|
|
touchDidChange?.Invoke();
|
2022-10-05 22:47:49 +02:00
|
|
|
LightManager.UpdateFadeLight(Area, false);
|
2022-05-16 23:38:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|