Esempio n. 1
0
    public void randomizeAward_Condition(int stageID, GameObject award_)
    {
        AwardDB_Condition        toAddAwardDB = new AwardDB_Condition();
        List <AwardDB_Condition> AwardDB      = new List <AwardDB_Condition>();

        Condition_CodeModifier        toAddCondition = new Condition_CodeModifier();
        List <Condition_CodeModifier> conditionList  = new List <Condition_CodeModifier>();
        string jsonData;

        try
        {
            jsonData = File.ReadAllText(Application.dataPath + "/Resources/Json_GameInfo/StageAwards/" + stageID + "/AwardDB_Condition.json");
            AwardDB  = JsonConvert.DeserializeObject <List <AwardDB_Condition> >(jsonData);
        }
        catch (System.Exception)
        {
            print("errrrrrrrrrrrrror");
        }
        //AwardDB는 총 뽑을 수 있는 놈.
        int    selectedIndex  = Random.Range(0, AwardDB.Count);
        int    theConditionID = AwardDB[selectedIndex].conditionID;
        int    theMin         = AwardDB[selectedIndex].range_min;
        int    theMax         = AwardDB[selectedIndex].range_max;
        string theUpDownOn    = AwardDB[selectedIndex].upDownOn;
        string thePrefab      = AwardDB[selectedIndex].conditionPrefab;
        int    selectedValue  = Random.Range(theMin, theMax);

        jsonData      = File.ReadAllText(Application.dataPath + "/Resources/Json_AccountInfo/" + AccountID.ToString() + "/ConditionData.json");
        conditionList = JsonConvert.DeserializeObject <List <Condition_CodeModifier> >(jsonData);

        toAddCondition.conditionID          = theConditionID;
        toAddCondition.conditionUniqueID    = conditionList.Count + 1 + 1000;
        toAddCondition.conditionName        = makeConditionName(theConditionID);
        toAddCondition.conditionDescription = makeConditionDescription(theConditionID, selectedValue);
        toAddCondition.conditionParent      = 0;
        toAddCondition.conditionPositionX   = 0f;
        toAddCondition.conditionPositionY   = 0f;
        toAddCondition.goldValue            = 888.8f;
        toAddCondition.conditionValue       = selectedValue;
        toAddCondition.conditionPrefab      = thePrefab;
        toAddCondition.conditionValueState  = theUpDownOn;
        toAddCondition.usingCharID          = -1;

        conditionList.Add(toAddCondition);

        string jdata = JsonConvert.SerializeObject(conditionList);

        jdata = JValue.Parse(jdata).ToString(Formatting.Indented);
        File.WriteAllText(Application.dataPath + "/Resources/Json_AccountInfo/" + AccountID.ToString() + "/ConditionData.json", jdata); //ID 추가해주기

        award_.transform.GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite>("CodeEditor/" + thePrefab);
        award_.transform.GetChild(1).GetComponent <Text>().text    = "조건 - " + toAddCondition.conditionDescription;
    }
Esempio n. 2
0
    public void createAward_Conditions()
    {
        //Json_GameInfo에서 StageAwards에서
        //숫자 (stage 이름)을 읽어오는 칸이 하나 필요하고
        //거기서 아이템을 읽어온다.

        stageID = int.Parse(createAward_Conditions_stageID_Text.text);

        AwardDB_Condition        toAddAwardDB = new AwardDB_Condition();
        List <AwardDB_Condition> AwardDB      = new List <AwardDB_Condition>();
        string jsonData;

        try
        {
            jsonData = File.ReadAllText(Application.dataPath + "/Resources/Json_GameInfo/StageAwards/" + stageID + "/AwardDB_Condition.json");
            AwardDB  = JsonConvert.DeserializeObject <List <AwardDB_Condition> >(jsonData);
        }
        catch (System.Exception)
        {
            print("errrrrrrrrrrrrror");
        }
        int    conditionID = 0, rangeMin = 0, rangeMax = 0;
        string upDownOn = ""; string thePrefab = "";

        conditionID = int.Parse(createAward_Conditions_conditionID_Text.text);
        rangeMin    = int.Parse(createAward_Conditions_rangeMin_Text.text);
        rangeMax    = int.Parse(createAward_Conditions_rangeMax_Text.text);
        upDownOn    = createAward_Conditions_upDownOn_Text.text;
        thePrefab   = createAward_Conditions_prefab_Text.text;

        toAddAwardDB.conditionID     = conditionID;
        toAddAwardDB.range_max       = rangeMax;
        toAddAwardDB.range_min       = rangeMin;
        toAddAwardDB.upDownOn        = upDownOn;
        toAddAwardDB.conditionPrefab = thePrefab;

        AwardDB.Add(toAddAwardDB);

        string jdata = JsonConvert.SerializeObject(AwardDB);

        jdata = JValue.Parse(jdata).ToString(Formatting.Indented);
        File.WriteAllText(Application.dataPath + "/Resources/Json_GameInfo/StageAwards/" + stageID + "/AwardDB_Condition.json", jdata);
        AssetDatabase.Refresh();
    }