예제 #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
    public void clickThumbnail()
    {
        building = Resources.Load(name) as GameObject;
        GameObject newBuilding = (GameObject)Instantiate(building, Vector3.zero, Quaternion.identity);

        newBuilding.name = name;
        BV_BuildingManager newBuildingScript = newBuilding.GetComponent <BV_BuildingManager> ();

        newBuildingScript.allowToMove = true;
        building = newBuilding;
    }
예제 #3
0
    void Start()
    {
        //GETS THE NAME OF THE PREFAB AND THEN THE BUILDING BEHAVIOUR SCRIPT
        myBuilding = gameObject.GetComponent <BV_BuildingManager> ();

        //INITIALIZE LAST OWNER
        lastOwner = myBuilding.myOwner + "";

        //CREATE A MATERIAL AND A SHADER
        myMaterial = new Material(Shader.Find("Standard (Specular setup)"));

        //MAKE THE TRANSPARENT PARTS (ALPHA CHANNEL) OF THE .PNG _d ALSO TRANSPARENT IN UNITY
        presetAlphaChannel();

        //LOAD THE MATERIAL INTO THE GAME OBJECT
        gameObject.GetComponent <Renderer> ().material = myMaterial;

        //LOAD TEXTURE FILE IF EXISTS
        loadTexture();
    }
예제 #4
0
    public void updateInfluence()
    {
        foreach (GameObject building in ownedBuilding)
        {
            BV_BuildingManager thisScript = building.GetComponent <BV_BuildingManager>();

            if (state == stateEnum.influence)
            {
                print("INFLUENCE = " + thisScript.getInfluence());

                if (stats_influence >= 0 && stats_influence < 50)
                {
                    building.GetComponent <Renderer> ().material.color = new Color32(255, 255, 255, 255);
                }
                if (stats_influence >= 50 && stats_influence < 100)
                {
                    building.GetComponent <Renderer> ().material.color = new Color32(255, 200, 255, 255);
                }
                if (stats_influence >= 100 && stats_influence < 150)
                {
                    building.GetComponent <Renderer> ().material.color = new Color32(255, 150, 255, 255);
                }
                if (stats_influence >= 150 && stats_influence < 200)
                {
                    building.GetComponent <Renderer> ().material.color = new Color32(255, 50, 255, 255);
                }
                if (stats_influence >= 200)
                {
                    building.GetComponent <Renderer> ().material.color = new Color32(255, 0, 255, 255);
                }
            }
            else
            {
                building.GetComponent <Renderer> ().material.color = Color.white;
                BV_BuildingShaderer shaderer = building.GetComponent <BV_BuildingShaderer>();
                shaderer.updateColor();
            }
        }
    }
예제 #5
0
    void Update()
    {
        if (!PhotonNetwork.isMasterClient && gameObject.name.Contains("(Clone)"))
        {
            gameObject.name = gameObject.name.Replace("(Clone)", "").Trim();

            //GETS THE NAME OF THE PREFAB AND THEN THE BUILDING BEHAVIOUR SCRIPT
            myBuilding = gameObject.GetComponent <BV_BuildingManager> ();

            //INITIALIZE LAST OWNER
            lastOwner = myBuilding.myOwner + "";

            //CREATE A MATERIAL AND A SHADER
            myMaterial = new Material(Shader.Find("Standard (Specular setup)"));

            //MAKE THE TRANSPARENT PARTS (ALPHA CHANNEL) OF THE .PNG _d ALSO TRANSPARENT IN UNITY
            presetAlphaChannel();

            //LOAD THE MATERIAL INTO THE GAME OBJECT
            gameObject.GetComponent <Renderer> ().material = myMaterial;

            //LOAD TEXTURE FILE IF EXISTS
            loadTexture();
        }

        //CREATE THE SCRIPT INSTANCE TO RETRIEVE ITS VALUES
        myBuilding = gameObject.GetComponent <BV_BuildingManager> ();

        //ALOOW US TO MODIFY THE EMISSION PART OF THE SHADER
        gameObject.GetComponent <Renderer> ().material.EnableKeyword("_EMISSION");

        if (lastOwner != myBuilding.myOwner + "" && myBuilding.myType == BV_BuildingManager.typeEnum.leisure)
        {
            //print ("####### COLOR CHANGED !");
            //updateColor(myScript);
            lastOwner = myBuilding.myOwner + "";
        }
    }
예제 #6
0
    IEnumerator GetAllUDP()
    {
        WWW w = new WWW("http://localhost:8080/AssetService/resources/assets");

        yield return(w);

        while (w.text == "")
        {
            yield return(null);
        }

        //DELETE THE BRACKETS
        string result = w.text + "";

        string[] answer = result.Split('#');

        foreach (string item in answer)
        {
            string[] values = item.Split('/');

            //print ("VALUES #######");
            int i = 0;

            foreach (string value in values)
            {
                switch (i)
                {
                case 0:
                    //ID
                    i++;
                    break;

                case 1:
                    //NAME
                    buildingName = value;
                    //print ("SUCCEED LOAD NAME :"+buildingName);
                    i++;
                    break;

                case 2:
                    buildingPosX = float.Parse(value);
                    //print ("SUCCEED LOAD POSX :"+buildingPosX);
                    //posX
                    i++;
                    break;

                case 3:
                    //posY
                    buildingPosY = float.Parse(value);
                    //print ("SUCCEED LOAD POSY :"+buildingPosY);
                    i++;
                    break;

                case 4:
                    //posZ
                    buildingPosZ = float.Parse(value);
                    //print ("SUCCEED LOAD POSZ :"+buildingPosZ);
                    i++;
                    break;

                case 5:
                    //rotX
                    buildingRotX = float.Parse(value);
                    //print ("SUCCEED LOAD RotX :"+buildingRotX);
                    i++;
                    break;

                case 6:
                    //rotY
                    buildingRotY = float.Parse(value);
                    //print ("SUCCEED LOAD RotY :"+buildingRotY);
                    i++;
                    break;

                case 7:
                    //rotZ
                    buildingRotZ = float.Parse(value);
                    //print ("SUCCEED LOAD RotZ :"+buildingRotZ);
                    i++;
                    break;

                case 8:
                    //rotW
                    buildingRotW = float.Parse(value);
                    //print ("SUCCEED LOAD RotW :"+buildingRotW);
                    i++;
                    break;
                }
            }



            if (buildingName != null)
            {
                Vector3    position = new Vector3(buildingPosX, buildingPosY, buildingPosZ);
                Quaternion rotation = new Quaternion(buildingRotX, buildingRotY, buildingRotZ, buildingRotW);
                GameObject building = PhotonNetwork.Instantiate(buildingName, position, rotation, 0);
                building.name = buildingName;
                BV_BuildingManager newBuildingScript = building.GetComponent <BV_BuildingManager> ();
                newBuildingScript.allowToMove = false;
            }
        }

        DBsize = answer.Length - 1;
    }
예제 #7
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;
            }
            }
        }
    }