Exemple #1
0
    IEnumerator GetJson()
    {
        WWW www = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=getuser&token=" + MainResourcesController.userToken);

        yield return(www);

        result = JSON.Parse(www.text);

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

        if (MainResourcesController.buildingInProgress.Count != 0)
        {
            progressParrent.SetActive(true);

            buildsInProgress = new BuildingsInProgress(MainResourcesController.buildingInProgress[0].sysId,
                                                       MainResourcesController.buildingInProgress[0].buildId,
                                                       MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.timeNow,
                                                       MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.buildingInProgress[0].startTimeBuild);

            thisBlc = blocksParrent.transform.FindChild("Building_prefab_" + buildsInProgress.buildId).GetComponent <BlockController>();

            queneName.text     = thisBlc.title;
            queneAvatar.sprite = thisBlc.ava;
            goInstQuene        = Instantiate(quenePrefab);
            goInstQuene.transform.SetParent(progressParrent.transform);
            goInstQuene.transform.localScale = new Vector3(1, 1, 1);

            QueneController qC = goInstQuene.GetComponent <QueneController>();
            qC.queneId             = buildsInProgress.buildId;
            qC.timeToEndBuild      = buildsInProgress.timeToEnd;
            qC.timeToEndTxt        = goInstQuene.transform.FindChild("TimeValue_text").GetComponent <Text>();
            qC.parrentBuilding     = progressParrent;
            qC.progress            = goInstQuene.transform.FindChild("Bg_image").GetComponent <Image>();
            qC.progress.fillAmount = 1f - buildsInProgress.timeToEnd / buildsInProgress.startTimeBuild;
            qC.TickBuild();
        }
        else
        {
            progressParrent.SetActive(false);
        }

        yield return(new WaitForSeconds(1f));

        loadingPanel.SetActive(false);
        scrnM.ShowCurrentPanel();
    }
    public void DropDownItem_btn(int _id, string _name, int _galaxy, int _x, int _y)
    {
        MainResourcesController.currentSystemID = _id;
        MainResourcesController.currentSystemName = _name;
        MainResourcesController.currentGalaxy = _galaxy;
        MainResourcesController.currentSystemX = _x;
        MainResourcesController.currentSystemY = _y;
        mainName.text = _name + " ["+_galaxy+":" + _x + ":" + _y + "]";

        if (GameObject.Find("ProgressElement(Clone)"))
        {
            qC = GameObject.Find("ProgressElement(Clone)").GetComponent<QueneController>();
                qC.CancelInvoke("StartTickBuildings");
                qC.CancelInvoke("StartTickResearch");
                qC.CancelInvoke("StartTickDoc");
                Destroy(GameObject.Find("ProgressElement(Clone)").gameObject);
        }

        StartCoroutine(DropDownItem());
    }
    public void DropDownItem_btn(int _id, string _name, int _galaxy, int _x, int _y)
    {
        MainResourcesController.currentSystemID   = _id;
        MainResourcesController.currentSystemName = _name;
        MainResourcesController.currentGalaxy     = _galaxy;
        MainResourcesController.currentSystemX    = _x;
        MainResourcesController.currentSystemY    = _y;
        mainName.text = _name + " [" + _galaxy + ":" + _x + ":" + _y + "]";

        if (GameObject.Find("ProgressElement(Clone)"))
        {
            qC = GameObject.Find("ProgressElement(Clone)").GetComponent <QueneController>();
            qC.CancelInvoke("StartTickBuildings");
            qC.CancelInvoke("StartTickResearch");
            qC.CancelInvoke("StartTickDoc");
            Destroy(GameObject.Find("ProgressElement(Clone)").gameObject);
        }

        StartCoroutine(DropDownItem());
    }
Exemple #4
0
    IEnumerator GetJson()
    {
        loadingPanel.SetActive(true);

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

        yield return(www);

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

            MainResourcesController.timeNow = result["now"].AsLong;
            //MainResourcesController.weapone_update = result["system"]["weapon_update"].AsLong;

            if (MainResourcesController.docDefInProgress.Count != 0)
            {
                buildingInProgressParent.SetActive(true);

                for (int i = 0; i < MainResourcesController.docDefInProgress.Count; i++)
                {
                    docDefInProgress = new DocDefInProgress(MainResourcesController.docDefInProgress[i].systemId,
                                                            MainResourcesController.docDefInProgress[i].elementId,
                                                            MainResourcesController.docDefInProgress[i].count_elements);

                    FindBLC(docDefInProgress.elementId);

                    queneName.text     = thisBlc.title + "(" + docDefInProgress.count_elements + ")";
                    queneAvatar.sprite = thisBlc.ava;
                    instGO             = Instantiate(prefabProgress);

                    QueneController qC = instGO.GetComponent <QueneController>();
                    qC.queneId        = docDefInProgress.elementId;
                    qC.timeToEndTxt   = instGO.transform.FindChild("TimeValue_text").GetComponent <Text>();
                    qC.timeToEndBuild = thisBlc.timeToBuild * docDefInProgress.count_elements - (MainResourcesController.timeNow - MainResourcesController.weapone_update);
                    qC.timeEndDoc     = thisBlc.timeToBuild * docDefInProgress.count_elements;
                    qC.progress       = instGO.transform.FindChild("Bg_image").GetComponent <Image>();

                    if (i == 0)
                    {
                        instGO.transform.SetParent(buildingInProgressParent.transform);
                        qC.TickDocDef();
                    }
                    else
                    {
                        qC.timeToEndTxt.text = SetTime(qC.timeEndDoc);

                        if (whatBlock == ParseAll.WhatBlockParse.Weapon)
                        {
                            instGO.transform.SetParent(docQuene.transform);
                        }
                        else
                        {
                            instGO.transform.SetParent(defQuene.transform);
                        }
                    }

                    instGO.transform.localScale = new Vector3(1, 1, 1);

                    yield return(new WaitForSeconds(0.2f));
                }
            }
        }
        else
        {
            Debug.Log("No Internet Connections");
        }

        yield return(new WaitForSeconds(1f));

        loadingPanel.SetActive(false);
        scrnM.ShowCurrentPanel();
    }
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;
        }
    }