Exemple #1
0
    IEnumerator AddWeapon(string json_query, BlockController _blc)
    {
        WWW www = new WWW(json_query);

        yield return(www);

        if (www.error == null)
        {
            var      result           = JSON.Parse(www.text);
            JSONNode system           = result["system"];
            JSONNode docDefInProgress = result["system"]["weapon"];

            if (result["error"].Value != "")
            {
                Debug.Log("Json Doc Error id: " + result["error"].Value);
                yield break;
            }
            else
            {
                parrentQuene_d.gameObject.SetActive(true);

                MainResourcesController.main_titan_value      = system["titan"].AsDouble;
                MainResourcesController.main_silicone_value   = system["silicon"].AsDouble;
                MainResourcesController.main_antimatter_value = system["antimatter"].AsDouble;
                MainResourcesController.energy_used           = system["energy_used"].AsInt;
                MainResourcesController.timeNow        = result["now"].AsLong;
                MainResourcesController.weapone_update = system["weapon_update"].AsLong;

                MainResourcesController mrc = TopBlock.GetComponent <MainResourcesController>();
                mrc.ValOnTheirPlace();

                MainResourcesController.docDefInProgress.Clear();
                for (int i = 0; i < docDefInProgress.Count; i++)
                {
                    MainResourcesController.docDefInProgress.Add(new DocDefInProgress(
                                                                     docDefInProgress[i]["system_id"].AsInt,
                                                                     docDefInProgress[i]["element_id"].AsInt,
                                                                     docDefInProgress[i]["count"].AsInt));
                }

                GameObject.Find("DocDef").GetComponent <DocOnEnabled>().StartThis();

                yield return(null);
            }
        }
        else
        {
            errorWindow.SetActive(true);
            yield break;
        }
    }
    public IEnumerator GetJSON()
    {
        //Add login and pass string
        WWW www = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=login&email="+login_str+"&password="******"error"] == null)
            {
                LoginPanel.SetActive(false);
                if (isFirstLogin)
                {
                    PlayerPrefs.SetString("userLogin", login_str);
                    PlayerPrefs.SetString("userPass", pass_str);
                    PlayerPrefs.Save();
                }

                if (PlayerPrefs.HasKey("userLogin") && PlayerPrefs.HasKey("userPass"))
                    LoadingPanel.SetActive(true);

                MainResourcesController.userId = error["user_id"].AsInt;
                MainResourcesController.userToken = error["token"].Value;

                WWW www_getuser = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=getuser&token="+MainResourcesController.userToken);
                yield return www_getuser;

                result = JSON.Parse(www_getuser.text);

                current_user = result["user"];
                current_planet = result["system"];
                game_config = result["game_config"];
                system_list = result["system_list"];
                statistic = result["stats"];

                buildingsInProgress = current_planet["building"];
                researchInProgress = current_user["tech"];
                docDefInProgress = current_planet["weapon"];

                GetValForJson();
                mrc = TopBlock.GetComponent<MainResourcesController>();
                mrc.ValOnTheirPlace();
                mrc.repeatTick();
                MainResourcesController.timeNow = result["now"].AsLong;
                MainResourcesController.weapone_update = current_planet["weapon_update"].AsLong;

                xmlParser.SetActive(true);
            }
            else
            {
                // Bad Login Or Pass
                login_field.transform.FindChild("Text").GetComponent<Text>().color = red;
                login_field.GetComponent<Image>().sprite = errorLogin_sprite;
                pass_field.transform.FindChild("Text").GetComponent<Text>().color = red;
                pass_field.GetComponent<Image>().sprite = errorLogin_sprite;
                errorText_go.SetActive(true);
                errorText_go.GetComponent<Text>().text = "Ошибка:\nЕмайл или пароль введены не верно.";
            }
        }
        else
        {
            Debug.Log(www.error);
            Error.SetActive(true);
        }
    }
Exemple #3
0
    public IEnumerator GetJSON()
    {
        //Add login and pass string
        WWW www = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=login&email=" + login_str + "&password="******"error"] == null)
            {
                LoginPanel.SetActive(false);
                if (isFirstLogin)
                {
                    PlayerPrefs.SetString("userLogin", login_str);
                    PlayerPrefs.SetString("userPass", pass_str);
                    PlayerPrefs.Save();
                }

                if (PlayerPrefs.HasKey("userLogin") && PlayerPrefs.HasKey("userPass"))
                {
                    LoadingPanel.SetActive(true);
                }

                MainResourcesController.userId    = error["user_id"].AsInt;
                MainResourcesController.userToken = error["token"].Value;

                WWW www_getuser = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=getuser&token=" + MainResourcesController.userToken);
                yield return(www_getuser);

                result = JSON.Parse(www_getuser.text);

                current_user   = result["user"];
                current_planet = result["system"];
                game_config    = result["game_config"];
                system_list    = result["system_list"];
                statistic      = result["stats"];

                buildingsInProgress = current_planet["building"];
                researchInProgress  = current_user["tech"];
                docDefInProgress    = current_planet["weapon"];


                GetValForJson();
                mrc = TopBlock.GetComponent <MainResourcesController>();
                mrc.ValOnTheirPlace();
                mrc.repeatTick();
                MainResourcesController.timeNow        = result["now"].AsLong;
                MainResourcesController.weapone_update = current_planet["weapon_update"].AsLong;

                xmlParser.SetActive(true);
            }
            else
            {
                // Bad Login Or Pass
                login_field.transform.FindChild("Text").GetComponent <Text>().color = red;
                login_field.GetComponent <Image>().sprite = errorLogin_sprite;
                pass_field.transform.FindChild("Text").GetComponent <Text>().color = red;
                pass_field.GetComponent <Image>().sprite = errorLogin_sprite;
                errorText_go.SetActive(true);
                errorText_go.GetComponent <Text>().text = "Ошибка:\nЕмайл или пароль введены не верно.";
            }
        }
        else
        {
            Debug.Log(www.error);
            Error.SetActive(true);
        }
    }
    IEnumerator DropDownItem()
    {
        WWW www = new WWW("http://vg2.v-galaktike.ru/api/?class=planet&method=getplanet&token="
                          + MainResourcesController.userToken
                          + "&system_id="
                          + MainResourcesController.currentSystemID);

        yield return(www);

        if (www.error == null)
        {
            var result = JSON.Parse(www.text);

            MainResourcesController.timeNow = result["now"].AsLong;

            current_user        = result["user"];
            current_planet      = result["system"];
            buildingsInProgress = current_planet["building"];
            researchInProgress  = current_user["tech"];
            docDefInProgress    = current_planet["weapon"];

            MainResourcesController.main_titan_value      = current_planet["titan"].AsDouble;
            MainResourcesController.main_silicone_value   = current_planet["silicon"].AsDouble;
            MainResourcesController.main_antimatter_value = current_planet["antimatter"].AsDouble;
            MainResourcesController.energy_used           = current_planet["energy_used"].AsInt;
            MainResourcesController.energy_max            = current_planet["energy_max"].AsInt;
            MainResourcesController.weapone_update        = current_planet["weapon_update"].AsLong;
            MainResourcesController mrc = TopBlock.GetComponent <MainResourcesController>();
            mrc.ValOnTheirPlace();

            if (buildingsInProgress.Count != 0)
            {
                MainResourcesController.buildingInProgress.Clear();
                MainResourcesController.buildingInProgress.Add(new BuildingsInProgress(
                                                                   buildingsInProgress["system_id"].AsInt,
                                                                   buildingsInProgress["building_id"].AsInt,
                                                                   buildingsInProgress["building_end"].AsLong,
                                                                   buildingsInProgress["building_start"].AsLong));
            }
            else
            {
                MainResourcesController.buildingListIsFull = false;
                MainResourcesController.buildingInProgress.Clear();
            }

            if (researchInProgress.Count != 0)
            {
                MainResourcesController.researchInProgress.Clear();

                MainResourcesController.researchInProgress.Add(new ResearchInProgress(
                                                                   researchInProgress["user_id"].AsInt,
                                                                   researchInProgress["tech_id"].AsInt,
                                                                   researchInProgress["tech_end"].AsLong,
                                                                   researchInProgress["tech_start"].AsLong));
            }
            else
            {
                MainResourcesController.researchInProgress.Clear();
            }

            if (docDefInProgress.Count != 0)
            {
                MainResourcesController.docDefInProgress.Clear();

                for (int i = 0; i < docDefInProgress.Count; i++)
                {
                    MainResourcesController.docDefInProgress.Add(new DocDefInProgress(
                                                                     docDefInProgress[i]["system_id"].AsInt,
                                                                     docDefInProgress[i]["element_id"].AsInt,
                                                                     docDefInProgress[i]["count"].AsInt));
                }
            }
            else
            {
                MainResourcesController.docDefInProgress.Clear();
            }

            GetValForJson();

            MainResourcesController.CreadeDictionaryBuildingsLevel();
            MainResourcesController.CreadeDictionaryResearchLevel();

            loading.SetActive(true);
            yield return(new WaitForSeconds(0.5f));

            RefreshController.R_Buildings(buildingBlocks);
            RefreshController.R_Research(researchBlocks);
            yield return(new WaitForSeconds(0.5f));

            RefreshController.R_Doc(docBlocks);
            RefreshController.R_Defc(defBlocks);
            yield return(new WaitForSeconds(0.5f));

            RefreshController.R_Technology(techBlocks);
            loading.SetActive(false);

            DwopDownBtn_close();

            if (planetBlock.activeInHierarchy)
            {
                planetBlock.GetComponent <PlanetMenuItemController>().ChangePlanet();
            }

            if (scrM.currentPanel.name == "Building")
            {
                buildingBlocks.transform.GetComponent <BuildingOnEnabled>().StartThis();
            }
            else if (scrM.currentPanel.name == "Research")
            {
                researchBlocks.transform.GetComponent <ResearchOnEnabled>().StartThis();
            }

            else if (scrM.currentPanel.name == "DocDef")
            {
                docBlocks.transform.GetComponent <DocOnEnabled>().StartThis();
            }
        }
        else
        {
            Debug.Log(www.error);
        }
    }
Exemple #5
0
    IEnumerator AddResearch(string json_query, BlockController _blc)
    {
        WWW www = new WWW(json_query);

        yield return(www);

        if (www.error == null)
        {
            var      result             = JSON.Parse(www.text);
            JSONNode system             = result["system"];
            JSONNode current_user       = result["user"];
            JSONNode researchInProgress = current_user["tech"];

            MainResourcesController.researchListIsFull = true;

            if (result["error"].Value != "")
            {
                Debug.Log("Json Building Error id: " + result["error"].Value);
                yield break;
            }
            else
            {
                parrentQuene_r.gameObject.SetActive(true);

                MainResourcesController.main_titan_value      = system["titan"].AsDouble;
                MainResourcesController.main_silicone_value   = system["silicon"].AsDouble;
                MainResourcesController.main_antimatter_value = system["antimatter"].AsDouble;
                MainResourcesController.energy_used           = system["energy_used"].AsInt;
                MainResourcesController.timeNow = result["now"].AsLong;

                MainResourcesController mrc = TopBlock.GetComponent <MainResourcesController>();
                mrc.ValOnTheirPlace();

                if (parrentQuene_r.transform.FindChild("ProgressElement(Clone)"))
                {
                    Destroy(parrentQuene_r.transform.FindChild("ProgressElement(Clone)").gameObject);
                }

                MainResourcesController.researchInProgress.Add(new ResearchInProgress(
                                                                   researchInProgress["user_id"].AsInt,
                                                                   researchInProgress["tech_id"].AsInt,
                                                                   researchInProgress["tech_end"].AsLong,
                                                                   researchInProgress["tech_start"].AsLong));

                goInstQuene_r = Instantiate(quenePrefab_r);
                goInstQuene_r.transform.SetParent(parrentQuene_r);
                goInstQuene_r.transform.localScale = new Vector3(1, 1, 1);

                QueneController qC = goInstQuene_r.GetComponent <QueneController>();
                qC.parrentBuilding     = parentGOResearch.gameObject;
                qC.queneId             = _blc.blockId;
                qC.timeToEndBuild      = researchInProgress["tech_end"].AsLong - MainResourcesController.timeNow; //_blc.timetoend
                qC.timeToEndTxt        = goInstQuene_r.transform.FindChild("TimeValue_text").GetComponent <Text>();
                qC.progress            = goInstQuene_r.transform.FindChild("Bg_image").GetComponent <Image>();
                qC.progress.fillAmount = 1f - _blc.timeToBuild / (MainResourcesController.researchInProgress[0].timeToEnd - MainResourcesController.researchInProgress[0].startTime);
                qC.TickResearch();
                yield break;
            }
        }
        else
        {
            Debug.Log(www.error);
            errorWindow.SetActive(true);
            yield break;
        }
    }