Switch to new Model, Added fade light, new env, new touch hitbox, clean assets
NOT FULLI TESTED JET
This commit is contained in:
@@ -7,33 +7,33 @@ using System.Collections;
|
||||
|
||||
public class ColliderToSerial : MonoBehaviour
|
||||
{
|
||||
private Renderer cr;
|
||||
public GameObject LightManager;
|
||||
private LightManager lightManager;
|
||||
private int _insideColliderCount = 0;
|
||||
public static event Action touchDidChange;
|
||||
|
||||
private void Start()
|
||||
private int Area;
|
||||
private void Start()
|
||||
{
|
||||
cr = GetComponent<Renderer>();
|
||||
Area = Convert.ToInt32(gameObject.name);
|
||||
lightManager = LightManager.GetComponent<LightManager>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
_insideColliderCount += 1;
|
||||
Serial.SetTouch(Convert.ToInt32(gameObject.name), true);
|
||||
Serial.SetTouch(Area, true);
|
||||
touchDidChange?.Invoke();
|
||||
cr.material.color = new Color(1f, 1f, 1f, 1f);
|
||||
lightManager.UpdateLight(Area, true);
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
_insideColliderCount -= 1;
|
||||
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
|
||||
|
||||
if (_insideColliderCount == 0)
|
||||
{
|
||||
Serial.SetTouch(Convert.ToInt32(gameObject.name), false);
|
||||
Serial.SetTouch(Area, false);
|
||||
touchDidChange?.Invoke();
|
||||
cr.material.color = new Color(0f, 0f, 0f, 0f);
|
||||
lightManager.UpdateLight(Area, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LightManager : MonoBehaviour
|
||||
{
|
||||
public List<GameObject> Lights = new List<GameObject>();
|
||||
public float FadeDuration = 0.5f;
|
||||
private IEnumerator[] coroutines = new IEnumerator[240];
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public void UpdateLight(int Area, bool State)
|
||||
{
|
||||
Area -= 1;
|
||||
Material mat = Lights[Area].GetComponent<Renderer>().material;
|
||||
if (State)
|
||||
{
|
||||
|
||||
mat.SetColor("_EmissionColor", new Color(1f, 1f, 1f, 1f));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (coroutines[Area] != null)
|
||||
StopCoroutine(coroutines[Area]);
|
||||
coroutines[Area] = FadeOut(Area, mat);
|
||||
StartCoroutine(coroutines[Area]);
|
||||
}
|
||||
}
|
||||
public IEnumerator FadeOut(int Area, Material mat)
|
||||
{
|
||||
for (float time = 0f; time < FadeDuration; time += Time.deltaTime)
|
||||
{
|
||||
float p = 1 - time / FadeDuration;
|
||||
mat.SetColor("_EmissionColor", new Color(p, p, p, 1f));
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0b59e9770996c148af81fc09e30924d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -35,6 +35,7 @@ public class Serial : MonoBehaviour
|
||||
byte[] SettingData_201 = new byte[7];
|
||||
static byte[] TouchPackL = new byte[36];
|
||||
static byte[] TouchPackR = new byte[36];
|
||||
public static bool[] TouchPackAll = new bool[240];
|
||||
bool StartUp = false;
|
||||
void Start()
|
||||
{
|
||||
@@ -242,7 +243,7 @@ public class Serial : MonoBehaviour
|
||||
}
|
||||
public static void SetTouch(int Area, bool State) //set touch data 0-239
|
||||
{
|
||||
Area +=1;
|
||||
//Area +=1;
|
||||
if (Area < 121)
|
||||
{
|
||||
Area += (Area-1) / 5 * 3 + 7;
|
||||
@@ -254,6 +255,7 @@ public class Serial : MonoBehaviour
|
||||
Area += (Area-1) / 5 * 3 + 7;
|
||||
ByteHelper.SetBit(TouchPackL, Area, State);
|
||||
}
|
||||
TouchPackAll[Area] = State;
|
||||
}
|
||||
|
||||
void SetSettingData_160()
|
||||
|
||||
Reference in New Issue
Block a user