示例#1
0
    public void ResetGraph()
    {
        dataPoints.Clear();

        if (lineRenderer != null)
        {
            pointOffset = 2f / visiblePointsCount;
            lineRenderer.positionCount = visiblePointsCount;

            for (int i = 0; i < visiblePointsCount; i++)
            {
                dataPoints.Enqueue(0);
                lineRenderer.SetPosition(i, new Vector3(i * pointOffset - 1f, 0, 0));
            }
        }
        else if (uiLineRenderer != null)
        {
            pointOffset           = 1f / visiblePointsCount;
            uiLineRenderer.Points = new Vector2[visiblePointsCount];

            uiWidth  = uiLineRenderer.GetComponent <RectTransform>().rect.width;
            uiHeight = uiLineRenderer.GetComponent <RectTransform>().rect.height;

            for (int i = 0; i < visiblePointsCount; i++)
            {
                dataPoints.Enqueue(0);
                uiLineRenderer.Points[i] = new Vector2(i * pointOffset * uiWidth, 0);
            }

            uiLineRenderer.Apply();
        }
    }
示例#2
0
        private void InstantiateViews()
        {
            labelText = viewCreator.InstantiateText("label", transform, PivotValue.MIDDLE_LEFT);
            labelText.GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 0.5f);
            labelText.GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 0.5f);
            labelText.GetComponent <RectTransform>().sizeDelta = new Vector2(300f, 40f);

            lineRenderer = viewCreator.InstantiateLineRenderer("line", transform, PivotValue.CENTER);
            lineRenderer.GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 0.5f);
            lineRenderer.GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 0.5f);
            lineRenderer.lineThickness = 2.0f;
        }
        private void InstantiateViews()
        {
            labelText = viewCreator.InstantiateWithPrefab <ChartLabel> (labelPrafab, transform);
            labelText.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 0.5f);
            labelText.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 0.5f);
            labelText.GetComponent <RectTransform> ().sizeDelta = new Vector2(300f, 40f);

            lineRenderer = viewCreator.InstantiateLineRenderer("line", transform, PivotValue.CENTER);
            lineRenderer.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 0.5f);
            lineRenderer.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 0.5f);
            lineRenderer.lineThickness = 2.0f;
        }
示例#4
0
    // Use this for initialization
    void Start()
    {
        if (carObject != null)
        {
            _OgmaNeoCar = carObject.GetComponentInChildren <OgmaNeoCarController>();

            if (_OgmaNeoCar == null || !_OgmaNeoCar.isActiveAndEnabled)
            {
                _eOgmaNeoCar = carObject.GetComponentInChildren <EOgmaNeoCarController>();
            }
        }

        _lineRenderer = GetComponentInChildren <UILineRenderer>();

        RectTransform rectTransform = _lineRenderer.GetComponent <RectTransform>();
        Rect          rect          = rectTransform.rect;

        _graphWidth  = rect.width;
        _graphHeight = rect.height;

        _graphValues = new List <float>();

        _graphPoints = new Vector2[_maxNumValues];
        for (int i = 0; i < _maxNumValues; i++)
        {
            float x = i * (_graphWidth / _maxNumValues);
            float y = 0.0f;

            _graphPoints[i].Set(x, y);
        }

        _lineRenderer.Points = _graphPoints;
    }
示例#5
0
        private UILineRenderer CreateLineRenderer()
        {
            UILineRenderer lineRenderer = viewCreator.InstantiateLineRenderer("Line",
                                                                              chartDataContainerView.transform, PivotValue.BOTTOM_LEFT);

            lineRenderer.GetComponent <RectTransform> ().sizeDelta = GetSize();
            return(lineRenderer);
        }
    public void SetWeapon(Weapon weapon)
    {
        DamageLabel.text = ResourceManager.instance.GetLocalization("Damage") + ": " + weapon.GetMaxDamage().ToString("0");
        RangeLabel.text  = ResourceManager.instance.GetLocalization("Range") + ": " + weapon.GetMaxRangeDisplay().ToString("0");

        Rect GraphRect = Lines.GetComponent <RectTransform>().rect;

        Vector2[] DamagePoints = weapon.GetGraphDamagePoints();
        Lines.Points = new Vector2[DamagePoints.Length];

        for (int i = 0; i < DamagePoints.Length; i++)
        {
            Lines.Points[i] = new Vector2(DamagePoints[i].x * GraphRect.width, DamagePoints[i].y * GraphRect.height);
        }
    }
示例#7
0
    void Start()
    {
        mainCamera = Camera.main;
        player     = GameObject.FindGameObjectWithTag("Player");

        GameObject objLineRenderer = new GameObject("UILineRenderer");

        lineRenderer = objLineRenderer.AddComponent <UILineRenderer>();
        lineRenderer.GetComponent <RectTransform>().pivot = Vector2.zero;

        Canvas c = FindObjectOfType <Canvas>();

        objLineRenderer.transform.SetParent(c.transform);

        objLineRenderer.SetActive(false);
    }
示例#8
0
    public override void OnActionStart(Vector2 position)
    {
        if (phase == 0)
        {
            Debug.Log("ACTION START");
            showGUIInfo = true;
            GameObject objLineRenderer = new GameObject("UILineRenderer");

            if (lineRenderer)
            {
                Destroy(lineRenderer.gameObject);
            }
            lineRenderer = objLineRenderer.AddComponent <UILineRenderer>();
            lineRenderer.GetComponent <RectTransform>().pivot = Vector2.zero;
            objLineRenderer.transform.SetParent(canvas.transform);

            GameObject objCircle = new GameObject("UICircle");

            if (circle)
            {
                Destroy(circle.gameObject);
            }
            circle = objCircle.AddComponent <UICircle>();
            circle.GetComponent <RectTransform>().sizeDelta = 30 * Vector2.one;
            objCircle.transform.SetParent(canvas.transform);

            initialPosition = position;
            objCircle.transform.position = initialPosition;
        }
        else if (phase == 1)
        {
            if (ball)
            {
                player.transform.position = ball.transform.position;
                Destroy(ball.gameObject);
            }
        }
    }
示例#9
0
 void Update()
 {
     if (next)
     {
         line.enabled = true;
         line.Points  = new Vector2[] {
             new Vector2(0f, 0f),
             new Vector2(30f, 0),
             RectTransformExtension.switchToRectTransform(next.anchor.GetComponent <RectTransform>(), line.GetComponent <RectTransform>()) - new Vector2(30f, 0),
             RectTransformExtension.switchToRectTransform(next.anchor.GetComponent <RectTransform>(), line.GetComponent <RectTransform>())
         };
     }
     else
     {
         line.enabled = false;
     }
 }
示例#10
0
//----functions
    void repeatFn()
    {
        isDropped       = false;
        Line.Points [1] = Line.Points [0] = Vector2.zero;
        Line.GetComponent <UILineRenderer> ().enabled = false;
    }