예제 #1
0
    public void InitializeOrnamentProperty(MiniJsonObject m)
    {
        if (gameController == null)
        {
            gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
        }

        if (rfm == null)
        {
            rfm = GameObject.FindGameObjectWithTag("ResourceFileManager").GetComponent <ResourceFileManager>();
        }
        propertyType = "ornament";

        GetComponent <Button>().onClick.RemoveAllListeners();
        GetComponent <Button>().onClick.AddListener(InvokeUseThisOrnament);

        mo = m;
        serializedJsonObject = mo.ToString(); //MiniJSON.jsonEncode(m);


        wearingCode = mo.GetField("type_id", -1);

        imgName = mo.GetField("icon", "");

        lockStatus = mo.GetField("lock_status", "false");

        if (!gameController.IsPaidUser && lockStatus == "true")
        {
            //GetComponent<Button>().interactable = false; // may we need to change this..?
            transform.GetChild(0).gameObject.SetActive(true);
        }


        switch (wearingCode)
        {
        case 1:     //download female dress
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["dressFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 2:      //download female wig
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["wigFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 3:      //download female ornament
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["ornamentFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 4:      //download female shoe
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["shoeFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 5:     //download male wig
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["wigMaleDataPAth"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 6:     // download male tie
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["tieMaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        default:
        {
            break;
        }
        }

        _isInitialized = true;
        StartCoroutine(SetImage());
    }
    public void InitializeShoeProperty(string jsonString, Color sc)
    {
        if (jsonString == "" || jsonString == null)
        {
            IsInitialized = false;
            return;
        }
        MiniJsonObject m = new MiniJsonObject(jsonString);

        if (gameController == null)
        {
            gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
        }

        if (rfm == null)
        {
            rfm = GameObject.FindGameObjectWithTag("ResourceFileManager").GetComponent <ResourceFileManager>();
        }
        propertyType = "shoe";

        //GetComponent<Button>().onClick.RemoveAllListeners();
        //GetComponent<Button>().onClick.AddListener(UseThisDress);

        mo = m;
        serializedJsonObject = mo.ToString(); //MiniJSON.jsonEncode(mo);

        wearingCode = mo.GetField("type_id", -1);

        imgName = mo.GetField("icon", "");

        lockStatus = mo.GetField("lock_status", "false");

        //if (!gameController.IsPaidUser && lockStatus == "true")
        //{
        //    GetComponent<Button>().interactable = false;
        //    transform.GetChild(0).gameObject.SetActive(true);
        //}

        switch (wearingCode)
        {
        case 1:     //download female dress
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["dressFemaleDataPath"], imgName);
                //finalSavePath = Path.Combine(rfm.dataPathDict["thumb_dressFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 2:      //download female wig
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["wigFemaleDataPath"], imgName);
                //finalSavePath = Path.Combine(rfm.dataPathDict["thumb_wigFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 3:      //download female ornament
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["ornamentFemaleDataPath"], imgName);
                //finalSavePath = Path.Combine(rfm.dataPathDict["thumb_ornamentFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 4:      //download female shoe
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["shoeFemaleDataPath"], imgName);
                //finalSavePath = Path.Combine(rfm.dataPathDict["thumb_shoeFemaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 5:     //download male wig
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["wigMaleDataPAth"], imgName);
                //finalSavePath = Path.Combine(rfm.dataPathDict["thumb_wigMaleDataPAth"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        case 6:     // download male tie
        {
            if (imgName != "")
            {
                finalImageUrl = string.Format(rfm.imageUrlFormat, imgName);
                finalSavePath = Path.Combine(rfm.dataPathDict["tieMaleDataPath"], imgName);
                //finalSavePath = Path.Combine(rfm.dataPathDict["thumb_tieMaleDataPath"], imgName);


                //StartCoroutine(DownloadImage(finalImageUrl, finalSavePath));

                //UpdateDownloadInfo();
            }
            break;
        }

        default:
        {
            break;
        }
        }

        shoeColor      = new float[] { sc.r, sc.g, sc.b, sc.a };
        _isInitialized = true;
        print("successfully init shoeproperty");
        //StartCoroutine(SetImage());
    }