Esempio n. 1
0
        public void OnDrawConnection()
        {
            foreach (Transform item in EquipmentUIResourceManage.Instance.EquipmentPageContent.GetComponentsInChildren <Transform>())
            {
                if (item.gameObject.tag == "Line")
                {
                    Destroy(item.gameObject);
                }
            }

            EquipmentButton eqb = EquipmentButton.currentEquipmentButton.GetComponent <EquipmentButton>();

            if (eqb.equipmentType == EqunipmentType.SMALL)
            {
            }

            else if (eqb.equipmentType == EqunipmentType.MIDDLE)
            {
                RectTransform eqbTransform = _middleGameObjectList[eqb.equipemntId].GetComponent <RectTransform>();
                float         maxposY      = eqbTransform.localPosition.y;
                float         minposY      = eqbTransform.localPosition.y;
                float         posX         = eqbTransform.localPosition.x - buttonwidth;

                GameObject lineobj0 = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                lineobj0.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                lineobj0.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), 3f);
                lineobj0.GetComponent <RectTransform>().localPosition = new Vector2(eqbTransform.localPosition.x - buttonwidth * 3 / 4, eqbTransform.localPosition.y);

                EquipmentComponent eqcom = EquipmentFactory.Instance.GetMiddleEquipmentById(eqb.equipemntId);
                foreach (EquipmentLeaf leaf in eqcom.equipmentLeafList)
                {
                    if (!_smallGameObjectList.ContainsKey(leaf.equipmentId))
                    {
                        continue;
                    }
                    RectTransform a        = _smallGameObjectList[leaf.equipmentId].GetComponent <RectTransform>();
                    GameObject    lineobj2 = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                    lineobj2.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                    lineobj2.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), 3f);
                    lineobj2.GetComponent <RectTransform>().localPosition = new Vector2(a.localPosition.x + buttonwidth * 3 / 4, a.localPosition.y);



                    if (a.localPosition.y > maxposY)
                    {
                        maxposY = a.localPosition.y;
                    }
                    else if (a.localPosition.y < minposY)
                    {
                        minposY = a.localPosition.y;
                    }
                }

                if (eqcom.equipmentCompmenTList.Count > 0)
                {
                    foreach (EquipmentComponent compoment in eqcom.equipmentCompmenTList)
                    {
                        if (!_middleGameObjectList.ContainsKey(compoment.equipmentId))
                        {
                            continue;
                        }
                        RectTransform a        = _middleGameObjectList[compoment.equipmentId].GetComponent <RectTransform>();
                        GameObject    lineobj1 = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                        lineobj1.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                        lineobj1.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), 3f);
                        lineobj1.GetComponent <RectTransform>().localPosition = new Vector2(a.localPosition.x - buttonwidth * 3 / 4, a.localPosition.y);

                        if (a.localPosition.y > maxposY)
                        {
                            maxposY = a.localPosition.y;
                        }
                        else if (a.localPosition.y < minposY)
                        {
                            minposY = a.localPosition.y;
                        }
                    }
                }

                GameObject lineobj = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                lineobj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                lineobj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - 5), maxposY - minposY);
                lineobj.GetComponent <RectTransform>().localPosition = new Vector2(posX, (maxposY + minposY) / 2);
            }

            else if (eqb.equipmentType == EqunipmentType.BIG)
            {
                RectTransform eqbTransform = _bigGameObjectList[eqb.equipemntId].GetComponent <RectTransform>();
                float         maxposY      = eqbTransform.localPosition.y;
                float         minposY      = eqbTransform.localPosition.y;
                float         posX         = eqbTransform.localPosition.x - buttonwidth;

                GameObject lineobj0 = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                lineobj0.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                lineobj0.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), 3f);
                lineobj0.GetComponent <RectTransform>().localPosition = new Vector2(eqbTransform.localPosition.x - buttonwidth * 3 / 4, eqbTransform.localPosition.y);
                EquipmentComponent eqcom = EquipmentFactory.Instance.GetBigEquipmentById(eqb.equipemntId);

                if (eqcom.equipmentCompmenTList.Count > 0)
                {
                    foreach (EquipmentComponent compoment in eqcom.equipmentCompmenTList)
                    {
                        if (!_middleGameObjectList.ContainsKey(compoment.equipmentId))
                        {
                            continue;
                        }

                        RectTransform a        = _middleGameObjectList[compoment.equipmentId].GetComponent <RectTransform>();
                        GameObject    lineobj1 = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                        lineobj1.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                        lineobj1.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), 3f);
                        lineobj1.GetComponent <RectTransform>().localPosition = new Vector2(a.localPosition.x + buttonwidth * 3 / 4, a.localPosition.y);

                        if (a.localPosition.y > maxposY)
                        {
                            maxposY = a.localPosition.y;
                        }

                        else if (a.localPosition.y < minposY)
                        {
                            minposY = a.localPosition.y;
                        }
                    }
                }

                GameObject lineobj = Instantiate(EquipmentUIResourceManage.Instance.DrawLineInstacneObj) as GameObject;
                lineobj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                lineobj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - 5), maxposY - minposY);
                lineobj.GetComponent <RectTransform>().localPosition = new Vector2(posX, (maxposY + minposY) / 2);
            }
        }
Esempio n. 2
0
        private void InitEquipmentPage()
        {
            int   number = GetBigHeight();
            float he     = number * buttonheight + (number + 1) * buttonheight / 2;

            if (he < rectHeight)
            {
                he = rectHeight;
            }
            EquipmentUIResourceManage.Instance.EquipmentPageContent.GetComponent <RectTransform>().sizeDelta = new Vector2(0, he);
            float otherwideth;

            if (flag)
            {
                otherwideth = 0;
            }
            else
            {
                otherwideth = rectWidth / 2;
            }

            int count = 0;

            foreach (EquipmentLeaf lefeitem in _samllEquipmentList)
            {
                GameObject ga = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateObj) as GameObject;

                GameObject nameObj = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateTextObj) as GameObject;

                GameObject priceObj = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateTextObj) as GameObject;

                nameObj.GetComponent <Text>().text = lefeitem.equipmentName;

                priceObj.GetComponent <Text>().text = lefeitem.equipmentPrice.ToString();

                EquipmentButton eqb = ga.GetComponent <EquipmentButton>();
                eqb.searchType    = lefeitem.seaechType;
                eqb.equipemntId   = lefeitem.equipmentId;
                eqb.equipmentType = lefeitem.equipmentType;
                eqb.GetComponent <Image>().sprite = lefeitem.equipmentIcor;

                ga.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                ga.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth), buttonheight);
                ga.GetComponent <RectTransform>().localPosition = new Vector2(-2 * buttonwidth + otherwideth, -count * (buttonheight * 3 / 2) - buttonheight);

                nameObj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                nameObj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), buttonheight / 2);
                nameObj.GetComponent <RectTransform>().localPosition = new Vector2(-5 * buttonwidth / 4 + otherwideth, -count * (buttonheight * 3 / 2) - 3 * buttonheight / 4);

                priceObj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                priceObj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), buttonheight / 2);
                priceObj.GetComponent <RectTransform>().localPosition = new Vector2(-5 * buttonwidth / 4 + otherwideth, -count * (buttonheight * 3 / 2) - 5 * buttonheight / 4);

                _smallGameObjectList.Add(lefeitem.equipmentId, ga);
                count++;
            }

            count = 0;
            foreach (EquipmentComponent lefeitem in _middleEquipmentLis)
            {
                GameObject ga = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateObj) as GameObject;

                GameObject nameObj = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateTextObj) as GameObject;

                GameObject priceObj = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateTextObj) as GameObject;

                nameObj.GetComponent <Text>().text = lefeitem.equipmentName;

                priceObj.GetComponent <Text>().text = lefeitem.equipmentPrice.ToString();

                EquipmentButton eqb = ga.GetComponent <EquipmentButton>();
                eqb.searchType    = lefeitem.seaechType;
                eqb.equipemntId   = lefeitem.equipmentId;
                eqb.equipmentType = lefeitem.equipmentType;
                eqb.GetComponent <Image>().sprite = lefeitem.equipmentIcor;

                ga.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                ga.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth), buttonheight);
                ga.GetComponent <RectTransform>().localPosition = new Vector2(0 + otherwideth, -count * (buttonheight * 3 / 2) - buttonheight);

                nameObj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                nameObj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), buttonheight / 2);
                nameObj.GetComponent <RectTransform>().localPosition = new Vector2(3 * buttonwidth / 4 + otherwideth, -count * (buttonheight * 3 / 2) - 3 * buttonheight / 4);

                priceObj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                priceObj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), buttonheight / 2);
                priceObj.GetComponent <RectTransform>().localPosition = new Vector2(3 * buttonwidth / 4 + otherwideth, -count * (buttonheight * 3 / 2) - 5 * buttonheight / 4);

                _middleGameObjectList.Add(lefeitem.equipmentId, ga);
                count++;
            }

            count = 0;
            foreach (EquipmentComponent lefeitem in _bigEquipmentList)
            {
                GameObject ga = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateObj) as GameObject;

                GameObject nameObj = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateTextObj) as GameObject;

                GameObject priceObj = Instantiate(EquipmentUIResourceManage.Instance.EquipmentInstantiateTextObj) as GameObject;

                EquipmentButton eqb = ga.GetComponent <EquipmentButton>();

                nameObj.GetComponent <Text>().text = lefeitem.equipmentName;

                priceObj.GetComponent <Text>().text = lefeitem.equipmentPrice.ToString();

                eqb.searchType    = lefeitem.seaechType;
                eqb.equipemntId   = lefeitem.equipmentId;
                eqb.equipmentType = lefeitem.equipmentType;
                eqb.GetComponent <Image>().sprite = lefeitem.equipmentIcor;

                ga.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                ga.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth), buttonheight);
                ga.GetComponent <RectTransform>().localPosition = new Vector2(2 * buttonwidth + otherwideth, -count * (buttonheight * 3 / 2) - buttonheight);

                nameObj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                nameObj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), buttonheight / 2);
                nameObj.GetComponent <RectTransform>().localPosition = new Vector2(11 * buttonwidth / 4 + otherwideth, -count * (buttonheight * 3 / 2) - 3 * buttonheight / 4);

                priceObj.GetComponent <RectTransform>().SetParent(EquipmentUIResourceManage.Instance.EquipmentPageContent.transform);
                priceObj.GetComponent <RectTransform>().sizeDelta     = new Vector2(-(rectWidth - buttonwidth / 2), buttonheight / 2);
                priceObj.GetComponent <RectTransform>().localPosition = new Vector2(11 * buttonwidth / 4 + otherwideth, -count * (buttonheight * 3 / 2) - 5 * buttonheight / 4);

                _bigGameObjectList.Add(lefeitem.equipmentId, ga);
                count++;
            }

            flag = false;
        }
        public void OnReciveMessgaeEquipmentButton()
        {
            attributeText.text = "";
            EquipmentButton eqb = EquipmentButton.currentEquipmentButton.GetComponent <EquipmentButton>();

            switch (eqb.equipmentType)
            {
            case EqunipmentType.SMALL:
                EquipmentLeaf eleaf = EquipmentFactory.Instance.GetLeafEquipmentById(eqb.equipemntId);
                if (eleaf != null)
                {
                    iconImage.sprite = eleaf.equipmentIcor;
                    foreach (EquipmentAttribute item in eleaf.equipmentAttribute)
                    {
                        attributeText.text += (item._attributeName + ":");
                        string valuestring = "";
                        switch (item._attributeType)
                        {
                        case InscriptionSystem.AttributeValue.NUMBER:
                            valuestring = System.Math.Round(item._attributeValue, 1).ToString();
                            break;

                        case InscriptionSystem.AttributeValue.PERCENTAGE:
                            valuestring = System.Math.Round(item._attributeValue * 100, 1).ToString() + "%";
                            break;
                        }
                        attributeText.text += valuestring;
                        attributeText.text += "\n";
                    }
                    attributeText.text += "\n";
                    if (eleaf.equipmentSkill.Count > 0)
                    {
                        foreach (EquipmentSkill item in eleaf.equipmentSkill)
                        {
                            switch (item.skillType)
                            {
                            case SkillType.PASSIVE:
                                attributeText.text += ("唯一被动-" + item.skillName + ":" + item.skillDescription);
                                break;

                            case SkillType.INITIATIVE:
                                attributeText.text += ("唯一主动-" + item.skillName + ":" + item.skillDescription);
                                break;
                            }
                            attributeText.text += "\n";
                        }
                    }
                }
                break;

            case EqunipmentType.MIDDLE:
                EquipmentComponent ecomp = EquipmentFactory.Instance.GetMiddleEquipmentById(eqb.equipemntId);
                if (ecomp != null)
                {
                    iconImage.sprite = ecomp.equipmentIcor;
                    foreach (EquipmentAttribute item in ecomp.equipmentAttribute)
                    {
                        attributeText.text += (item._attributeName + ":");
                        string valuestring = "";
                        switch (item._attributeType)
                        {
                        case InscriptionSystem.AttributeValue.NUMBER:
                            valuestring = System.Math.Round(item._attributeValue, 1).ToString();
                            break;

                        case InscriptionSystem.AttributeValue.PERCENTAGE:
                            valuestring = System.Math.Round(item._attributeValue * 100, 1).ToString() + "%";
                            break;
                        }
                        attributeText.text += valuestring;
                        attributeText.text += "\n";
                    }
                    attributeText.text += "\n";
                    if (ecomp.equipmentSkill.Count > 0)
                    {
                        foreach (EquipmentSkill item in ecomp.equipmentSkill)
                        {
                            switch (item.skillType)
                            {
                            case SkillType.PASSIVE:
                                attributeText.text += ("唯一被动-" + item.skillName + ":" + item.skillDescription);
                                break;

                            case SkillType.INITIATIVE:
                                attributeText.text += ("唯一主动-" + item.skillName + ":" + item.skillDescription);
                                break;
                            }
                            attributeText.text += "\n";
                        }
                    }
                }

                break;

            case EqunipmentType.BIG:
                EquipmentComponent bigecomp = EquipmentFactory.Instance.GetBigEquipmentById(eqb.equipemntId);
                if (bigecomp != null)
                {
                    iconImage.sprite = bigecomp.equipmentIcor;
                    foreach (EquipmentAttribute item in bigecomp.equipmentAttribute)
                    {
                        attributeText.text += (item._attributeName + ":");
                        string valuestring = "";
                        switch (item._attributeType)
                        {
                        case InscriptionSystem.AttributeValue.NUMBER:
                            valuestring = System.Math.Round(item._attributeValue, 1).ToString();
                            break;

                        case InscriptionSystem.AttributeValue.PERCENTAGE:
                            valuestring = System.Math.Round(item._attributeValue * 100, 1).ToString() + "%";
                            break;
                        }
                        attributeText.text += valuestring;
                        attributeText.text += "\n";
                    }
                    attributeText.text += "\n";
                    if (bigecomp.equipmentSkill.Count > 0)
                    {
                        foreach (EquipmentSkill item in bigecomp.equipmentSkill)
                        {
                            switch (item.skillType)
                            {
                            case SkillType.PASSIVE:
                                attributeText.text += ("唯一被动-" + item.skillName + ":" + item.skillDescription);
                                break;

                            case SkillType.INITIATIVE:
                                attributeText.text += ("唯一主动-" + item.skillName + ":" + item.skillDescription);
                                break;
                            }
                            attributeText.text += "\n";
                        }
                    }
                }

                break;
            }
        }