示例#1
0
    public void updateValues()
    {
        dayCount = 0;

        //CLEAN EVERYTHING
        ownedBuilding.Clear();
        ownedBuilding.Clear();
        stats_popularity    = 0;
        stats_influence     = 0;
        stats_income        = 0;
        stats_buildingCount = 0;
        stats_taxesCount    = 0;
        stats_illegalCount  = 0;
        money_income        = 0;
        money_expenses      = 0;
        money_taxes         = 0;
        money_total         = 0;

        if (PhotonNetwork.room != null && PhotonNetwork.room.playerCount > 1)
        {
            GameObject[] buildings = GameObject.FindGameObjectsWithTag("BUILDING");

            foreach (GameObject building in buildings)
            {
                buildingScript = building.GetComponent <BV_BuildingManager>();
                print("BUILDING ID =" + buildingScript.getOwnerID());

                if (buildingScript.getOwnerID() == PhotonNetwork.player.ID)
                {
                    buildingScript.setValues();
                    ownedBuilding.Add(building);
                    //REFACTOR
                    stats_popularity    = stats_popularity + buildingScript.getPopularity();
                    stats_influence     = stats_influence + buildingScript.getInfluence();
                    stats_income        = stats_income + buildingScript.getIncome();
                    stats_buildingCount = buildings.Length;
                    if (buildingScript.getPayTaxes() == true)
                    {
                        stats_taxesCount++;
                    }
                    if (buildingScript.getPayTaxes() == false)
                    {
                        stats_illegalCount++;
                    }
                    money_income   = stats_income;
                    money_expenses = money_expenses + buildingScript.getExpenses();
                    money_taxes    = money_taxes + buildingScript.getTaxes();
                }
            }
            money_acount        = money_acount;
            money_total         = money_acount - money_expenses + money_income;
            stats_buildingCount = stats_buildingCount + ownedBuilding.Count();
            print("YOU OWNN" + ownedBuilding.Count());
        }
    }
示例#2
0
    //UPDATE GUI OF BUILDING WINDOW
    public void setValues()
    {
        //GET SCRIPT FROM SELECTED TERRAIN
        //
        //GameObject guimanager = GameObject.Find("GameScripts").GetComponent<BV_GameGuiManager>();
        // print("TST RAYCAST");
        //
        buildingScript = building.GetComponent <BV_BuildingManager>();
        string s;
        Text   newtext;

        print("_______________________________________________________________________");
        print("BV_BuildingGui : Updating values with data from : " + building.name);
        print("_______________________________________________________________________");

        foreach (Transform child in transform)
        {
            switch (child.name)
            {
            case "RawImage":
            {
                Texture NewTexture = Resources.Load <Texture>("Thumbnails/" + building.name + "_t");
                child.GetComponent <RawImage>().texture = NewTexture;
                print("BV_BuildingGui : succeeded changing thumbnail" + building.name);
                break;
            }

            case "StateBtn":
            {
                stateBtn     = child.GetComponent <Button>();
                s            = buildingScript.myState + "";
                newtext      = child.transform.Find("StateText").GetComponent <Text>();
                newtext.text = s;
                print("BV_BuildingGui : succeeded changing state btn text");

                //ADD LISTENER TO THE STATE BUTTON
                stateBtn.onClick.AddListener(() => {
                        clickStateBtn();
                    });
                break;
            }

            case "PopValue":
            {
                float value = buildingScript.getPopularity();
                s            = buildingScript.getPopularity() + "";
                newtext      = child.GetComponent <Text>();
                newtext.text = s;
                child.GetComponent <Text>().color = fontColorChanger(value);
                print("BV_BuildingGui : succeeded changing popularity value");
                break;
            }

            case "InfValue":
            {
                float value = buildingScript.getInfluence();
                s            = buildingScript.getInfluence() + "";
                newtext      = child.GetComponent <Text>();
                newtext.text = s;
                child.GetComponent <Text>().color = fontColorChanger(value);
                print("BV_BuildingGui : succeeded changing influence value");
                break;
            }

            case "IncValue":
            {
                float value = buildingScript.getIncome();
                s            = buildingScript.getIncome() + "";
                newtext      = child.GetComponent <Text>();
                newtext.text = s;
                child.GetComponent <Text>().color = fontColorChanger(value);
                print("BV_BuildingGui : succeeded changing income value");
                break;
            }

            case "ExpValue":
            {
                float value = buildingScript.getExpenses();
                s            = buildingScript.getExpenses() + "";
                newtext      = child.GetComponent <Text>();
                newtext.text = s;
                child.GetComponent <Text>().color = fontColorChanger(value);
                print("BV_BuildingGui : succeeded changing expenses value");
                break;
            }

            case "TotValue":
            {
                float value = buildingScript.getTotal();
                s            = buildingScript.getTotal() + "";
                newtext      = child.GetComponent <Text>();
                newtext.text = s;
                child.GetComponent <Text>().color = fontColorChanger(value);
                print("BV_BuildingGui : succeeded changing total value");
                break;
            }

            case "Toggle":
            {
                child.GetComponent <Toggle>().isOn = buildingScript.getPayTaxes();
                print("BV_BuildingGui : succeeded changing toggle value");
                child.GetComponent <Toggle>().onValueChanged.AddListener((value) => {
                        updateTaxeBool(value);
                    });

                break;
            }

            case "Close":
            {
                closeBtn = child.GetComponent <Button>();
                //ADD LISTENER TO THE CLOSE BUTTON
                closeBtn.onClick.AddListener(() => {
                        clickCloseBtn();
                    });
                break;
            }
            }
        }
    }