public async Task buyWeapon(uint _id, ItemOwnershipContractClient OwnerClient, JsonGunState.Gun gun) { try { await ConnectToContract(); Debug.Log("buyWepon start"); await this.contract.CallAsync("buyWeapon", _id); JsonGunState jsonGunState = await OwnerClient.GetWeapons(); if (jsonGunState == null) { jsonGunState = new JsonGunState(); } jsonGunState.guns.Add(gun); await OwnerClient.setUserWeapon(jsonGunState); Debug.Log("buyWepon end"); } catch (Exception e) { Debug.Log(e); } }
public async Task sellWeapon(uint _price, ItemOwnershipContractClient OwnerClient, JsonGunState.Gun gun) { try { await ConnectToContract(); Debug.Log("SellWeapon start"); await this.contract.CallAsync("sellWeapon", _price); Debug.Log("겜매니저 컨트ㅐㄺ트 클라이언트 가격 : " + _price); Debug.Log("Sell"); JsonGunState jsonGunState = await OwnerClient.GetWeapons(); Debug.Log("Get"); if (jsonGunState == null) { return; } int i = 0; Debug.Log("find Remove"); Debug.Log(jsonGunState.guns); Debug.Log(gun.index); foreach (JsonGunState.Gun g in jsonGunState.guns) { if (g.name == gun.name) { break; } i++; } Debug.Log("sell Wepon@@@@@@@@@@@@@@:" + jsonGunState.guns[i].name); jsonGunState.guns.RemoveAt(i); Debug.Log("Remove"); await OwnerClient.setUserWeapon(jsonGunState); Debug.Log("Sell Weapon End"); } catch (Exception e) { Debug.Log(e); } }
public async Task sellWeapon(int _id, ItemOwnershipContractClient OwnerClient, BankContractClient BankClient) { try{ await ConnectToContract(); Debug.Log("sellWepon start"); JsonGunState jsonGunState = await OwnerClient.GetWeapons(); if (jsonGunState == null) { return; } jsonGunState.guns.RemoveAt(_id); await OwnerClient.setUserWeapon(jsonGunState); Debug.Log("sellWeapon End"); }catch (Exception e) { Debug.Log(e); } }