using UnityEngine; using petabytes.LTCLight; using UnityEngine.UI; using System.Data; using System.Collections.Generic; public class SettingCabinetLights : MonoBehaviour { private static GameObject _lightSettingPanel; //START PNL----------------------------------------------- public static void StartPnl() { DOIT.CloseALLPNLONLY(); if (_lightSettingPanel==null) { _lightSettingPanel=Get.o2("Canvas/Panel_SCENE/PNL","LightSetting"); } _lightSettingPanel.SetActive(true); _lightSettingPanel.transform.localPosition=new Vector3(330,0,0); int IndexADN=Get.GetObjectIndex(SceneModeManager.SelectedName); string Category = _G.OBJs[IndexADN][5][..2]; string[] Recipe=_G.OBJs[IndexADN][40].Split("?"); GameObject SPOT=Get.o2("Canvas/Panel_SCENE/PNL/LightSetting/Setting","SPOT"); GameObject NEONUNDER=Get.o2("Canvas/Panel_SCENE/PNL/LightSetting/Setting","NEONUNDER"); GameObject NEONKICK=Get.o2("Canvas/Panel_SCENE/PNL/LightSetting/Setting","NEONKICK"); GameObject NEONCOUNTER=Get.o2("Canvas/Panel_SCENE/PNL/LightSetting/Setting","NEONCOUNTER"); DOIT.AllChildOff(Get.o2("Canvas/Panel_SCENE/PNL/LightSetting","Setting")); if (Category.Contains("W") || Category.Contains("ho")){ SPOT.SetActive(true); SPOT.transform.Find("SpotLight").GetComponent().isOn=Recipe[0].Split("_")[0]=="On"; NEONUNDER.SetActive(true); NEONUNDER.transform.Find("NeonUnder").GetComponent().isOn=Recipe[1].Split("_")[0]=="On"; } else if (Category.Contains("T")){ NEONKICK.SetActive(true); NEONKICK.transform.Find("NeonKick").GetComponent().isOn=Recipe[2].Split("_")[0]=="On"; } else if (Category.Contains("B")){ NEONKICK.SetActive(true); NEONKICK.transform.Find("NeonKick").GetComponent().isOn=Recipe[2].Split("_")[0]=="On"; NEONCOUNTER.SetActive(true); NEONCOUNTER.transform.Find("NeonCounter").GetComponent().isOn=Recipe[3].Split("_")[0]=="On"; } } //TOGGLE ----------------------------------------------- public void LightToggle(GameObject O) { int IndexADN=Get.GetObjectIndex(SceneModeManager.Selected.name); string ParentName=O.transform.parent.name; bool isON = O.GetComponent().isOn; GameObject Light = Get.o2(SceneModeManager.Selected.name,O.name); if(!Light.name.Contains("Neon")) { Light.GetComponent().enabled=isON; } else { Light.GetComponent().enabled=isON; } GameObject O2=Get.o2(SceneModeManager.Selected.name, O.name + "2"); if (O2 != null) { O2.GetComponent().enabled=isON; } string OnOFF="Off"; if(isON) OnOFF="On"; if (ParentName == "SPOT"){AddtoCode(IndexADN,0,0, OnOFF);} if (ParentName == "NEONUNDER"){AddtoCode(IndexADN,1,0, OnOFF);} if (ParentName == "NEONKICK"){AddtoCode(IndexADN,2,0, OnOFF);} if (ParentName == "NEONCOUNTER"){AddtoCode(IndexADN,3,0, OnOFF);} } //INTENSITY-------------------------------------------------- public void SetIntensity(GameObject O) { string ParentName=O.transform.parent.name; print(O.name); print(" Value==="+O.GetComponent().value); float Value = O.GetComponent().value; int IndexADN=Get.GetObjectIndex(SceneModeManager.Selected.name); if (ParentName == "SPOT") { SceneModeManager.Selected.transform.Find("SpotLight").gameObject.GetComponent().intensity=Value; AddtoCode(IndexADN,0,1, Value.ToString()); } else if (ParentName == "NEONUNDER") { SceneModeManager.Selected.transform.Find("NeonUnder").gameObject.GetComponent().Intensity = new(0,Value); GameObject NeonUnder2=Get.o2(SceneModeManager.Selected.name,"NeonUnder2"); if(NeonUnder2!=null){NeonUnder2.GetComponent().Intensity = new(0,Value);} AddtoCode(IndexADN,1,1, Value.ToString()); } else if (ParentName == "NEONKICK") { SceneModeManager.Selected.transform.Find("NeonKick").gameObject.GetComponent().Intensity = new(0,Value); GameObject NeonKick2=Get.o2(SceneModeManager.Selected.name,"NeonKick2"); if(NeonKick2!=null){NeonKick2.GetComponent().Intensity = new(0,Value);} AddtoCode(IndexADN,2,1, Value.ToString()); } else if (ParentName == "NEONCOUNTER") { SceneModeManager.Selected.transform.Find("NeonCounter").gameObject.GetComponent().Intensity = new(0,Value); GameObject NeonCounter2=Get.o2(SceneModeManager.Selected.name,"NeonCounter2"); if(NeonCounter2!=null){NeonCounter2.GetComponent().Intensity = new(0,Value);} AddtoCode(IndexADN,3,1, Value.ToString()); } } //COLOR------------------------------------------------------- public void SetColor(GameObject O) { if (O.GetComponent().isOn) { string ParentName=O.transform.parent.name; int IndexADN=Get.GetObjectIndex(SceneModeManager.Selected.name); print(O.name+" Parent===="+O.transform.parent.name); Color NewColor=DOIT.CSc(O.name,255); if (ParentName == "ColorSpot") { SceneModeManager.Selected.transform.Find("SpotLight").gameObject.GetComponent().color=DOIT.CSc(O.name,255); AddtoCode(IndexADN,0,2, O.name); } else if (ParentName == "ColorUnder") { SceneModeManager.Selected.transform.Find("NeonUnder").gameObject.GetComponent().Color = NewColor; GameObject NeonUnder2=Get.o2(SceneModeManager.Selected.name,"NeonUnder2"); if(NeonUnder2!=null){NeonUnder2.GetComponent().Color = NewColor;} AddtoCode(IndexADN,1,2, O.name); } else if (ParentName == "ColorKick") { SceneModeManager.Selected.transform.Find("NeonKick").gameObject.GetComponent().Color = NewColor; GameObject NeonKick2=Get.o2(SceneModeManager.Selected.name,"NeonKick2"); if(NeonKick2!=null){NeonKick2.GetComponent().Color = NewColor;} AddtoCode(IndexADN,2,2, O.name); } else if (ParentName == "ColorCounter") { SceneModeManager.Selected.transform.Find("NeonCounter").gameObject.GetComponent().Color = NewColor; GameObject NeonCounter2=Get.o2(SceneModeManager.Selected.name,"NeonCounter2"); if(NeonCounter2!=null){NeonCounter2.GetComponent().Color = NewColor;} AddtoCode(IndexADN,3,2, O.name); } } } //AADD TO CABNETS--------------------------------------------- public static void AddSpotLight(GameObject Base,float H,string C40){ //print("C40=====" + C40); string[] c40 = C40.Split("?")[0].Split("_"); float Intensity = 15; if (c40.Length > 1) { Intensity = float.Parse(c40[1]); }; GameObject lightGameObject = new ("SpotLight"); lightGameObject.AddComponent(); lightGameObject.GetComponent().type=0; lightGameObject.transform.position = new Vector3(0, -H*0.5f+0, 0); lightGameObject.transform.eulerAngles = new Vector3(90, 0, 0); lightGameObject.transform.SetParent(Base.transform); lightGameObject.GetComponent().intensity=Intensity; lightGameObject.GetComponent().range=50; lightGameObject.GetComponent().innerSpotAngle=100; lightGameObject.GetComponent().spotAngle=179; lightGameObject.GetComponent().enabled=true; lightGameObject.GetComponent().color=DOIT.CSc(c40[2],255); lightGameObject.tag="Lights_Wall_Cabinet"; bool isOn = c40[0]=="On"; lightGameObject.GetComponent().enabled=isOn; } public static void AddNeonUnderWall(GameObject Cabinet,float W,float H,float D,string C40) { GameObject Neon = new("NeonUnder"); Neon.AddComponent(); Neon.transform.localPosition=new(0,-H*0.5f-0.5f,D*0.5f-2); Neon.transform.SetParent(Cabinet.transform); SetLightNeon(Neon,1,C40,W); Neon.tag="Lights_Wall_Cabinet"; } public static void AddNeonKickBase(GameObject Cabinet,float W,float H,float D,string C40) { GameObject Neon = new("NeonKick"); Neon.AddComponent(); Neon.transform.localPosition=new(0,-H*0.5f+4,-D*0.5f+1); Neon.transform.SetParent(Cabinet.transform); SetLightNeon(Neon,2,C40,W); Neon.tag="Lights_Wall_Cabinet"; } public static void AddNeonCounterBase(GameObject Cabinet,float W,float H,float D,string C40) { GameObject Neon = new("NeonCounter"); Neon.AddComponent(); Neon.transform.localPosition=new(0,H*0.5f-0.1f,D*0.5f+1); Neon.transform.SetParent(Cabinet.transform); SetLightNeon(Neon,3,C40,W); Neon.tag="Lights_Wall_Cabinet"; } //CORNER CAB public static void AddNeonUnderCornerWall(GameObject Cabinet,Vector3 Position1,Vector3 Position2,float W,float D,float Rot1, float Rot2,string C40) { GameObject Neon = new("NeonUnder"); Neon.AddComponent(); Neon.transform.localPosition= Position1; Neon.transform.eulerAngles=new(0,Rot1,0); Neon.transform.SetParent(Cabinet.transform); SetLightNeon(Neon,1,C40,W); Neon.tag="Lights_Wall_Cabinet"; GameObject Neon2 = new("NeonUnder2"); Neon2.AddComponent(); Neon2.transform.localPosition=Position2; Neon2.transform.eulerAngles=new(0,Rot2,0); Neon2.transform.SetParent(Cabinet.transform); SetLightNeon(Neon2,1,C40,D); Neon2.tag="Lights_Wall_Cabinet"; } public static void AddNeonKickCornerBase(GameObject Cabinet,Vector3 Position1,Vector3 Position2,float W1,float W2,float Rot1, float Rot2, string C40) { GameObject Neon = new("NeonKick"); Neon.AddComponent(); Neon.transform.localPosition=Position1; Neon.transform.eulerAngles=new(0,Rot1,0); Neon.transform.SetParent(Cabinet.transform); SetLightNeon(Neon,2,C40,W1); Neon.tag="Lights_Wall_Cabinet"; if (W2 != 0){ GameObject Neon2 = new("NeonKick2"); Neon2.AddComponent(); Neon2.transform.localPosition=Position2; Neon2.transform.eulerAngles=new(0,Rot2,0); Neon2.transform.SetParent(Cabinet.transform); SetLightNeon(Neon2,2,C40,W2); Neon2.tag="Lights_Wall_Cabinet"; } } public static void AddNeonCounterCornerBase(GameObject Cabinet,Vector3 Position1,Vector3 Position2,float W,float D,float Rot1, float Rot2,string C40) { GameObject Neon = new("NeonCounter"); Neon.AddComponent(); Neon.transform.localPosition=Position1; Neon.transform.eulerAngles=new(0,Rot1,0); Neon.transform.SetParent(Cabinet.transform); SetLightNeon(Neon,3,C40,W); Neon.tag="Lights_Wall_Cabinet"; GameObject Neon2 = new("NeonCounter2"); Neon2.AddComponent(); Neon2.transform.localPosition=Position2; Neon2.transform.eulerAngles=new(0,Rot2,0); Neon2.transform.SetParent(Cabinet.transform); SetLightNeon(Neon2,3,C40,D); Neon2.tag="Lights_Wall_Cabinet"; } public static void SetLightNeon(GameObject Neon,int LightIndex,string C40,float W) { string[] c40 = C40.Split("?")[LightIndex].Split("_"); float Intensity = float.Parse(c40[1]); var Setting=Neon.GetComponent(); List PolygonPoints=new(){new(W*0.5f,0,-0.5f),new(-W*0.5f,0,-0.5f),new(-W*0.5f,0,0.5f),new(W*0.5f,0,0.5f)}; Setting.PolygonPoints = PolygonPoints; Setting.Intensity = new(0,Intensity); Setting.Range = 25f; Setting.Color = DOIT.CSc(c40[2],255); bool isOn=c40[0]=="On"; Setting.enabled=isOn; } //SET CODE public static void AddtoCode(int IndexADN,int IndexLight,int IndexSet, string NewValue) { string Recipe =_G.OBJs[IndexADN][40]; string[] Light = Recipe.Split("?"); string[] RecipeLight = Light[IndexLight].Split("_"); RecipeLight[IndexSet] = NewValue; Light[IndexLight] = string.Join("_", RecipeLight); _G.OBJs[IndexADN][40] = string.Join("?", Light); } }