public void SendWeapon(LegacyWeaponSO wep) { if (wep != null) { StartCoroutine(SendData(wep)); } }
private IEnumerator Run() { while (target.MoveNext()) { result = (LegacyWeaponSO)target.Current; yield return(result); } }
void LevelUp() { experience -= nextLevelEXP; level++; float nxt = nextLevelEXP * (2f + ((float)level / 10f)); Debug.Log(nxt); nextLevelEXP = (int)nxt; experienceBar.maxValue = nextLevelEXP; UpgradeBaseStats(); UpdateStats(); HealOnLvlUp(); if (equipmentManager.currentWeapon is LegacyWeaponSO) { LegacyWeaponSO legacy = (LegacyWeaponSO)equipmentManager.currentWeapon; legacy.level++; legacy.damage += legacy.level; } }
IEnumerator SendData(LegacyWeaponSO wep) { string jsonStr = JsonUtility.ToJson(wep, true); var uwr = new UnityWebRequest(sendURL, "POST"); byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(jsonStr); uwr.uploadHandler = (UploadHandler) new UploadHandlerRaw(jsonToSend); uwr.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); uwr.SetRequestHeader("Content-Type", "application/json"); uwr.chunkedTransfer = false; yield return(uwr.SendWebRequest()); if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log(uwr.error); } else { Debug.Log("Form upload complete! Recieved: " + uwr.downloadHandler.text); } }