hch
74 分钟以前 bc6f633a2f3cfc01122d8fd4452f69313ddcb32b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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<FuncPresetChangeNameWin>(funcType*100 + id);
    }
 
    void Fold(int funcType, int id)
    {
        pareant.unFoldID = 0;
        FuncPresetManager.Instance.OnSelectPresetEvent?.Invoke(curBattleType, funcType, id, false);
    }
 
    
}