Esempio n. 1
0
    IEnumerator Start()
    {
        loading.SetActive(true);

        foreach (var mm in allLeftBtn)
        {
            mm.interactable = true;
        }

        pathToXml = Application.dataPath + "/config.xml";
        xmlDoc    = (TextAsset)Resources.Load("config");
        MainResourcesController mrc = TopBlock.GetComponent <MainResourcesController>();

        MainResourcesController.CreadeDictionaryBuildingsLevel();
        MainResourcesController.CreadeDictionaryResearchLevel();
        mrc.CreateDictionaryResources(xmlDoc.text);
        canBuild     = Root_build_conf.LoadFromText(xmlDoc.text);
        helpTextList = Root_helper_tech.LoadFromText(xmlDoc.text);
        XmlClass buidings = new XmlClass();

        foreach (var mm in canBuild.build_conf.allow_planet.canBuildList)
        {
            StartCoroutine(BuildingsInst(goInst, buidings, mm.canBuildId));
            StartCoroutine(TechInst(goInst, buidings, mm.canBuildId));
            yield return(null);
        }

        foreach (var mm in canBuild.build_conf.allow_planet.canResearchList)
        {
            StartCoroutine(ResearchInst(goInst, buidings, mm.canResearchId));
            StartCoroutine(TechInst(goInst, buidings, mm.canResearchId));
            yield return(null);
        }

        foreach (var mm in canBuild.build_conf.allow_planet.canFleetList)
        {
            StartCoroutine(DocInst(goInst, buidings, mm.canFleetId));
            StartCoroutine(TechInst(goInst, buidings, mm.canFleetId));
            yield return(null);
        }

        foreach (var mm in canBuild.build_conf.allow_planet.canDefenseList)
        {
            StartCoroutine(DefInst(goInst, buidings, mm.canDefenseId));
            StartCoroutine(TechInst(goInst, buidings, mm.canDefenseId));
            yield return(null);
        }

        ScreenManager scr = GameObject.Find("ScreenManager").GetComponent <ScreenManager>();

        scr.currentPanel = planetBlock;

        planetBlock.SetActive(true);
        loading.SetActive(false);
    }
Esempio n. 2
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;
        }
    }
Esempio n. 3
0
    public void OnEndResearch()
    {
        MainResourcesController.researchListIsFull = false;
        MainResourcesController.researchInProgress.Clear();
        foreach (var mm in MainResourcesController.resDictionary)
        {
            if (mm.resId == queneId)
            {
                MainResourcesController.technologyLevel[mm.resTechName] += 1;
            }
        }

        MainResourcesController.UpdateResearch(queneId, parrentBuilding);

        CancelInvoke("StartTickResearch");

        Destroy(this.gameObject);
        gameObject.transform.parent.gameObject.SetActive(false);
    }
Esempio n. 4
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);
        }
    }
Esempio n. 5
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);
        }
    }
Esempio n. 6
0
    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);
        }
    }
Esempio n. 7
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;
        }
    }