コード例 #1
0
    void GetAccountComplete(RecordAccount account)
    {
        List <RecordPet> pets = account != null ? account.pets : null;

        if (loading != null)
        {
            loading.SetActive(false);
        }

        if (pets != null)
        {
            for (int i = 0; i < pets.Count; i++)
            {
                MyPet myPet = Instantiate(myPetProto) as MyPet;
                myPet.gameObject.SetActive(true);
                myPet.Set(pets [i]);
                myPet.transform.SetParent(myPetProto.transform.parent);
                myPet.name = pets [i].id;

                if (myPets == null)
                {
                    myPets = new List <MyPet> ();
                }

                myPets.Add(myPet);

                Debug.Log("create " + myPet.name);
            }
        }

        money.text = "money: " + (account != null ? account.money.ToString() : "---");
    }
コード例 #2
0
    public void Show(RecordAccount account = null)
    {
        myPetProto.gameObject.SetActive(false);

        if (loading != null)
        {
            loading.SetActive(true);
        }

        if (myPets != null)
        {
            foreach (var pet in myPets)
            {
                Debug.Log("delete " + pet.name);
                Destroy(pet.gameObject);
            }
            myPets.Clear();
        }

        if (account != null)
        {
            GetAccountComplete(account);
        }
        else
        {
            Server.GetAccount(GetAccountComplete);
        }
    }
コード例 #3
0
    IEnumerator IEGetAccount(System.Action <RecordAccount> callback)
    {
        using (WWW www = new WWW("http://localhost:8080/getaccount")) {
            yield return(www);

            RecordAccount account = JsonConvert.DeserializeObject <RecordAccount>(www.text);
            Debug.Log(account != null ? account.ToString() : "NULL");
            callback(account);
        }
    }
コード例 #4
0
    IEnumerator IEDeletePet(string pet_id, System.Action <RecordAccount> callback)
    {
        byte[] bytes = System.Text.Encoding.UTF8.GetBytes(pet_id);
        using (WWW www = new WWW("http://localhost:8080/deletepet", bytes)) {
            yield return(www);

            RecordAccount account = JsonConvert.DeserializeObject <RecordAccount>(www.text);
            Debug.Log(account != null ? account.ToString() : "NULL");
            callback(account);
        }
    }
コード例 #5
0
    IEnumerator IECreatePet(System.Action <RecordAccount> callback)
    {
        using (WWW www = new WWW("http://localhost:8080/createpet", new byte[] { 1 })) {
            yield return(www);

            Debug.Log(www.error);
            Debug.Log(www.text);
            RecordAccount account = JsonConvert.DeserializeObject <RecordAccount>(www.text);
            Debug.Log(account != null ? account.ToString() : "NULL");
            callback(account);
        }
    }
コード例 #6
0
 void CreatePetComplete(RecordAccount account)
 {
     Show(account);
 }
コード例 #7
0
ファイル: MyPet.cs プロジェクト: Game-Graph/H18
 public void OnDeleteComplete(RecordAccount account)
 {
     MenuPets.Instance.Show();
 }
コード例 #8
0
    static void SaveAccount(RecordAccount account)
    {
        string json = JsonConvert.SerializeObject(account);

        File.WriteAllText("account", json);
    }
コード例 #9
0
ファイル: MenuFight.cs プロジェクト: Game-Graph/H18
 void UpdateMoney(RecordAccount account)
 {
     money.text = "money: " + (account != null ? account.money.ToString() : "---");
 }