Exemplo n.º 1
0
    public JsonEquippableItem makeJsonEquippableItem(EquippableItem item, bool isEquipped, int charID)
    {
        JsonEquippableItem newItem = new JsonEquippableItem(item.itemID, item.itemName, item.healthAdd, item.healthMulti, item.damageAdd, item.damageMulti, item.weaponRange, item.speedAdd, item.speedMulti, item.defenseAdd,
                                                            item.defenseMulti, item.criticalDamageAdd, item.criticalDamageMulti, item.criticalRateAdd, item.criticalRateMulti, isEquipped, charID, item.itemID_forAccount);

        return(newItem);
    }
Exemplo n.º 2
0
    public EquippableItem makeItemSlots(JsonEquippableItem item)
    {
        string itemID = item.itemID;

        string[]       result  = itemID.Split('_');
        EquippableItem newItem = new EquippableItem();

        newItem.itemName          = item.itemName;
        newItem.itemID            = item.itemID;
        newItem.itemID_forAccount = item.itemID_forAccount;
        int type = int.Parse(result[0]);
        int id   = int.Parse(result[2]);

        print("type: " + type + "id: " + id);
        newItem.EquipmentType     = equipmentTypeToEquipmentType(type);
        newItem.icon              = Resources.Load <Sprite>("ItemDB/" + newItem.EquipmentType + "/" + id);
        newItem.healthAdd         = item.healthAdd;                     newItem.healthMulti = item.healthMulti;
        newItem.damageAdd         = item.damageAdd;                     newItem.damageMulti = item.damageMulti;
        newItem.weaponRange       = item.weaponRange;
        newItem.speedAdd          = item.speedAdd;                       newItem.speedMulti = item.speedMulti;
        newItem.defenseAdd        = item.defenseAdd;                   newItem.defenseMulti = item.defenseMulti;
        newItem.criticalDamageAdd = item.criticalDamageAdd;     newItem.criticalDamageMulti = item.criticalDamageMulti;
        newItem.criticalRateAdd   = item.criticalRateAdd;         newItem.criticalRateMulti = item.criticalRateMulti;
        return(newItem);
    }
Exemplo n.º 3
0
 public void addUnequippedItem()
 {
     for (int i = 0; i < inventory.items.Count; i++)
     {
         if (inventory.items[i].itemName != null)
         {
             // Debug.Log("inventory item: " + inventory.items[i].itemName);
             JsonEquippableItem item = makeJsonEquippableItem((EquippableItem)inventory.items[i], false, -1);
             result.Add(item);
         }
     }
     print("unequipped itme: " + result.Count);
 }
Exemplo n.º 4
0
    public void addEquippedItem()
    {
        for (int i = 0; i < allEquippedItems.Count; i++)
        {
            characterStats[i].equippedItemIds.Clear();
            for (int j = 0; j < allEquippedItems[i].Count; j++)
            {
                JsonEquippableItem item = makeJsonEquippableItem(allEquippedItems[i][j], true, i);
                result.Add(item);
                characterStats[i].equippedItemIds.Add(item.itemID);
            }
        }

        print("equipped itme: " + result.Count);
    }
Exemplo n.º 5
0
    public void randomizeAward_Item(int stageID, GameObject award_)
    {
        AwardDB_Item        toAddAwardDB = new AwardDB_Item();
        List <AwardDB_Item> AwardDB      = new List <AwardDB_Item>();

        JsonEquippableItem        toAddItem     = new JsonEquippableItem();
        List <JsonEquippableItem> JsonItemsList = new List <JsonEquippableItem>();
        string jsonData;

        try
        {
            jsonData = File.ReadAllText(Application.dataPath + "/Resources/Json_GameInfo/StageAwards/" + stageID + "/AwardDB_Item.json");
            AwardDB  = JsonConvert.DeserializeObject <List <AwardDB_Item> >(jsonData);
        }
        catch (System.Exception)
        {
            print("errrrrrrrrrrrrror");
        }

        //AwardDB는 총 뽑을 수 있는 놈.
        int selectedIndex = Random.Range(0, AwardDB.Count);

        string[] split_itemTotalID_toString = AwardDB[selectedIndex].itemTotalID.Split('_');
        // X_X_X_X니까 이 Array의 Length는 4가 될 것임.
        int[] split_itemTotalID = new int[4];
        for (int i = 0; i < split_itemTotalID_toString.Length; i++)
        {//int로 바꿔주자.
            split_itemTotalID[i] = int.Parse(split_itemTotalID_toString[i]);
        }
        // itemType rarity itemUniqueID itemPrefabID
        // 0-Helmet 1-Chest 2-Gloves    3-Boots 4-Weapon    5-Potion    6-Accessory

        int AccountID = GameObject.Find("PassStageInfoBetweenScenes_dontDestroy").GetComponent <passDataBetweenScene>().AccountID;

        jsonData      = File.ReadAllText(Application.dataPath + "/Resources/Json_AccountInfo/" + AccountID.ToString() + "/ItemsInfo.json");
        JsonItemsList = JsonConvert.DeserializeObject <List <JsonEquippableItem> >(jsonData);

        toAddItem.itemID = AwardDB[selectedIndex].itemTotalID;

        //아이템 이름 정하기
        string name_rare = "";

        switch (split_itemTotalID[1])
        {
        case 0:   name_rare = "낡은 ";   break;

        case 1:   name_rare = "허름한 ";   break;

        case 2:   name_rare = "보통의 ";   break;

        case 3:   name_rare = "준수한 ";   break;

        case 4:   name_rare = "명품의 ";   break;

        case 5:   name_rare = "희귀한 ";   break;

        case 6:   name_rare = "전설의 ";   break;

        default:    break;
        }

        string name_type = "";
        string forPrefab = "";

        switch (split_itemTotalID[0])
        {
        case 0:
            forPrefab = "Helmet";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "철 헬멧";   break;

            case 1:   name_type = "천 모자";   break;

            case 2:   name_type = "가죽 모자 ";   break;

            default:    break;
            }
            break;

        case 1:
            forPrefab = "Chest";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "철 갑옷";   break;

            case 1:   name_type = "셔츠";   break;

            case 2:   name_type = "가죽 자켓";   break;

            default:    break;
            }
            break;

        case 2:
            forPrefab = "Glove";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "철 글러브";   break;

            case 1:   name_type = "가죽 장갑";   break;

            case 2:   name_type = "털장갑 ";   break;

            default:    break;
            }
            break;

        case 3:
            forPrefab = "Boots";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "짚신";   break;

            case 1:   name_type = "쪼리";   break;

            case 2:   name_type = "부츠 ";   break;

            default:    break;
            }
            break;

        case 4:
            forPrefab = "Weapon";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "원드";   break;

            case 1:   name_type = "무기2";   break;

            case 2:   name_type = "무기3 ";   break;

            default:    break;
            }
            break;

        case 5:
            forPrefab = "Potion";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "체력 포션";   break;

            case 1:   name_type = "공격력 포션";   break;

            case 2:   name_type = "방어력 포션 ";   break;

            default:    break;
            }
            break;

        case 6:
            forPrefab = "Accessory";
            switch (split_itemTotalID[2])
            {
            case 0:   name_type = "진주 목걸이";   break;

            case 1:   name_type = "진주 팔찌";   break;

            case 2:   name_type = "진주 귀걸이 ";   break;

            default:    break;
            }
            break;

        default:    break;
        }
        toAddItem.itemName            = name_rare + name_type;
        toAddItem.healthAdd           = Mathf.RoundToInt(split_itemTotalID[1] * 10 * Random.Range(2.99f, 9.99f));
        toAddItem.healthMulti         = Mathf.RoundToInt(split_itemTotalID[1] * 5 * Random.Range(1.00f, 4.00f));
        toAddItem.damageAdd           = Mathf.RoundToInt(split_itemTotalID[1] * 3 * Random.Range(1.00f, 4.00f));
        toAddItem.damageMulti         = Mathf.RoundToInt(split_itemTotalID[1] * 2 * Random.Range(1.00f, 4.00f));
        toAddItem.weaponRange         = Mathf.RoundToInt(split_itemTotalID[1] * 1 * Random.Range(1.00f, 4.00f));
        toAddItem.speedAdd            = Mathf.RoundToInt(split_itemTotalID[1] * 5 * Random.Range(1.00f, 4.00f));
        toAddItem.speedMulti          = Mathf.RoundToInt(split_itemTotalID[1] * 1 * Random.Range(1.00f, 4.00f));
        toAddItem.defenseAdd          = Mathf.RoundToInt(split_itemTotalID[1] * 5 * Random.Range(1.00f, 4.00f));
        toAddItem.defenseMulti        = Mathf.RoundToInt(split_itemTotalID[1] * 5 * Random.Range(1.00f, 4.00f));
        toAddItem.criticalDamageAdd   = Mathf.RoundToInt(split_itemTotalID[1] * 2 * Random.Range(1.00f, 4.00f));
        toAddItem.criticalDamageMulti = Mathf.RoundToInt(split_itemTotalID[1] * 5 * Random.Range(1.00f, 4.00f));
        toAddItem.criticalRateAdd     = Mathf.RoundToInt(split_itemTotalID[1] * 1 * Random.Range(1.00f, 4.00f));
        toAddItem.criticalRateMulti   = Mathf.RoundToInt(split_itemTotalID[1] * 1 * Random.Range(1.00f, 4.00f));
        toAddItem.itemEquipped        = false;
        toAddItem.charID            = -1;
        toAddItem.itemID_forAccount = JsonItemsList.Count;

        JsonItemsList.Add(toAddItem);

        string jdata = JsonConvert.SerializeObject(JsonItemsList);

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

        //그리고 itemPrefab에 매치되는 그림을 가져와주자.

        award_.transform.GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite>("ItemDB/" + forPrefab + "/" + split_itemTotalID[2].ToString());
        award_.transform.GetChild(1).GetComponent <Text>().text    = toAddItem.itemName;
    }