Пример #1
0
    void Start()
    {
        initialHero  = CommonConfig.Knight;
        hasEquipment = new bool[6];
        ui.SetActive(true);
        GetHeroEquiments(initialHero);
        helmet.type = EquipmentType.Helmet;
        gloves.type = EquipmentType.Gloves;
        weapon.type = EquipmentType.Sword;
        armor.type  = EquipmentType.Armor;
        pants.type  = EquipmentType.Pants;
        shoes.type  = EquipmentType.Shoes;

        Scroller = GameObject.Find("Canvas/UnEquipments");
        if (Scroller != null)
        {
            Scroller.transform.position = new Vector3(-1000f, -1000f, 0f);

            /* ScrollViewManager manager = Scroller.GetComponent<ScrollViewManager>();
             * manager.ui.SetActive(false);*/
        }


        for (int i = 0; i < equipments.Count; i++)
        {
            if (equipments[i].EquipmentType == EquipmentType.Helmet)
            {
                helmet.setEquipment(equipments[i]);
                hasEquipment[0] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Gloves)
            {
                gloves.setEquipment(equipments[i]);
                hasEquipment[1] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Pants)
            {
                pants.setEquipment(equipments[i]);
                hasEquipment[4] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Shoes)
            {
                shoes.setEquipment(equipments[i]);
                hasEquipment[5] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Armor)
            {
                armor.setEquipment(equipments[i]);
                hasEquipment[3] = true;
            }
            else
            {
                weapon.setEquipment(equipments[i]);
                hasEquipment[2] = true;
            }
        }
    }
Пример #2
0
    void Start()
    {
        initialHero = CommonConfig.Knight;
        ui.SetActive(true);
        GetHeroEquiments(initialHero);
        helmet.type = EquipmentType.Helmet;
        gloves.type = EquipmentType.Gloves;
        weapon.type = EquipmentType.Sword;
        armor.type  = EquipmentType.Armor;
        pants.type  = EquipmentType.Pants;
        shoes.type  = EquipmentType.Shoes;
        changeHero(initialHero);
        Scroller = GameObject.Find("Canvas/UnEquipments");
        if (Scroller != null)
        {
            Scroller.transform.position = new Vector3(-1000f, -1000f, 0f);
        }
        if (EquipmentManager.instance.getHeroEquipment("knight").Count == 0 && EquipmentStorage.hasNeverUsed == false)
        {
            addInitialEquipment();
        }

        for (int i = 0; i < equipments.Count; i++)
        {
            if (equipments[i].EquipmentType == EquipmentType.Helmet)
            {
                helmet.setEquipment(equipments[i]);
                hasEquipment[0] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Gloves)
            {
                gloves.setEquipment(equipments[i]);
                hasEquipment[1] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Pants)
            {
                pants.setEquipment(equipments[i]);
                hasEquipment[4] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Shoes)
            {
                shoes.setEquipment(equipments[i]);
                hasEquipment[5] = true;
            }
            else if (equipments[i].EquipmentType == EquipmentType.Armor)
            {
                armor.setEquipment(equipments[i]);
                hasEquipment[3] = true;
            }
            else
            {
                weapon.setEquipment(equipments[i]);
                hasEquipment[2] = true;
            }
        }
    }
Пример #3
0
    public void ShowUnEquipped(EquipmentType type)
    {
        for (int i = 0; i < list.Count; i++)
        {
            Destroy(list[i]);
        }
        if (temp == null)
        {
            temp = new GameObject();
            temp.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 5.0f;
            temp.AddComponent <TextMesh>();
            var style = temp.GetComponent <TextMesh>();
            style.text     = "You don't have this type of equipments.";
            style.anchor   = TextAnchor.MiddleCenter;
            style.fontSize = 8;
            style.color    = Color.black;
        }
        temp.SetActive(false);
        equipments = EquipmentManager.instance.getUnequippedEquipment(type);
        if (equipments == null || equipments.Count == 0)
        {
            temp.SetActive(true);
            ui.SetActive(true);
            return;
        }

        int r = 0;
        int c = 0;

        for (int i = 0; i < equipments.Count; i++)
        {
            GameObject      singleEuipmentGo = (GameObject)Instantiate(prefab, transform.position, transform.rotation);
            SingleEquipment single           = singleEuipmentGo.GetComponent <SingleEquipment>();
            list.Add(singleEuipmentGo);
            single.setEquipment(equipments[i]);
            if (i % 5 == 0)
            {
                r++;
                c = 0;
                single.transform.position = new Vector3(UIvector.x - 200, UIvector.y + 200 - 150 * r, UIvector.z);
                Debug.Log(UIvector.y + single.transform.localPosition.y * c);
            }
            else
            {
                c++;
                single.transform.position = new Vector3(UIvector.x - 200 + 100 * c, UIvector.y + 200 - 150 * r, UIvector.z);
            }
        }
        ui.SetActive(true);
    }
Пример #4
0
    public void Unequip()
    {
        hasClick = false;
        if (equipment == null || !equipment.isUsed)
        {
            ui.SetActive(false);
            GameObject      tempG;
            SingleEquipment tempS;
            tempG = GameObject.Find("/EquipmentUI/Equipments/Helmet");
            tempS = tempG.GetComponent <SingleEquipment>();
            tempS.ui.SetActive(true);
            tempG = GameObject.Find("/EquipmentUI/Equipments/Armor");
            tempS = tempG.GetComponent <SingleEquipment>();
            tempS.ui.SetActive(true);
            tempG = GameObject.Find("/EquipmentUI/Equipments/Pants");
            tempS = tempG.GetComponent <SingleEquipment>();
            tempS.ui.SetActive(true);
            tempG = GameObject.Find("/EquipmentUI/Equipments/Shoes");
            tempS = tempG.GetComponent <SingleEquipment>();
            tempS.ui.SetActive(true);
            tempG = GameObject.Find("/EquipmentUI/Equipments/Gloves");
            tempS = tempG.GetComponent <SingleEquipment>();
            tempS.ui.SetActive(true);
            tempG = GameObject.Find("/EquipmentUI/Equipments/Weapon");
            tempS = tempG.GetComponent <SingleEquipment>();
            tempS.ui.SetActive(true);
            for (int i = 0; i < temp.Count; i++)
            {
                Destroy(temp[i]);
            }
            temp = new List <GameObject>();
            manager.ui.SetActive(false);
            addHero();
            return;
        }
        if (equipment.isUsed)
        {
            equipment.RemoveEquipmentFromHero(equipment.hero);
            equipment.isUsed = false;
            if (equipment.EquipmentType == EquipmentType.Helmet)
            {
                GameObject      tt = GameObject.Find("/EquipmentUI/Equipments/Helmet");
                SingleEquipment t  = tt.GetComponent <SingleEquipment>();
                t.setEquipment(null);
            }
            else if (equipment.EquipmentType == EquipmentType.Armor)
            {
                GameObject      tt = GameObject.Find("/EquipmentUI/Equipments/Armor");
                SingleEquipment t  = tt.GetComponent <SingleEquipment>();
                t.setEquipment(null);
            }
            else if (equipment.EquipmentType == EquipmentType.Gloves)
            {
                GameObject      tt = GameObject.Find("/EquipmentUI/Equipments/Gloves");
                SingleEquipment t  = tt.GetComponent <SingleEquipment>();
                t.setEquipment(null);
            }
            else if (equipment.EquipmentType == EquipmentType.Pants)
            {
                GameObject      tt = GameObject.Find("/EquipmentUI/Equipments/Pants");
                SingleEquipment t  = tt.GetComponent <SingleEquipment>();
                t.setEquipment(null);
            }
            else if (equipment.EquipmentType == EquipmentType.Shoes)
            {
                GameObject      tt = GameObject.Find("/EquipmentUI/Equipments/Shoes");
                SingleEquipment t  = tt.GetComponent <SingleEquipment>();
                t.setEquipment(null);
            }
            else
            {
                GameObject      tt = GameObject.Find("/EquipmentUI/Equipments/Weapon");
                SingleEquipment t  = tt.GetComponent <SingleEquipment>();
                t.setEquipment(null);
            }
            if (temp == null || temp.Count == 0)
            {
                List <Equipment> list;
                if (equipment == null)
                {
                    if (forNull == EquipmentType.Sword || forNull == EquipmentType.Shield)
                    {
                        list = EquipmentManager.instance.getUnequippedEquipment(forNull);
                        foreach (Equipment e1 in EquipmentManager.instance.getUnequippedEquipment(EquipmentType.Shield))
                        {
                            list.Add(e1);
                        }
                    }
                    else
                    {
                        list = EquipmentManager.instance.getUnequippedEquipment(forNull);
                        Debug.Log(list.Count);
                    }
                }
                else
                {
                    list = EquipmentManager.instance.getUnequippedEquipment(equipment.EquipmentType);
                }
                manager.ui.SetActive(true);
                for (int i = 0; i < list.Count; i++)
                {
                    GameObject      Single = (GameObject)Instantiate(prefab, transform.position, transform.rotation);
                    UnEquipmentNode node   = Single.GetComponent <UnEquipmentNode>();
                    node.index    = i;
                    node.tempList = temp;
                    Single.transform.localScale = new Vector3(0.4f, 0.4f, 0.3f);
                    node.transform.position     = new Vector3(100f, 540f - 150f * i, 0f);
                    node.ui.SetActive(true);
                    node.setHero(hero);
                    temp.Add(Single);
                    node.Set(list[i]);
                    Single.transform.SetParent(manager.transform.GetChild(0).GetChild(0));
                }
                manager.ui.SetActive(true);
                set(null, equipment.EquipmentType);
            }
            else
            {
                manager.ui.SetActive(true);
                GameObject      temp1  = (GameObject)Instantiate(prefab, transform.position, transform.rotation);
                UnEquipmentNode unNode = temp1.GetComponent <UnEquipmentNode>();
                unNode.setHero(hero);
                unNode.index    = temp.Count;
                unNode.tempList = temp;
                unNode.Set(equipment);
                set(null, equipment.EquipmentType);
                Vector3 v = temp[temp.Count - 1].transform.position;
                temp1.transform.position = new Vector3(100f, v.y - 150f, 0f);
                // temp1.transform.position = new Vector3(100f, 540f - (temp.Count - 1) * 150f, 0f);
                temp1.transform.localScale = new Vector3(0.5f, 0.5f, 0.3f);
                temp1.transform.SetParent(manager.transform.GetChild(0).GetChild(0));
                temp.Add(temp1);
            }

            /*manager.ui.SetActive(true);
             * GameObject temp1 = (GameObject)Instantiate(prefab, transform.position, transform.rotation);
             * UnEquipmentNode unNode = temp1.GetComponent<UnEquipmentNode>();
             * unNode.setHero(hero);
             * unNode.index = temp.Count;
             * unNode.tempList = temp;
             * unNode.Set(equipment);
             * set(null, equipment.EquipmentType);
             * temp.Add(temp1);
             * Debug.Log(temp.Count);
             * temp1.transform.position = new Vector3(100f, 540f - (temp.Count - 1) * 150f, 0f);
             * temp1.transform.localScale = new Vector3(0.4f, 0.4f, 0.3f);
             * temp1.transform.SetParent(manager.transform.GetChild(0).GetChild(0));
             * set(null, equipment.EquipmentType);*/
            removeHero();
        }
    }