yyl
5 天以前 e40a47e6889372bfd7846d675bc931eab32220b1
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using UnityEngine.Events;
 
public class GMCmdPanel : UIBase
{
 
    [SerializeField]
    private ScrollerController _cmdCtrl;
 
    [SerializeField]
    private Button _closeBtn;
 
    GMCmdManager _cmdModel;
    GMCmdManager cmdModel{ get { return GMCmdManager.Instance; } }
 
    protected override void InitComponent()
    { 
        _closeBtn.AddListener(OnClickCloseBtn);
    }
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        _cmdCtrl.OnRefreshCell += RefreshCmdCell;
 
 
        CreateCmdCell();
    }
 
    protected override void OnOpen()
    {
        base.OnOpen();
        this.transform.SetAsLastSibling();
    }
 
 
    private void CreateCmdCell()
    {
        _cmdCtrl.Refresh();
        var allKeys = GmCmdConfig.dic.Keys;
        foreach (var key in allKeys)
        {
            _cmdCtrl.AddCell(ScrollerDataType.Header, key);
        }
        _cmdCtrl.Restart();
    }
 
    private void RefreshCmdCell(ScrollerDataType type, CellView cell)
    {
        Button cellBtn = cell.GetComponent<Button>();
        Text cmdText = cell.transform.Find("Text").GetComponent<Text>();
        GmCmdConfig gmCmdModel = GmCmdConfig.Get(cell.index);
        if (gmCmdModel == null)
            return;
 
        cmdText.text = gmCmdModel.Cmd + "=" + gmCmdModel.ParamSet;
        cellBtn.onClick.RemoveAllListeners();
        cellBtn.onClick.AddListener(() => { OnClickCmdCell(gmCmdModel.ParamSet); });
    }
 
    private void OnClickCmdCell(string paramSet)
    {
        SplitLongGMCmd(paramSet);
    }
 
    public void SplitLongGMCmd(string value)
    {
 
        string[] longCmdArray = value.Split('|');
        for (int i = 0; i < longCmdArray.Length; i++)
        {
            cmdModel.OnSendGMQuest(longCmdArray[i].Trim());
        }
 
 
    }
 
    public void OnClickCloseBtn()
    {
        CloseWindow();
    }
 
}