Exemple #1
0
    private static void AddText(GameObject _childPanel, RectTransform _parentRect, WorldDivision.Cell _zone)
    {
        // Add text to the text holder
        GameObject _textHolder = new GameObject($"Zone Text: {_zone.Id}");
        Text       _text       = _textHolder.AddComponent <Text>();

        _textHolder.transform.SetParent(_childPanel.transform, false);

        RectTransform _textRect = _text.GetComponent <RectTransform>();

        // Center in parent
        // Set text holder anchors relative to parent
        _textRect.anchoredPosition = _parentRect.anchoredPosition;
        Vector2 _panelTopLeftCorner = new Vector2(0f, 1f);

        _textRect.anchorMin  = _panelTopLeftCorner;
        _textRect.anchorMax  = _panelTopLeftCorner;
        _textRect.pivot      = _panelTopLeftCorner;
        _textRect.localScale = _childPanel.GetComponent <RectTransform>().localScale;
        _textRect.sizeDelta  = _childPanel.GetComponent <RectTransform>().sizeDelta;
        _textRect.position   = _childPanel.GetComponent <RectTransform>().position;

        // Text propeties
        _text.font      = Font.CreateDynamicFontFromOSFont("Arial", 10);
        _text.fontStyle = FontStyle.Bold;
        _text.color     = Color.white;
        _text.fontSize  = 30;
        _text.alignment = TextAnchor.MiddleCenter;
        _text.text      = _zone.Id.ToString();
    }
Exemple #2
0
    private GameObject AddChildPanel(RectTransform _parentRect, WorldDivision.Cell _zone, Vector2 _scaleRatio)
    {
        GameObject _panelChild = new GameObject($"Zone Panel: {_zone.Id}");
        // Set it as a child of mini map panel
        RectTransform _panelChildRect = _panelChild.AddComponent <RectTransform>();

        _panelChild.AddComponent <CanvasRenderer>();
        _panelChild.AddComponent <Image>().sprite = borderImage;
        _panelChild.transform.SetParent(miniMapPanel.transform, false);


        // Add & configure text holder rect transform
        _panelChildRect.localScale = new Vector3(1f, 1f, 1f);
        // Set text holder anchors relative to parent
        _panelChildRect.anchoredPosition = _parentRect.anchoredPosition;
        Vector2 _panelTopLeftCorner = new Vector2(0f, 1f);

        _panelChildRect.anchorMin = _panelTopLeftCorner;
        _panelChildRect.anchorMax = _panelTopLeftCorner;
        _panelChildRect.pivot     = _panelTopLeftCorner;

        // Set text holder scaled dimension
        _panelChildRect.sizeDelta = new Vector2(_zone.Dimension.x / _scaleRatio.x,
                                                _zone.Dimension.y / _scaleRatio.y);
        // Set text holder position (Invert y-axis because parent anchor is at the bottom-right)
        _panelChildRect.localPosition = new Vector3(_zone.StartPos.x / _scaleRatio.x,
                                                    -_zone.StartPos.y / _scaleRatio.y,
                                                    0f);

        return(_panelChild);
    }
Exemple #3
0
    private void AddZoneToPanel(WorldDivision.Cell _zone, RectTransform _parentRect, Vector2 _scaleRatio)
    {
        GameObject _panelChild = AddChildPanel(_parentRect, _zone, _scaleRatio);

        AddText(_panelChild, _parentRect, _zone);
    }
 private void UpdateZonesInfo()
 {
     myZone        = zoneManager.FindMyZone(playerTransform.position);
     adjacentZones = zoneManager.GetNeighbours(playerTransform.position, current_AOIM_radius);
 }