예제 #1
0
    public void OnBody()
    {
        if (id >= controller.construcciones.Length)
        {
            EditorGUILayout.HelpBox("El id es superior al valor real...", MessageType.Warning);
            return;
        }
        ObjetoTienda panel = controller.construcciones[id];

        panel.nombre      = EditorGUILayout.TextField("Nombre recurso: ", panel.nombre);
        panel.descripcion = EditorGUILayout.TextArea(panel.descripcion);

        GUILayout.Space(10);

        EditorGUILayout.HelpBox("Actualmente desactivado la inclusión de arrays de Sprites", MessageType.Warning);

        GUILayout.Space(10);

        panel.categoria        = (CONSTRUCCION)EditorGUILayout.EnumPopup("Tipo recurso: ", panel.categoria);
        panel.tipoConstruccion = (TIPOCONSTRUCCION)EditorGUILayout.EnumPopup("Tipo recurso: ", panel.tipoConstruccion);
        panel.investigacionNec = (INVESTIGACION)EditorGUILayout.EnumPopup("Investigación: ", panel.investigacionNec);

        GUILayout.Space(10);

        EditorGUILayout.HelpBox("El prefab con la construcción necesaria.", MessageType.Info);
        panel.prefab = (GameObject)EditorGUILayout.ObjectField("Prefab: ", panel.prefab, typeof(GameObject), false);

        GUILayout.Space(10);

        EditorGUILayout.HelpBox("Actualmente desactivado la inclusión de arrays de ObjetoRecursos", MessageType.Warning);

        GUILayout.Space(10);

        EditorGUILayout.HelpBox("La posición de los vectores", MessageType.Info);
        panel.entrada = EditorGUILayout.Vector2Field("Posición entrada rel:", panel.entrada);
        EditorGUILayout.HelpBox("Actualmente desactivado la inclusión de arrays de Vector2", MessageType.Warning);
    }
예제 #2
0
    public Sprite CompareNeighbourFloor(IntVector2 position, int selectID, bool compareNeighbours = true)
    {
        ObjetoTienda objeto    = construcciones[selectID];
        string       thisFloor = objeto.nombre;

        //Si no dispone de sprite, devuelve error.
        if (objeto.spriteObjeto == null || objeto.spriteObjeto.Length == 0)
        {
            Debug.LogWarning("Construccion::CompareNeighbour error: " + objeto.nombre + " no tiene sprites asignados.");
            return(null);
        }

        if (objeto.spriteObjeto.Length == 1)
        {
            return(objeto.spriteObjeto[0]);
        }

        if (thisFloor == "")
        {
            Debug.LogWarning("Construccion::CompareNeighbourFloor error: No tiene ningún suelo.");
            return(objeto.spriteObjeto[0]);
        }

        string name = thisFloor + "_";
        Node   node = manager.GetNode(position.x, position.y + 1);

        if (node != null && node.floorName == thisFloor)
        {
            name += "N";
            if (compareNeighbours)
            {
                node.ChangeFloorSprite(CompareNeighbourFloor(node.GetPosition(), selectID, false), true);
            }
        }

        node = manager.GetNode(position.x + 1, position.y);
        if (node != null && node.floorName == thisFloor)
        {
            name += "E";
            if (compareNeighbours)
            {
                node.ChangeFloorSprite(CompareNeighbourFloor(node.GetPosition(), selectID, false), true);
            }
        }

        node = manager.GetNode(position.x, position.y - 1);
        if (node != null && node.floorName == thisFloor)
        {
            name += "S";
            if (compareNeighbours)
            {
                node.ChangeFloorSprite(CompareNeighbourFloor(node.GetPosition(), selectID, false), true);
            }
        }

        node = manager.GetNode(position.x - 1, position.y);
        if (node != null && node.floorName == thisFloor)
        {
            name += "W";
            if (compareNeighbours)
            {
                node.ChangeFloorSprite(CompareNeighbourFloor(node.GetPosition(), selectID, false), true);
            }
        }

        for (int i = 0; i < objeto.spriteObjeto.Length; i++)
        {
            if (objeto.spriteObjeto[i].name == name)
            {
                return(objeto.spriteObjeto[i]);
            }
        }

        return(objeto.spriteObjeto[0]);
    }
예제 #3
0
    public Sprite CompareNeighbour(IntVector2 position, int selectID, bool compareNeighbours = true)
    {
        ObjetoTienda objeto   = construcciones[selectID];
        ESTRUCTURA   thisType = manager.GetNode(position).build.GetBuildType();


        //Si no dispone de sprite, devuelve error.
        if (objeto.spriteObjeto == null || objeto.spriteObjeto.Length == 0)
        {
            Debug.LogWarning("Construccion::CompareNeighbour error: " + objeto.nombre + " no tiene sprites asignados.");
            return(null);
        }

        if (objeto.spriteObjeto.Length == 1)
        {
            return(objeto.spriteObjeto[0]);
        }

        if (thisType == ESTRUCTURA.Ninguno)
        {
            Debug.LogWarning("Construccion::CompareNeighbour error: No es ningun tipo de estructura.");
            return(objeto.spriteObjeto[0]);
        }

        string name = objeto.nombre + "_";
        Node   node = manager.GetNode(position.x, position.y + 1);

        if (node != null && node.build != null && node.build.GetBuildType() == thisType)
        {
            name += "N";
            if (compareNeighbours)
            {
                node.build.ChangeSprite(CompareNeighbour(node.GetPosition(), selectID, false));
            }
        }

        node = manager.GetNode(position.x + 1, position.y);
        if (node != null && node.build != null && node.build.GetBuildType() == thisType)
        {
            name += "E";
            if (compareNeighbours)
            {
                node.build.ChangeSprite(CompareNeighbour(node.GetPosition(), selectID, false));
            }
        }

        node = manager.GetNode(position.x, position.y - 1);
        if (node != null && node.build != null && node.build.GetBuildType() == thisType)
        {
            name += "S";
            if (compareNeighbours)
            {
                node.build.ChangeSprite(CompareNeighbour(node.GetPosition(), selectID, false));
            }
        }

        node = manager.GetNode(position.x - 1, position.y);
        if (node != null && node.build != null && node.build.GetBuildType() == thisType)
        {
            name += "W";
            if (compareNeighbours)
            {
                node.build.ChangeSprite(CompareNeighbour(node.GetPosition(), selectID, false));
            }
        }

        for (int i = 0; i < objeto.spriteObjeto.Length; i++)
        {
            if (objeto.spriteObjeto[i].name == name)
            {
                return(objeto.spriteObjeto[i]);
            }
        }

        return(objeto.spriteObjeto[0]);
    }