using UnityEngine;
using System.Collections;
using ArgosTweenSpacePuppy;
using VRTK;
using UnityEngine.UI;
using UnityEngine.UI.Extensions;
public class VU_UI_Panel_Interface : MonoBehaviour
{
//TEMP
public bool bPANEL_TESTER = false;
public int start_Panel = 0;
public GameObject transistion_Alpha_Plane;
public int new_Selection = 0;
public int curr_Selection = 0;
public bool bTransition_Now = false;
public float transistion_Time = 0.61803f;
private float tAccum = 0;
private UI_Ladder ui_Ladder;
public VU_UI_Panel_Control[] panelArray;
public Arch_Cube_Handler[] arch_Cube_Selectors;
public int nCOLOR_PICKER_IDX = 7;
public HSVPicker hsvPicker;
private float cam_far_Field;
void Start ()
{
ui_Ladder = GetComponent<UI_Ladder>();
transistion_Alpha_Plane.GetComponent<Renderer>().material.SetFloat("_MainTexOpacity", 1);
foreach (VU_UI_Panel_Control p in panelArray)
{
p.gameObject.SetActive(true);
}
//LOAD VALUES FROM SERIALIZE = LOAD PRESET HERE
StartCoroutine(Wait_Set_Panel());
}
IEnumerator Wait_Set_Panel()
{
yield return new WaitForSeconds(0.001f);
Select_Panel(start_Panel);
}
public bool Select_Panel(int iD)
{
if (curr_Selection != iD)
{
new_Selection = iD;
for(int i = 0; i<arch_Cube_Selectors.Length; i++)
{
if(i == new_Selection)
{
arch_Cube_Selectors[i].SetState(Arch_Cube_Handler.State.ACTIVE);
}
else
{
arch_Cube_Selectors[i].SetState(Arch_Cube_Handler.State.WAITING);
}
}
bTransition_Now = true;
tAccum = 0;
return true;
}
else
{
arch_Cube_Selectors[curr_Selection].Wiggle_Already_On();
}
return false;
}
public void onButton_Select_Forward()
{
int new_sel = curr_Selection;
if(++new_sel > panelArray.Length-1)
{
new_sel = 0;
}
Select_Panel(new_sel);
}
public void onButton_Select_Back()
{
int new_sel = curr_Selection;
if (--new_sel < 0)
{
new_sel = panelArray.Length - 1;
}
Select_Panel(new_sel);
}
bool bTransDown = true;
bool CFAPC_Last = false;//TEMP
bool bSliders_Preset_Done = false;
void Update ()
{
if (bPANEL_TESTER != CFAPC_Last)
{
onButton_Select_Forward();
CFAPC_Last = bPANEL_TESTER;
}
if (bTransition_Now)
{
tAccum += Time.deltaTime;
float t = tAccum / transistion_Time;
float alpha = 0.0001f;
//if(!bSliders_Preset_Done)
//{
// panelArray[new_Selection].PreSet_Sliders();
// bSliders_Preset_Done = true;
//}
if (t < 0.5)
{
bTransDown = true;
alpha = 1.9998f * t + 0.0001f;
//transistion_Alpha_Plane.GetComponent<Renderer>().material.SetColor("_Color", new Color(1, 1, 1, alpha));
transistion_Alpha_Plane.GetComponent<Renderer>().material.SetFloat("_MainTexOpacity", alpha);
transistion_Alpha_Plane.GetComponent<Blocking_Plate_Animation>().Fan_Transition(t);
}
else if (t > 0.5 && t < 1)
{
if (bTransDown)
{
bTransDown = false;
foreach (VU_UI_Panel_Control pA in panelArray)
{
pA.SetPanelActive(false);
pA.gameObject.SetActive(false);
}
panelArray[new_Selection].SetPanelActive(true);
panelArray[new_Selection].gameObject.SetActive(true);
curr_Selection = new_Selection;
}
alpha = 1.8f * (1 - t) + 0.2f;
transistion_Alpha_Plane.GetComponent<Renderer>().material.SetFloat("_MainTexOpacity", 0.99f);
transistion_Alpha_Plane.GetComponent<Blocking_Plate_Animation>().Fan_Transition(t);
}
else if (t > 1)
{
transistion_Alpha_Plane.GetComponent<Renderer>().material.SetFloat("_MainTexOpacity", 0.01f);
transistion_Alpha_Plane.GetComponent<Blocking_Plate_Animation>().Fan_Transition(0);
bTransition_Now = false;
bSliders_Preset_Done = false;
tAccum = 0;
}
}
}
}
