Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        rend       = GetComponent <Renderer>();
        startColor = rend.material.color;


        buildManager = BuildManager.instance;

        menu = GameObject.Find("Construir").GetComponent <MenuConstruir>();

        graphsAlgorithms = GameObject.Find("GameMaster").GetComponent <GraphsAlgorithms>();
    }
    public void BuildStructureOn(Building node) //Construir en un nodo particular
    {
        if (PlayerStats.Money < structureToBuild.cost)
        {
            Debug.Log("Nos enough money");
            return;
        }

        if (structureToBuild.needWater == true && node.water == false)
        {
            Debug.Log("NO WATER CANT BUILD HERE");
            return;
        }

        PlayerStats.Money -= structureToBuild.cost;
        structureToBuild.cantidadEdificios++; // Incrementamos el número de edificaciones de ese tipo
        GameObject structure = (GameObject)Instantiate(structureToBuild.prefab, node.GetBuildPosition(), structureToBuild.prefab.transform.rotation);

        node.edification = structure;
        structureToBuild.nodeAsociate = node;

        EdificationUpdate.listOfStructures.Add(structureToBuild);

        //Debug.Log("Antes de la llamada");
        //GraphsAlgorithms graphsAlgorithms = gameObject.GetComponent<GraphsAlgorithms>();
        //
        //
        ////Afecta a todos los nodos cercanos (un rango de 3)
        //
        // Debug.Log("Antes de la llamada");
        // graphs.BusquedaEnAnchura(node.gameObject.GetComponent<Nodo>());
        //graphsAlgorithms.BusquedaEnAnchura(node.gameObject.GetComponent<Nodo>());


        //LAMAMOS AL GRAFO
        graphs = gameObject.GetComponent <GraphsAlgorithms>();
        graphs.ResetGraph();
        graphs.BusquedaEnAnchura(node.gameObject.GetComponent <Nodo>(), structureToBuild.levelOfSatisfaction);



        Debug.Log(PlayerStats.Money);
        Debug.Log(structureToBuild.cantidadEdificios);
        node.gameObject.GetComponent <MeshRenderer>().enabled = false;
    }