Ejemplo 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);
    }
Ejemplo n.º 2
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);
        }
    }