Ejemplo n.º 1
0
    public void generateButtonPressed()
    {
        GeneratorUIManager.Instance.disableGenerateButton();
        GeneratorUIManager.Instance.deleteMapOnUI(Content.transform);

        try
        {
            validateGeneratorParams(GeneratorsVect[(int)activeGenerator]);
            GeneratorsVect[(int)activeGenerator].TypeGrid = TypeGridVect[(int)activeTypeGrid];  //Typegrid change in generator
            TileObject[,] map = GeneratorsVect[(int)activeGenerator].initializeMap();

            GeneratorsVect[(int)activeGenerator].generateMap();
            GeneratorsVect[(int)activeGenerator].postprocessMap();


            if (GeneratorsVect[(int)activeGenerator].useRandomSeed)
            {
                GeneratorUIManager.Instance.gameObject.GetComponent <UIParametersValueChange>().refreshUIParams();
            }

            dataMap = MapEvaluator.computeMetrics(GeneratorsVect[(int)activeGenerator].getMap(), GeneratorsVect[(int)activeGenerator].TypeGrid, GeneratorsVect[(int)activeGenerator].startPos, GeneratorsVect[(int)activeGenerator].endPos);
            DisplayMainMap((GeneratorUIManager.Instance.isTrapsOnMapBorderToggleOn() ? GeneratorsVect[(int)activeGenerator].getMapWTrapBorder() : GeneratorsVect[(int)activeGenerator].getMap()));
            GeneratorUIManager.Instance.showUIMapInfo(MapHolder.transform, dataMap, GeneratorsVect[(int)activeGenerator].TypeGrid);
        }
        catch (Exception e) {
            ErrorManager.ManageError(ErrorManager.Error.SOFT_ERROR, e.Message);
        }

        GeneratorUIManager.Instance.enableGenerateButton();
    }
Ejemplo n.º 2
0
    public static GameObject renderAliasOnUI(RectTransform container, ITypeGrid typeGrid, StructuredAlias alias, GameObject AliasPrefab, bool attachMapMetrics)
    {
        GameObject AliasGO = GameObject.Instantiate(AliasPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject;

        container.parent.GetComponent <MapListManager>().addMapToDictionary(alias.AliasMap, alias.start, alias.end, alias.similarityDistance, AliasGO.GetInstanceID());

        AliasGO.transform.SetParent(container, false);
        Transform     t           = AliasGO.transform.Find("BorderMask/Content");
        RectTransform contentRect = t.GetComponent <RectTransform>();
        RectTransform prefabRect  = typeGrid.TilePrefab.GetComponent <RectTransform>();

        initAliasGameObject(AliasGO);
        GeneratorUIManager.Instance.DisplayMap(alias.AliasMap, t, ParameterManager.Instance.GridType);

        GeneratorUIManager.Instance.ScaleToFitContainer(contentRect, new Rect(Vector2.zero, container.GetComponent <GridLayoutGroup>().cellSize));

        if (attachMapMetrics)
        {
            AliasGO.GetComponentInChildren <HoverDisplayText>().textToDisplay = MapEvaluator.aggregateAliasDataMap(MapEvaluator.computeMetrics(alias.AliasMap, typeGrid, alias.start, alias.end), alias.similarityDistance);
        }
        else
        {
            AliasGO.GetComponentInChildren <HoverDisplayText>().gameObject.SetActive(false);
        }

        return(AliasGO);
    }