예제 #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() : "---");
 }