using UnityEngine; using TMPro; using UnityEngine.UI; public class AiStep : MonoBehaviour { [SerializeField] private AI aiController; [SerializeField] private UIPathEffect lightController; public void Number() { print("Title====" + AiButton.Instance.GetTitle().text); bool isGOBackButton = true; bool isDeleteButton = false; AiButton.Instance.GetModification().SetActive(false); DOIT.CloseALLPNL(); if (BoolTitle("Hi")) { ShowWindowPanel(); isGOBackButton = false; isDeleteButton = AiStep.CabinetOnScene(); } else if (BoolTitle("Windows Position")) { ShowPatioPanel(); } else if (BoolTitle("Windows")) { ShowPatioPanel(); } else if (BoolTitle("Patio")) { ShowRoomDoorPanel(); } else if (BoolTitle("Door")) { ShowOpenPanel(); } else if (BoolTitle("Open")) { ShowStovePanel(); } else if (BoolTitle("Stove")) { ShowFridgePanel(); } else if (BoolTitle("Fridge")) { SetWallsSelection(); } else if (BoolTitle("Select Walls")) { ShowDoorSelectionBase(); } else if (BoolTitle("Door base")) { ShowCounterPreferences(); } else if (BoolTitle("Counter")) { ShowFloorPreferences(); } else if (BoolTitle("Floor")) { ShowWallColorPreferences(); } else if (BoolTitle("Wall color")) { ShowIslandPreferences(); } else if (BoolTitle("Island")) { GenearateDesign(); } else if (BoolTitle("Modification")) { GenearateDesign(); } AiButton.Instance.GetGoBackButton().SetActive(isGOBackButton); AiButton.Instance.GetDeleteAllCabButton().SetActive(isDeleteButton); } //-----------------------------SHOW PABEL------------------------------- public void ShowWindowPanel() { AddTitle("Windows"); DECO_PNL.Instance.StartPNL("WINDOW"); } public void ShowPatioPanel() { AddTitle("Patio"); DECO_PNL.Instance.StartPNL("PATIO"); } public void ShowRoomDoorPanel() { AddTitle("Door"); DECO_PNL.Instance.StartPNL("DOOR"); } public void ShowOpenPanel() { AddTitle("Open"); DECO_PNL.Instance.StartPNL("OPEN"); } public void ShowStovePanel() { AddTitle("Stove"); DECO_PNL.Instance.StartPNL("STOVE"); } public void ShowFridgePanel() { AddTitle("Fridge"); DECO_PNL.Instance.StartPNL("FRIDGE"); } public void SetWallsSelection() { print("Select Walls====" + AiButton.Instance.GetTitle().text); AddTitle("Select Walls"); SceneModeManager.Instance.SetSceneMode(SceneModes.Ai); AiButton.Instance.GetPlus().SetActive(false); AiButton.Instance.GetButtonGoNext().SetActive(false); } public void ShowDoorSelectionBase() { AddTitle("Door base"); DoorCabPNL.StartPNL(); AiButton.Instance.GetPlus().SetActive(false); AiButton.Instance.GetButtonGoNext().SetActive(false); } public void ShowDoorSelectionWall() { AddTitle("Door wall"); DoorCabPNL.StartPNL(); AiButton.Instance.GetPlus().SetActive(false); AiButton.Instance.GetButtonGoNext().SetActive(false); } public static void ShowCounterPreferences() { AddTitle("Counter"); AiButton.Instance.GetSelector().SetActive(true); GameObject Button = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR", "BTNMODEL"); GameObject ListContainer = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport", "Content"); DOIT.DELETEAllObjectChild(ListContainer); for (int i = 0; i < 4; i++) { GameObject NewButton = Instantiate(Button); NewButton.transform.SetParent(ListContainer.transform, false); NewButton.SetActive(true); string IconName = "Coun" + (i + 1).ToString(); NewButton.transform.Find("Background").GetComponent().sprite = Resources.Load("Ai/" + IconName); NewButton.transform.Find("Background/Image/Text").GetComponent().text = NameOnIcon(IconName); } Set.ToggleGroupToAllChild("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport/Content"); ListContainer.transform.GetChild(0).GetComponent().isOn = true; } public void ShowFloorPreferences() { AddTitle("Floor"); //AiButton.Instance.GetSelector().SetActive(true); GameObject Button = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR", "BTNMODEL"); GameObject ListContainer = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport", "Content"); DOIT.DELETEAllObjectChild(ListContainer); for (int i = 0; i < 4; i++) { GameObject NewButton = Instantiate(Button); NewButton.transform.SetParent(ListContainer.transform, false); NewButton.SetActive(true); string IconName = "Floor" + (i + 1).ToString(); NewButton.transform.Find("Background").GetComponent().sprite = Resources.Load("Ai/" + IconName); NewButton.transform.Find("Background/Image/Text").GetComponent().text = NameOnIcon(IconName); } Set.ToggleGroupToAllChild("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport/Content"); ListContainer.transform.GetChild(2).GetComponent().isOn = true; } public void ShowWallColorPreferences() { AddTitle("Wall color"); AiButton.Instance.GetSelector().SetActive(true); GameObject Button = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR", "BTNMODEL"); GameObject ListContainer = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport", "Content"); DOIT.DELETEAllObjectChild(ListContainer); for (int i = 0; i < 6; i++) { GameObject NewButton = Instantiate(Button); NewButton.transform.SetParent(ListContainer.transform, false); NewButton.SetActive(true); string IconName = "Wall" + (i + 1).ToString(); NewButton.transform.Find("Background").GetComponent().color = Hexdecimal(IconName); NewButton.transform.Find("Background/Image/Text").GetComponent().text = NameOnIcon(IconName); } ListContainer.transform.GetChild(0).GetComponent().isOn = true; } public void ShowIslandPreferences() { AddTitle("Island"); GameObject Button = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR", "BTNMODEL"); GameObject ListContainer = Get.o2("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport", "Content"); DOIT.DELETEAllObjectChild(ListContainer); for (int i = 0; i < 5; i++) { GameObject NewButton = Instantiate(Button); NewButton.transform.SetParent(ListContainer.transform, false); NewButton.SetActive(true); string IconName = "Island" + (i).ToString(); NewButton.transform.Find("Background").GetComponent().sprite = Resources.Load("Ai/" + IconName); NewButton.transform.Find("Background/Image/Text").GetComponent().text = NameOnIcon(IconName); } Set.ToggleGroupToAllChild("Panel_SCENE/PNL/AI_PNL/SELECTOR/Model/Viewport/Content"); } public void GenearateDesign() { UIPathEffect.StartMovement(); AiButton.Instance.GetSelector().SetActive(false); AddTitle("Genarate Ai"); aiController.ProcessAi(); AiButton.Instance.GetButtonGoNext().SetActive(false); } public static void ShowModification() { //AiButton.Instance.GetButtonGoNext().SetActive(true); AiButton.Instance.GetTitle().text = AiText.Trans("Modification"); AiButton.Instance.GetModification().SetActive(true); } //-----------------------------BUTTON CLICK-------------------------------- public void Preferences() { Number(); } public void PlusClick() { if (BoolTitle("Windows") || BoolTitle("Windows Position")) { DECO_PNL.Instance.StartPNL("WINDOW"); AddTitle("Windows"); } else if (BoolTitle("Patio")) { ShowPatioPanel(); } else if (BoolTitle("Door")) { ShowRoomDoorPanel(); } else if (BoolTitle("Open")) { ShowOpenPanel(); } else if (BoolTitle("Stove")) { ShowStovePanel(); } else if (BoolTitle("Fridge")) { ShowFridgePanel(); } } public void GoBackGuide() { if (BoolTitle("Patio")) AddTitle("Hi"); else if (BoolTitle("Door")) AddTitle("Windows"); else if (BoolTitle("Open")) AddTitle("Patio"); else if (BoolTitle("Stove")) AddTitle("Door"); else if (BoolTitle("Fridge")) AddTitle("Open"); else if (BoolTitle("Select Walls")) { AddTitle("Stove"); } else if (BoolTitle("Door base")) { AddTitle("Fridge"); } else if (BoolTitle("Counter")) { AddTitle("Select Walls"); } else if (BoolTitle("Floor")) { AddTitle("Door base"); } else if (BoolTitle("Wall color")) { AddTitle("Counter"); } else if (BoolTitle("Island")) { AddTitle("Floor"); } else if (BoolTitle("Modification")) { AddTitle("Wall color"); } //DOIT.CloseALLPNL(); Number(); } public void DeleteAllCab() { AI.DeleteAllCab(); } //--------------------------------Get------------------------------------------------ public static bool BoolTitle(string Text) { return AiButton.Instance.GetTitle().text == AiText.Trans(Text); } public static void AddTitle(string Text) { AiButton.Instance.GetTitle().text = AiText.Trans(Text); } public static string NameOnIcon(string IconName) { switch (IconName) { case "Coun1": return AiText.Trans("Wood"); case "Coun2": return AiText.Trans("Granit"); case "Coun3": return AiText.Trans("Quartz"); case "Coun4": return AiText.Trans("Sintered Stone"); case "Floor1": return AiText.Trans("Wood"); case "Floor2": return AiText.Trans("Wood herringbone"); case "Floor3": return AiText.Trans("Ceramic"); case "Floor4": return AiText.Trans("Ceramic herringbone"); case "Wall1": return AiText.Trans("White"); case "Wall2": return AiText.Trans("Yellow"); case "Wall3": return AiText.Trans("Blue"); case "Wall4": return AiText.Trans("Red"); case "Wall5": return AiText.Trans("Green"); case "Wall6": return AiText.Trans("Black"); case "Island0": return AiText.Trans("None"); case "Island1": return AiText.Trans("Standard"); case "Island2": return AiText.Trans("Cascade"); case "Island3": return AiText.Trans("Double"); case "Island4": return AiText.Trans("Projection"); default: return IconName; // ou une valeur par défaut comme "" ou "Unknown" } } public Color Hexdecimal(string IconName) { switch (IconName) { case "Wall1": return DOIT.CSc("#ffffff", 255); case "Wall2": return DOIT.CSc("#EBE2B3", 255); case "Wall3": return DOIT.CSc("#B3BEC9", 255); case "Wall4": return DOIT.CSc("#E0ACAC", 255); case "Wall5": return DOIT.CSc("#AED9C7", 255); case "Wall6": return DOIT.CSc("#666666", 255); default: return DOIT.CSc("ffffff", 255); // ou une valeur par défaut comme "" ou "Unknown" } } //--------------------------------Modification------------------------------------------------ public void Modification(string Name) { print("name===========" + Name); switch (Name) { case "Door Base": DoorCabPNL.StartPNL(); break; case "Door Wall": DoorCabPNL.StartPNL(); break; case "Door Island": DoorCabPNL.StartPNL(); break; case "Countertop": TEXTURESPNL.Startpnl("Counter"); break; case "BackSplash": TEXTURESPNL.Startpnl("Splash"); break; case "Floor": TEXTURESPNL.Startpnl("FLOOR"); break; case "PAnel": TEXTURESPNL.Startpnl("PANEL"); break; } } public static bool CabinetOnScene() { for (int i = 0; i < _G.OBJnum; i++) { if (DOIT.exist(i) && _G.OBJs[i][0].Contains("cabi"))return true; } return false; } }