Exemplo n.º 1
0
    public void DrawItem(int num)
    {
        //차일드 삭제
        if (_childPool.childCount > 0)
        {
            for (var i = 0; i < _childPool.childCount; i++)
            {
                Destroy(_childPool.GetChild(i).gameObject);
            }
        }
        string tPath      = "";
        bool   textureChk = false;

        switch (num)
        {
        case 0:
            //헤어 종류
            tPath = "Items/0_Hair/";
            break;

        case 1:
            //수염 종류
            tPath = "Items/1_FaceHair/";
            break;

        case 2:
            //옷 종류
            tPath      = "Items/2_Cloth/";
            textureChk = true;
            break;

        case 3:
            //바지 종류
            tPath      = "Items/3_Pant/";
            textureChk = true;
            break;

        case 4:
            //헬멧 종류
            tPath = "Items/4_Helmet/";
            break;

        case 5:
            //갑옷 종류
            tPath      = "Items/5_Armor/";
            textureChk = true;
            break;

        case 6:
            //오른손 무기 종류
            tPath = "Items/6_Weapons/";
            break;

        case 7:
            //왼손 무기 종류
            tPath = "Items/6_Weapons/";
            break;

        case 8:
            //왼손 무기 종류
            tPath = "Items/7_Back/";
            break;
        }

        GameObject ttObj2 = Instantiate(_childItem) as GameObject;

        ttObj2.transform.SetParent(_childPool);
        ttObj2.transform.localScale = new Vector3(1, 1, 1);
        SPUM_PreviewItem ttObjST2 = ttObj2.GetComponent <SPUM_PreviewItem>();

        ttObjST2._basicImage.sprite = null;
        ttObjST2.ShowObj(-1);
        ttObjST2._managerST = this;
        ttObjST2._itemType  = num;
        ttObjST2._sprite    = null;

        if (!textureChk)
        {
            Sprite[] tObj = Resources.LoadAll <Sprite>("SPUM/SPUM_Sprites/" + tPath);
            for (var i = 0; i < tObj.Length; i++)
            {
                GameObject ttObj = Instantiate(_childItem) as GameObject;
                ttObj.transform.SetParent(_childPool);
                ttObj.transform.localScale = new Vector3(1, 1, 1);

                SPUM_PreviewItem ttObjST = ttObj.GetComponent <SPUM_PreviewItem>();
                ttObjST._basicImage.sprite = tObj[i];
                ttObjST._basicImage.SetNativeSize();
                ttObjST._basicImage.rectTransform.pivot         = new Vector2(tObj[i].pivot.x / tObj[i].rect.width, tObj[i].pivot.y / tObj[i].rect.height);
                ttObjST._basicImage.rectTransform.localPosition = Vector2.zero;
                ttObjST.ShowObj(0);
                ttObjST._managerST = this;
                ttObjST._itemType  = num;
                ttObjST._sprite    = tObj[i];
            }
        }
        else
        {
            Texture2D[] tObj = Resources.LoadAll <Texture2D>("SPUM/SPUM_Sprites/" + tPath);
            for (var i = 0; i < tObj.Length; i++)
            {
                if (tObj[i].GetType() == typeof(Texture2D))
                {
                    GameObject ttObj = Instantiate(_childItem) as GameObject;
                    ttObj.transform.SetParent(_childPool);
                    ttObj.transform.localScale = new Vector3(1, 1, 1);

                    SPUM_PreviewItem ttObjST = ttObj.GetComponent <SPUM_PreviewItem>();
                    switch (num)
                    {
                    case 2:
                        //옷 종류
                        ttObjST._clothList[0].gameObject.SetActive(false);
                        ttObjST._clothList[1].gameObject.SetActive(false);
                        ttObjST._clothList[2].gameObject.SetActive(false);

                        Sprite[] tSpriteCloth = Resources.LoadAll <Sprite>("SPUM/SPUM_Sprites/Items/2_Cloth/" + tObj[i].name);
                        for (var j = 0; j < tSpriteCloth.Length; j++)
                        {
                            switch (tSpriteCloth[j].name)
                            {
                            case "Body":
                                ttObjST._clothList[0].gameObject.SetActive(true);
                                ttObjST._clothList[0].sprite = tSpriteCloth[j];
                                break;

                            case "Left":
                                ttObjST._clothList[1].gameObject.SetActive(true);
                                ttObjST._clothList[1].sprite = tSpriteCloth[j];
                                break;

                            case "Right":
                                ttObjST._clothList[2].gameObject.SetActive(true);
                                ttObjST._clothList[2].sprite = tSpriteCloth[j];
                                break;
                            }
                        }
                        ttObjST.ShowObj(3);
                        break;

                    case 3:
                        //바지 종류
                        ttObjST._pantList[0].sprite = null;
                        ttObjST._pantList[1].sprite = null;
                        //바지
                        Sprite[] tSpritePant = Resources.LoadAll <Sprite>("SPUM/SPUM_Sprites/Items/3_Pant/" + tObj[i].name);
                        for (var j = 0; j < tSpritePant.Length; j++)
                        {
                            switch (tSpritePant[j].name)
                            {
                            case "Left":
                                ttObjST._pantList[0].sprite = tSpritePant[j];
                                break;

                            case "Right":
                                ttObjST._pantList[1].sprite = tSpritePant[j];
                                break;
                            }
                        }
                        ttObjST.ShowObj(4);
                        break;

                    case 5:
                        //갑옷 종류
                        ttObjST._armorList[0].gameObject.SetActive(false);
                        ttObjST._armorList[1].gameObject.SetActive(false);
                        ttObjST._armorList[2].gameObject.SetActive(false);

                        Sprite[] tSpriteArmor = Resources.LoadAll <Sprite>("SPUM/SPUM_Sprites/Items/5_Armor/" + tObj[i].name);

                        for (var j = 0; j < tSpriteArmor.Length; j++)
                        {
                            switch (tSpriteArmor[j].name)
                            {
                            case "Body":
                                ttObjST._armorList[0].gameObject.SetActive(true);
                                ttObjST._armorList[0].sprite = tSpriteArmor[j];
                                break;

                            case "Left":
                                ttObjST._armorList[1].gameObject.SetActive(true);
                                ttObjST._armorList[1].sprite = tSpriteArmor[j];
                                break;

                            case "Right":
                                ttObjST._armorList[2].gameObject.SetActive(true);
                                ttObjST._armorList[2].sprite = tSpriteArmor[j];
                                break;
                            }
                        }
                        ttObjST.ShowObj(2);
                        break;
                    }

                    ttObjST._managerST = this;
                    ttObjST._itemType  = num;
                    ttObjST._name      = tObj[i].name;
                }
            }
        }


        _drawItemObj.SetActive(true);
    }
Exemplo n.º 2
0
    public void OpenLoadData()
    {
        if (_prefabUnitList.Count == 0)
        {
            ToastOn("There is no any saved Unit");
            return;
        }

        if (_loadPool.childCount > 0)
        {
            for (var i = 0; i < _loadPool.childCount; i++)
            {
                Destroy(_loadPool.GetChild(i).gameObject);
            }
        }


        for (var j = 0; j < _prefabUnitList.Count; j++)
        {
            GameObject      tObj   = _prefabUnitList[j];
            SPUM_SpriteList tObjST = tObj.GetComponent <SPUM_Prefabs>()._spriteOBj;

            GameObject ttObj = Instantiate(_childItem) as GameObject;
            ttObj.transform.SetParent(_loadPool);
            ttObj.transform.localScale = new Vector3(1, 1, 1);

            SPUM_PreviewItem ttObjST = ttObj.GetComponent <SPUM_PreviewItem>();
            ttObjST.ShowObj(5);
            //아이템 연동 부분
            ttObjST._fullSetList[0].sprite = tObjST._bodyList[0].sprite;
            ttObjST._fullSetList[1].sprite = tObjST._bodyList[1].sprite;
            ttObjST._fullSetList[2].sprite = tObjST._bodyList[2].sprite;
            ttObjST._fullSetList[3].sprite = tObjST._bodyList[3].sprite;
            ttObjST._fullSetList[4].sprite = tObjST._bodyList[4].sprite;
            ttObjST._fullSetList[5].sprite = tObjST._bodyList[5].sprite;

            ttObjST._fullSetList[6].sprite = tObjST._eyeList[0].sprite;
            ttObjST._fullSetList[7].sprite = tObjST._eyeList[0].sprite;

            ttObjST._fullSetList[8].sprite  = tObjST._hairList[3].sprite;
            ttObjST._fullSetList[9].sprite  = tObjST._hairList[0].sprite;
            ttObjST._fullSetList[10].sprite = tObjST._hairList[1].sprite;

            ttObjST._fullSetList[11].sprite = tObjST._clothList[0].sprite;
            ttObjST._fullSetList[12].sprite = tObjST._clothList[1].sprite;
            ttObjST._fullSetList[13].sprite = tObjST._clothList[2].sprite;

            ttObjST._fullSetList[14].sprite = tObjST._armorList[0].sprite;
            ttObjST._fullSetList[15].sprite = tObjST._armorList[1].sprite;
            ttObjST._fullSetList[16].sprite = tObjST._armorList[2].sprite;

            ttObjST._fullSetList[17].sprite = tObjST._pantList[0].sprite;
            ttObjST._fullSetList[18].sprite = tObjST._pantList[1].sprite;

            ttObjST._fullSetList[19].sprite = tObjST._weaponList[0].sprite;
            ttObjST._fullSetList[20].sprite = tObjST._weaponList[1].sprite;

            ttObjST._fullSetList[21].sprite = tObjST._weaponList[2].sprite;
            ttObjST._fullSetList[22].sprite = tObjST._weaponList[3].sprite;

            ttObjST._fullSetList[23].sprite = tObjST._backList[0].sprite;

            //string 연동


            //색연동
            if (!tObjST._eyeList[0].gameObject.activeInHierarchy)
            {
                ttObjST._fullSetList[6].gameObject.SetActive(true);
                ttObjST._fullSetList[7].gameObject.SetActive(true);

                ttObjST._fullSetList[6].color = tObjST._eyeList[0].color;
                ttObjST._fullSetList[7].color = tObjST._eyeList[0].color;
            }
            else
            {
                ttObjST._fullSetList[6].gameObject.SetActive(false);
                ttObjST._fullSetList[7].gameObject.SetActive(false);
            }

            if (!tObjST._hairList[3].gameObject.activeInHierarchy)
            {
                ttObjST._fullSetList[8].gameObject.SetActive(true);
                ttObjST._fullSetList[8].color = tObjST._hairList[3].color;
            }
            else
            {
                ttObjST._fullSetList[8].gameObject.SetActive(false);
            }

            if (!tObjST._hairList[0].gameObject.activeInHierarchy)
            {
                ttObjST._fullSetList[9].gameObject.SetActive(true);
                ttObjST._fullSetList[9].color = tObjST._hairList[0].color;
            }
            else
            {
                ttObjST._fullSetList[9].gameObject.SetActive(true);
            }

            for (var i = 0; i < ttObjST._fullSetList.Count; i++)
            {
                ttObjST._fullSetList[i].SetNativeSize();
                if (ttObjST._fullSetList[i].sprite != null)
                {
                    ttObjST._fullSetList[i].gameObject.SetActive(true);
                    ttObjST._fullSetList[i].rectTransform.pivot = new Vector2(ttObjST._fullSetList[i].sprite.pivot.x / ttObjST._fullSetList[i].sprite.rect.width, ttObjST._fullSetList[i].sprite.pivot.y / ttObjST._fullSetList[i].sprite.rect.height);
                }
                else
                {
                    ttObjST._fullSetList[i].gameObject.SetActive(false);
                }
            }

            ttObjST._name      = _prefabUnitList[j].name;
            ttObjST._managerST = this;
            ttObjST._itemType  = 11;
            ttObjST._index     = j;
            ttObjST.DeleteButton.SetActive(true);
        }
        _loadObjCanvas.SetActive(true);
    }