using UnityEngine; using UnityEngine.UI; //方案预设 方案选择组件 public class FuncPresetChooseCell : MonoBehaviour { [SerializeField] Transform unFoldObj; //展开 [SerializeField] Transform foldObj; //折叠 在此状态也有选中非选中 [SerializeField] Image lockImg; [SerializeField] Text numText; [SerializeField] Image selectImg; [SerializeField] Button unFoldBtn; //解锁 或选中 [SerializeField] Text caseNameText; [SerializeField] Button changeNameBtn; [SerializeField] Text numUnFoldText; [SerializeField] Button foldBtn; //折叠 [SerializeField] FuncPresetChooseCells pareant; [SerializeField] Image redImg; int curBattleType; public void Display(int battleType, int funcType, int id, bool isUnFold) { curBattleType = battleType; var data = FuncPresetManager.Instance.GetFuncPreset(funcType, id); if (data == null) { return; } var selectID = FuncPresetManager.Instance.GetFuncPresetIDByBattleType(battleType, funcType); if (isUnFold) { unFoldObj.SetActive(true); foldObj.SetActive(false); caseNameText.text = data.PresetName; numUnFoldText.text = id.ToString(); changeNameBtn.AddListener(() => ChangeName(funcType, id)); foldBtn.AddListener(() => Fold(funcType, id)); } else { unFoldObj.SetActive(false); foldObj.SetActive(true); redImg.SetActive(FuncPresetManager.Instance.ShowRed(funcType, id)); unFoldBtn.AddListener(() => { if (id == selectID && pareant.unFoldID == 0) { //选中状态下点击折叠,则不折叠 pareant.unFoldID = id; } if (pareant.unFoldID == id) { FuncPresetManager.Instance.OnSelectPresetEvent?.Invoke(curBattleType, funcType, id, true); } else { if (FuncPresetManager.Instance.ClickFuncPreset(battleType, funcType, id)) { pareant.unFoldID = id; } } }); lockImg.SetActive(!data.unLock); numText.text = !data.unLock ? "" : id.ToString(); selectImg.SetActive(selectID == id); } } void ChangeName(int funcType, int id) { UIManager.Instance.OpenWindow(funcType*100 + id); } void Fold(int funcType, int id) { pareant.unFoldID = 0; FuncPresetManager.Instance.OnSelectPresetEvent?.Invoke(curBattleType, funcType, id, false); } }