コード例 #1
0
    public List <SlotData_inventory> slots = new List <SlotData_inventory>();//생성된 슬롯 칸 리스트


    // Start is called before the first frame update
    private async void Start()//상점 입장 시 아이템 목록 각각 이미지 프리팹으로 불러와서 보여줌
    {
        userPassword = GameObject.Find("GameInformationManager").GetComponent <gameInformationManager>().passwd;
        if (ItemOwnershipContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        playerWallet = LoadWallet(userPassword);
        var playerPrivateKey = playerWallet.privateKey;
        var playerPublicKey  = playerWallet.publicKey;


        Address ownershipContractAddress = Address.FromString(OwnershipContractAddress);

        this.OwnerClient = new ItemOwnershipContractClient(playerPrivateKey, playerPublicKey, ownershipContractAddress, Debug.unityLogger);

        await ConnectOwnerClient();

        GameObject slotPanel = GameObject.Find("inventorypanel");//캔버스에서 슬롯을 생성시킬 위치

        //LoadObject(prefabname);
        userPassword = GameObject.Find("GameInformationManager").GetComponent <gameInformationManager>().passwd;
    }
コード例 #2
0
    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);
        }
    }
コード例 #3
0
    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);
        }
    }
コード例 #4
0
    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);
        }
    }
コード例 #5
0
    public async Task LoadInventoryIteams()
    {
        ////인포매니저에서 비밀번호 받아옴
        infoManager  = GameObject.Find("GameInformationManager").GetComponent <gameInformationManager>();
        userPassword = infoManager.passwd;

        if (ItemOwnershipContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        playerWallet = LoadWallet(userPassword);
        var playerPrivateKey = playerWallet.privateKey;
        var playerPublicKey  = playerWallet.publicKey;

        Address ownershipContractAddress = Address.FromString(OwnershipContractAddress);

        this.OwnerClient = new ItemOwnershipContractClient(playerPrivateKey, playerPublicKey, ownershipContractAddress, Debug.unityLogger);

        await ConnectOwnerClient();

        GameObject slotPanel = GameObject.Find("inventorypanel");//캔버스에서 슬롯을 생성시킬 위치
    }
コード例 #6
0
    async void Start()//상점 입장 시 아이템 목록 각각 이미지 프리팹으로 불러와서 보여줌
    {
        Instantiate(loading, GameObject.Find("PopUpLocation").transform, false);

        ////인포매니저에서 비밀번호 받아옴
        infoManager   = GameObject.Find("GameInformationManager").GetComponent <gameInformationManager>();
        userPassword  = infoManager.passwd;
        newGunsInShop = infoManager.newGuns;



        text = GameObject.Find("Money").GetComponent <Text>();
        if (GameManagerContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        if (ItemFactoryContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        if (ItemOwnershipContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        playerWallet = LoadWallet(userPassword);
        var playerPrivateKey = playerWallet.privateKey;
        var playerPublicKey  = playerWallet.publicKey;

        Address factoryContractAddress   = Address.FromString(FactoryContractAddress);
        Address managerContractAddress   = Address.FromString(GameManagerContractAddress);
        Address ownershipContractAddress = Address.FromString(OwnershipContractAddress);

        this.FactoryClient = new ItemFactoryContractClient(playerPrivateKey, playerPublicKey, factoryContractAddress, Debug.unityLogger);
        this.OwnerClient   = new ItemOwnershipContractClient(playerPrivateKey, playerPublicKey, ownershipContractAddress, Debug.unityLogger);
        this.ManagerClient = new GameManagerContractClient(playerPrivateKey, playerPublicKey, managerContractAddress, Debug.unityLogger);


        await setUserWeapons();
        await ConnectFactoryClient();
        await ConnectManagerClient();

        slotPanel = GameObject.Find("useitempanel");//캔버스에서 슬롯을 생성시킬 위치
        int j = 0;

        foreach (JsonGunState.Gun g in this.getManagerGunState.guns)//이 슬롯들에 레이캐스트 입력 받는 컴포넌트 추가 - 선택하면 색 변하는 효과?(캔버스에 반투명 덮어씌우는 식으로?)
        {
            if (j < 10)
            {
                Debug.Log("Start Foreach  " + g.index);
                GameObject go = Instantiate(slotPrefab, slotPanel.transform, false);     //slotPrefab을 slotPanel위치에 생성
                prefabname[j] = g.name;
                priceString.GetComponent <Text>().text = g.price.ToString();
                itemName.GetComponent <Text>().text    = g.name;
                go.name = prefabname[j] + "/" + g.price; //생성된 슬롯의 이름
                SlotData slot = new SlotData();          //슬롯 객체 생성
                slot.isEmpty = true;                     //슬롯 객체 상태
                slot.slotObj = go;                       //슬롯 객체에 오브젝트 할당
                Instantiate(Resources.Load("prefabs/" + "image_" + prefabname[j]), go.transform, false);
                //현재 문자열 배열에 해당되는 오브젝트명 앞에 image를 붙여 해당 오브젝트의 이미지를 슬롯에 생성
                Instantiate(priceString, go.transform, false);
                Instantiate(itemName, go.transform, false);
                slots.Add(slot);//슬롯 추가
                j++;
            }
            else
            {
                break;
            }
        }

        money = this.tokenBalance;
        text.GetComponent <Text>().text = "보유금액:" + money;

        Destroy(GameObject.Find("Loading(Clone)").gameObject);
    }