You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
4.9 KiB
196 lines
4.9 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Experimental.VFX;
|
|
using UnityEngine.UI;
|
|
using UltraCombos.Configuration;
|
|
using TUIO;
|
|
|
|
public class DebugUI : MonoBehaviour
|
|
{
|
|
public bool debugMode = true;
|
|
public GameObject debugUI;
|
|
public VisualEffect vfx;
|
|
public VisualEffect ice_vfx;
|
|
public GameObject baseEmitter;
|
|
public GameObject target;
|
|
public GameObject emitter;
|
|
public GameObject button;
|
|
public string stat = "wait";
|
|
|
|
[Config]
|
|
[Range(0f, 5f)]
|
|
public float Emitter_x = 2.5f;
|
|
|
|
[Config]
|
|
[Range(-5f, 0f)]
|
|
public float Target_x = -2.5f;
|
|
|
|
[Config]
|
|
[Range(-3f, 3f)]
|
|
public float Common_z = 0f;
|
|
|
|
[Config]
|
|
[Range(0f, 0.02f)]
|
|
public float growingSpeed;
|
|
|
|
[Config]
|
|
[Range(10, 30)]
|
|
public float fadeSpeed;
|
|
|
|
[Config]
|
|
[Range(0f, 0.5f)]
|
|
public float smooth;
|
|
|
|
float spawn_t;
|
|
float total_t;
|
|
float lerp_val;
|
|
Vector3 final_pos;
|
|
bool showObject;
|
|
int cur_blob_count, pre_blob_count;
|
|
|
|
void Start()
|
|
{
|
|
stat = "wait";
|
|
debugUI.SetActive(debugMode);
|
|
button.GetComponent<Text>().text = stat;
|
|
spawn_t = 0;
|
|
total_t = 0;
|
|
lerp_val = 0;
|
|
cur_blob_count = 0;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
pre_blob_count = cur_blob_count;
|
|
cur_blob_count = TUIOManager.Instance.touches.Count;
|
|
|
|
if(cur_blob_count == 0 && stat == "completed")
|
|
{
|
|
enterVanish();
|
|
}
|
|
else if (cur_blob_count > 0 && stat == "wait")
|
|
{
|
|
enterGrow();
|
|
}
|
|
|
|
updateVFX();
|
|
|
|
if (Input.GetKeyDown(KeyCode.A))
|
|
{
|
|
debugMode = !debugMode;
|
|
debugUI.SetActive(debugMode);
|
|
if (debugMode)
|
|
{
|
|
showObject = true;
|
|
setObjectVisible(showObject);
|
|
} else
|
|
{
|
|
showObject = false;
|
|
setObjectVisible(showObject);
|
|
}
|
|
}
|
|
else if (debugMode && Input.GetKeyDown(KeyCode.D)){
|
|
showObject = !showObject;
|
|
setObjectVisible(showObject);
|
|
}
|
|
|
|
if(stat == "growing")
|
|
{
|
|
total_t += Time.deltaTime;
|
|
lerp_val += growingSpeed;
|
|
if(lerp_val >= 1)
|
|
{
|
|
lerp_val = 1;
|
|
stat = "completed";
|
|
StartCoroutine("sendCompleted");
|
|
setButtonInteractable(true);
|
|
button.GetComponent<Text>().text = stat;
|
|
Debug.Log(stat);
|
|
}
|
|
}
|
|
else if(stat == "vanishing")
|
|
{
|
|
vfx.SetBool("isEnteringVanish", false);
|
|
lerp_val -= growingSpeed * 0.4f;
|
|
if(lerp_val <= 0)
|
|
{
|
|
lerp_val = 0;
|
|
stat = "wait";
|
|
setButtonInteractable(true);
|
|
button.GetComponent<Text>().text = stat;
|
|
Debug.Log(stat);
|
|
}
|
|
}
|
|
|
|
lerp_val = Mathf.Clamp(lerp_val, 0, 1);
|
|
ice_vfx.SetFloat("Lerp_Val", lerp_val);
|
|
|
|
Transform base_trans = baseEmitter.GetComponent<Transform>();
|
|
Transform targ_trans = target.GetComponent<Transform>();
|
|
base_trans.position = new Vector3(Emitter_x, 0, Common_z);
|
|
targ_trans.position = new Vector3(Target_x, 0, Common_z);
|
|
emitter.GetComponent<Transform>().position = Vector3.Lerp(base_trans.position, targ_trans.position, lerp_val);
|
|
}
|
|
|
|
IEnumerator sendCompleted()
|
|
{
|
|
yield return new WaitForSeconds(0.5f);
|
|
vfx.SendEvent("Completed");
|
|
}
|
|
|
|
public void switchStat()
|
|
{
|
|
if(stat == "wait")
|
|
{
|
|
enterGrow();
|
|
}
|
|
else if(stat == "completed")
|
|
{
|
|
enterVanish();
|
|
}
|
|
button.GetComponent<Text>().text = stat;
|
|
}
|
|
|
|
public void enterGrow()
|
|
{
|
|
|
|
setButtonInteractable(false);
|
|
spawn_t = total_t;
|
|
stat = "growing";
|
|
vfx.SendEvent("MouseDown");
|
|
vfx.SetBool("isGrowing", true);
|
|
button.GetComponent<Text>().text = stat;
|
|
Debug.Log(stat);
|
|
}
|
|
|
|
public void enterVanish()
|
|
{
|
|
setButtonInteractable(false);
|
|
vfx.SetBool("isEnteringVanish", true);
|
|
stat = "vanishing";
|
|
vfx.SendEvent("MouseUp");
|
|
vfx.SetBool("isGrowing", false);
|
|
button.GetComponent<Text>().text = stat;
|
|
Debug.Log(stat);
|
|
}
|
|
|
|
private void setObjectVisible(bool isShowed)
|
|
{
|
|
baseEmitter.GetComponent<Renderer>().enabled = isShowed;
|
|
target.GetComponent<Renderer>().enabled = isShowed;
|
|
emitter.GetComponent<Renderer>().enabled = isShowed;
|
|
}
|
|
|
|
private void setButtonInteractable(bool _stat)
|
|
{
|
|
button.GetComponentInParent<Button>().interactable = _stat;
|
|
}
|
|
|
|
void updateVFX()
|
|
{
|
|
vfx.SetFloat("Fade Speed", fadeSpeed);
|
|
vfx.SetFloat("Smooth", smooth);
|
|
}
|
|
}
|
|
|