Exemple #1
0
    public GameObject ResearchPanel;//研究面板

    // Use this for initialization
    void Start()
    {
        SecBtnList = new List <GameObject> {
            SecBtnObj1, SecBtnObj2, SecBtnObj3, SecBtnObj4, SecBtnObj5, SecBtnObj6,
            SecBtnObj7, SecBtnObj8, SecBtnObj9
        };
        SecBtnInputList = new List <InputField> {
            SecInput1, SecInput2, SecInput3, SecInput4, SecInput5, SecInput6,
            SecInput7, SecInput8, SecInput9
        };

        A = BtnNum.text;
        a = int.Parse(A);

        int j = a * 10 + 1;
        int k = (a + 1) * 10;

        Button btn = FirstBtn.GetComponent <Button>();

        JsonData BtnAttribute = Load.LoadButton();

        FirstName.text = BtnAttribute[a][0].ToString();
        //FirstTitle.text = BtnAttribute[a][1].ToString();
        //FirstIntro.text = BtnAttribute[a][2].ToString();
        if (BtnAttribute[a][0].ToString() != Name)
        {
            FirstName.interactable = false;
        }
        else
        {
            FirstName.transform.SetAsLastSibling();
        }
        if (BtnAttribute[a][1].ToString() != title)
        {
            FirstTitle.interactable = false;
        }

        btn.onClick.AddListener(delegate {
            ResearchPanel.SetActive(false);
            Line.Delete();

            ButtonNum.a = a;
            ButtonNum.b = 0;
            for (int i = 11; i < 50; i++)
            {
                N.BtnN[i] = 0;//初始化二级按键的n
            }
            MasterPanel.transform.SetAsLastSibling();
            FirstBtnAdd.transform.SetAsLastSibling();
            FirstBtnEdit.transform.SetAsLastSibling();

            JsonData BtnAttribute1 = Load.LoadButton();
            FirstName.text         = BtnAttribute1[a][0].ToString();
            FirstTitle.text        = BtnAttribute1[a][1].ToString();
            FirstIntro.text        = BtnAttribute1[a][2].ToString();

            int m = 0;
            for (int i = j; i < k; i++)
            {
                SecBtnInputList[m].text = BtnAttribute1[i][0].ToString();

                if (SecBtnInputList[m].text != Name)
                {
                    SecBtnInputList[m].interactable = false;
                    SecBtnInputList[m].transform.SetAsFirstSibling();
                }
                else
                {
                    SecBtnInputList[m].interactable = true;
                    SecBtnInputList[m].transform.SetAsLastSibling();
                }
                m++;
            }

            JsonData BtnNumber = Load.LoadBtnNum();
            SecBtnNum          = int.Parse(BtnNumber[a][0].ToString());
            for (int i = 0; i < 9; i++)
            {
                SecBtnList[i].transform.localScale = new Vector3(0, 0, 0);
            }
            for (int i = 0; i < SecBtnNum; i++)
            {
                SecBtnList[i].transform.localScale = new Vector3(0.15f, 0.15f, 0);
            }
        });

        Button btnEdit = FirstBtnEdit.GetComponent <Button>();

        btnEdit.onClick.AddListener(delegate {
            FirstName.interactable = true;
            FirstName.transform.SetAsLastSibling();
            FirstTitle.interactable = true;
        });
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        Button btn = btnObj.GetComponent<Button>();
        Button btnAdd = btnAddObj.GetComponent<Button>();
        fourthButtonList = new List<GameObject> { fourthButton1, fourthButton2, fourthButton3, fourthButton4, fourthButton5,
                                                  fourthButton6, fourthButton7, fourthButton8 };

        btnAddObj.transform.SetAsFirstSibling();

        btn.onClick.AddListener(delegate ()
        {
            ButtonNum.c = 0;//可以改intro地位和对应的二级按键一样
            btnAddObj.transform.SetAsLastSibling();
        });

        btnAdd.onClick.AddListener(delegate ()
        {
            Line.Delete();

            ResearchPanel.SetActive(false);

            JsonData BtnNum = Load.LoadBtnNum();
            int fourthButtonNum = int.Parse(BtnNum[ButtonNum.b][0].ToString());//四级按键的数量
            if (fourthButtonNum < 8)
            {
                fourthButtonNum+=1;
                BtnNum[ButtonNum.b][0] = fourthButtonNum.ToString();
                Save.SaveBtnNum(BtnNum);
            }

             Vector3[] path = new Vector3[fourthButtonNum];
             if (fourthButtonNum <= 4)
             {
                 delat_y_R = (100 - 10 * fourthButtonNum) / (fourthButtonNum + 1);
             }
             else
             {
                 delat_y_R = 12f;
                 int k = fourthButtonNum;
                 k = k - 4;
                 delat_y_L = (100 - 10 * k) / (k + 1);
             }
             for (int i = 0; i < fourthButtonNum; i++)
             {
                 fourthButtonList[i].transform.localScale = new Vector3(0.13f, 0.1f, 0);
                 if (i < 4)
                 {
                     x = 20.8f;
                     y = 50 - delat_y_R * (i + 1) - 10 * i - 5;//此y都是i,j从0开始算的
                     path[i] = new Vector3(x, y, 0);
                 }
                 else if (i < 8)
                 {
                     x = -20.8f;
                     int j = i;
                     j = j - 4;
                     y = 50 - delat_y_L * (j + 1) - 10 * j - 5;
                     path[i] = new Vector3(x, y, 0);
                 }
                 fourthButtonList[i].transform.localPosition = path[i];

                 Line.Dline(StartBtnObj, fourthButtonList[i], segmentNum);
             }

         });
    }