Example #1
0
        public bool Show(Transform trans)
        {
            Owner = trans.gameObject;

            lineRenderer.Points[1] = lineRenderer.Points[0] =
                Camera.main.WorldToScreenPoint(trans.position);
            lineRenderer.SetVerticesDirty();
            gameObject.SetActive(true);
            return(true);
        }
    private void ShowLine(GameObject begin, GameObject destination) /* show green navigate line on map */
    {
        UILineRenderer line = navline.GetComponent <UILineRenderer>();

        line.Points.Clear();
        MarkerData checkPoint = begin.GetComponent <MarkerData>();
        int        i          = 0;

        //Debug.Log("Write Line At " + checkPoint.markerName + " " + line.Points(i));
        while (checkPoint.successor != null)
        {
            // last point point to marker position
            line.Points.Add(new Vector2(
                                checkPoint.referencePosition.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                                checkPoint.referencePosition.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                                ));
            i++;
            checkPoint = checkPoint.successor.GetComponent <MarkerData>();
        }
        // add last point
        line.Points.Add(new Vector2(
                            checkPoint.referencePosition.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                            checkPoint.referencePosition.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                            ));
        line.Points.Add(new Vector2(
                            checkPoint.position.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                            checkPoint.position.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                            ));
        line.SetVerticesDirty();
    }
    private void ClearLine() /* don't show line in that floor */
    {
        UILineRenderer line = navline.GetComponent <UILineRenderer>();

        line.Points.Clear();
        line.SetVerticesDirty();
    }
Example #4
0
        public void UpdateProgress(float percentage)
        {
            if (subdivisions == null || subdivisions.Count == 0)
            {
                return;
            }
            lastPercentage = percentage;

            // if line not filled draw progress line
            if (percentage < 1.0f)
            {
                progressLineRenderer.Points[0] = curLeftAnchor;
                progressLineRenderer.Points[1] = Vector2.Lerp(curLeftAnchor
                                                              , curRightAnchor
                                                              , percentage);
                progressLineRenderer.SetVerticesDirty();
                progressLineRenderer.color = progressColor;
                return;
            }

            //set progress line transparent
            progressLineRenderer.color = new Color(0, 0, 0, 0);
            // set line color according to max overflow
            subdivisions[lastLine].SetColor(Color.Lerp(progressColor, negativeColor, (percentage - 1) * 4));
            // transform line
            subdivisions[lastLine].Deform(percentage, 16.0f);
        }
Example #5
0
    /*
     * public void update()
     * {
     *      RectTransform parentRect = rect.parent.GetComponent<RectTransform>();
     * //		familyLine.enabled = false;
     *
     *      return;
     *      Debug.Log("update");
     *
     *      Debug.Log(transform);
     *      Debug.Log(transform.position);
     *      Debug.Log(parentRect.position);
     *
     * //		updateFamilyLine();
     * }
     */
    public void updateFamilyLine()
    {
        if (!familyLine)
        {
            return;
        }
        familyLine.enabled = true;

        RectTransform parentRect = rect.parent.GetComponent <RectTransform>();



        float startX = rect.sizeDelta.x / 2;
        float endX   = parentRect.sizeDelta.x / 2 - rect.position.x + parentRect.position.x;

        familyLine.Points = new Vector2[] {
            new Vector2(startX, 0),
            new Vector2(startX, 6),          //familyLineHeight * .4F),
            new Vector2(endX, 6),            //familyLineHeight * .4F),
            new Vector2(endX, familyLineHeight * .6F),

            new Vector2(endX, familyLineHeight)
        };
//		familyLine.color = new Color(Random.Range(0,1.0F), Random.Range(0,1.0F),Random.Range(0,1.0F));
        familyLine.SetVerticesDirty();
    }
Example #6
0
    private void UpdatePlots(ProcessData generationResults)
    {
        //Debug.Log("OnRoundEnded: MultipleTrendPlotScript");

        if (generationResults != null)
        {
            AddValueToPlot(BestScorePlot, generationResults.BestScore);
            AddValueToPlot(WorstScorePlot, generationResults.WorstScore);
            AddValueToPlot(AverageScorePlot, generationResults.AverageScore);
            AddValueToPlot(MedianScorePlot, generationResults.MedianScore);
        }

        int i = 0;

        foreach (Plot plot in PlotsArray)
        {
            PlotLinesRenderersArray[i].m_points =
                plot.GetPlotPoints(plotArea.rect.width, plotArea.rect.height, MaxPointsToShow, true, MinY - Expansion, MaxY + Expansion).
                ToArray();

            PlotLinesRenderersArray[i].SetVerticesDirty();

            i++;
        }

        XAxisRenderer.m_points[0].y = GetYPositionOfValue(0);
        XAxisRenderer.m_points[1].y = GetYPositionOfValue(0);
        XAxisRenderer.SetVerticesDirty();
    }
Example #7
0
    // Update is called once per frame
    void Update()
    {
        var csize = lifeline.parent.GetComponent <RectTransform>().sizeDelta;
        var toX   = csize.x * 0.5f;
        var toY   = diagram.GetComponent <RectTransform>().sizeDelta.y;

        lifelineRenderer.Points[0] = new Vector2(toX, -csize.y);
        lifelineRenderer.Points[1] = new Vector2(toX, -toY);
        lifelineRenderer.SetVerticesDirty();
    }
    // Update is called once per frame
    void Update()
    {
        if (timeBetweenUpdate + lastUpdateTime <= Time.time || lastUpdateTime == 0)
        {
            lastUpdateTime = Time.time;
            source.GetOutputData(samples, 1);
            CreatePointsList();

            lineRenderer.points = points;
            lineRenderer.SetVerticesDirty();
        }
    }
Example #9
0
    public void UpdatePoint(long bytes)
    {
        float lastData = bytes / 10f;

        for (int i = 0; i < arrayLength; i++)
        {
            Vector2 currentData = new Vector2(i * 10, lastData);
            lastData = lineRenderer.Points[i].y;
            lineRenderer.Points[i] = currentData;
        }
        lineRenderer.SetVerticesDirty();
    }
Example #10
0
    void drawFamilyLine(Vector2 start, Vector2 end)
    {
        var centerY = (start.y + end.y) * .4f;

        familyLine.Points = new Vector2[] {
            new Vector2(start.x, start.y),
            new Vector2(start.x, centerY),
            new Vector2(end.x, centerY),
            new Vector2(end.x, end.y)
        };
        familyLine.SetVerticesDirty();
    }
Example #11
0
    // Update is called once per frame
    void Update()
    {
        if (timeBetweenUpdate + lastUpdateTime <= Time.time || lastUpdateTime == 0) // reduce the amount of times the line renderer updates
        {
            lastUpdateTime = Time.time;

            if (amountCaptured >= max)
            {
                StartPlayerInput();                             // sets the sliders to be active, if not already

                lineRenderer.points = pointLists[lastPointSet]; // update points for line renderer
                lineRenderer.SetVerticesDirty();                // make the line renderer update

                lastPointSet++;

                if (lastPointSet >= pointLists.Count)
                {
                    lastPointSet = 0;
                }
            }
            else
            {
                if (captureWave)
                {
                    float[] newSamples = new float[512];

                    source.GetOutputData(newSamples, 1); // Gets the output data of the audio. Frequency and amplitude
                    var points = CreatePointsList(newSamples);

                    pointLists.Add(points);

                    lineRenderer.points = points;
                    lineRenderer.SetVerticesDirty();

                    amountCaptured++;
                }
            }
        }
    }
    private void DrawConnection(Socket sock1, Socket sock2, UILineRenderer lineRenderer)
    {
        var pointList = new List <Vector2>();

        for (float i = 0; i < vertexCount; i++)
        {
            var t = i / vertexCount;
            pointList.Add(CubicCurve(sock1.handle1.position, sock1.handle2.position, sock2.handle1.position, sock2.handle2.position, t));
        }

        lineRenderer.m_points = pointList.ToArray();
        lineRenderer.SetVerticesDirty();
    }
    void Update()
    {
        var list = new Vector2[transforms.Length];

        for (int i = 0; i < transforms.Length; i++)
        {
            var scale = canvas.transform.localScale.x;
            var x     = (transforms[i].position.x - transform.position.x) / scale;
            var y     = (transforms[i].position.y - transform.position.y) / scale;
            list[i] = new Vector2(x, y);
        }

        lineRenderer.Points = list;
        lineRenderer.SetVerticesDirty();
    }
Example #14
0
    private void UpdatePlotArea()
    {
        List <Vector2> plotPoints = plotObject.GetPlotPoints(plotArea.rect.width, plotArea.rect.height);

        XAxisRenderer.m_points[0].y = plotObject.GetYPositionOfValue(0);
        XAxisRenderer.m_points[1].y = plotObject.GetYPositionOfValue(0);

        // wyczyść listę UILineRenderera
        // wstaw plotPoints jako punkty

        PlotLineRenderer.m_points = plotPoints.ToArray();

        PlotLineRenderer.SetVerticesDirty();
        XAxisRenderer.SetVerticesDirty();
    }
Example #15
0
    public void UpdateGraph()
    {
        if (samples == null)
        {
            return;
        }
        if (samples.samples.Count == 0)
        {
            return;
        }

        // Update the list of points sent to the graph!
        var lastSample = samples.samples.Last();

        // Iterate through the samples to find the oldest sample index
        // that is younger than our time window seconds from the newest sample.
        int thresholdTime     = lastSample.millis - timeSpanMillis;
        int oldestSampleIndex = samples.samples.Count - 1;

        for (; oldestSampleIndex >= 0; --oldestSampleIndex)
        {
            var sample = samples.samples[oldestSampleIndex];
            if (sample.millis < thresholdTime)
            {
                break;
            }
        }

        // Since we found the first sample TOO old, re-increment the
        // index once to get the last sample old ENOUGH!
        oldestSampleIndex++;
        var oldestSample = samples.samples[oldestSampleIndex];

        // Create the new array of points for rendering
        int pointCount = samples.samples.Count - oldestSampleIndex;
        var points     = new Vector2[pointCount];

        for (int i = 0; i < pointCount; ++i)
        {
            var sample = samples.samples[i + oldestSampleIndex];
            points[i] = ScaleSample(sample.value, sample.millis);
        }

        lineRenderer.Points = points;
        lineRenderer.SetVerticesDirty();
    }
    private void ShowLine(GameObject point) /*draw line on connector point */
    {
        UILineRenderer line = navline.GetComponent <UILineRenderer>();

        line.Points.Clear();
        MarkerData checkPoint = point.GetComponent <MarkerData>();

        line.Points.Add(new Vector2(
                            checkPoint.position.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                            checkPoint.position.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                            ));
        line.Points.Add(new Vector2(
                            checkPoint.referencePosition.x * (mapImage.GetComponent <RectTransform>().sizeDelta.x / 1000),
                            checkPoint.referencePosition.z * (mapImage.GetComponent <RectTransform>().sizeDelta.y / 1000)
                            ));
        line.SetVerticesDirty();
    }
    //  drawing
    private void DrawConnection(SocketHandle port1, SocketHandle port2, UILineRenderer lineRenderer)
    {
        var pointList = new List <Vector2>();

        for (float i = 0; i < vertexCount; i++)
        {
            var t = i / vertexCount;
            pointList.Add(Utility.CubicCurve(GetLocalPoint(port1.handle1.position),
                                             GetLocalPoint(port1.handle2.position),
                                             GetLocalPoint(port2.handle1.position),
                                             GetLocalPoint(port2.handle2.position),
                                             t));
        }

        lineRenderer.m_points = pointList.ToArray();
        lineRenderer.SetVerticesDirty();
    }
    private void DrawRequestConnection(Socket socket)
    {
        Vector2 localPointerPos;
        var     success = RectTransformUtility.ScreenPointToLocalPointInRectangle(nodeContainer, Input.mousePosition, null, out localPointerPos);

        PointerLocator.localPosition = localPointerPos;

        var pointList = new List <Vector2>();

        for (float i = 0; i < 120; i++)
        {
            var t = i / 120;
            pointList.Add(QuadraticCurve(socket.handle1.position, socket.handle2.position, PointerLocator.position, t));
        }

        _lineRenderer.m_points = pointList.ToArray();
        _lineRenderer.SetVerticesDirty();
    }
Example #19
0
        private void UpdateLine()
        {
            points = lineRenderer.Points;
            //we want only end point + rectangle intersection point
            if (points.Length != 2)
            {
                Array.Resize(ref points, 2);
            }
            //transformating positions into proper spaces
            var worldEndPoint = lineRenderer.transform.TransformPoint(endPoint);
            var rectEndPoint  = rectTransform.InverseTransformPoint(worldEndPoint);
            //calculating intersection point
            var point           = rectTransform.rect.IntersectionWithRayFromCenter(rectEndPoint);
            var worldStartPoint = rectTransform.TransformPoint(point);
            //finally getting proper point in proper space
            Vector2 rectStartPoint = lineRenderer.transform.InverseTransformPoint(worldStartPoint);

            points[0] = rectStartPoint - offsetVector;
            points[1] = endPoint;
            //forcing refresh
            lineRenderer.SetVerticesDirty();
        }
    // Update is called once per frame
    void Update()
    {
        if (isStarted)
        {
            //Line Renderer
            if (lRTimer >= dayLength)
            {
                lRTimer = Time.deltaTime;
                lR_Incubation1.Points.Add(new Vector2(0, (float)population_Incubation1.Count / population.Count * lR_MaxHeight));
                int   pNum      = (lR_Incubation1.Points.Count - 1);
                float intervalX = lR_MaxWidth / pNum;
                for (int i = 0; i < lR_Incubation1.Points.Count; i++)
                {
                    Vector2 v = lR_Incubation1.Points[i];
                    v = new Vector2(intervalX * i, v.y);
                    lR_Incubation1.Points[i] = v;
                }
                lR_Incubation1.SetVerticesDirty();

                lR_Mild2.Points.Add(new Vector2(0, (float)population_Mild2.Count / population.Count * lR_MaxHeight));
                for (int i = 0; i < lR_Mild2.Points.Count; i++)
                {
                    Vector2 v = lR_Mild2.Points[i];
                    v = new Vector2(intervalX * i, v.y);
                    lR_Mild2.Points[i] = v;
                }
                lR_Mild2.SetVerticesDirty();

                lR_Critical3.Points.Add(new Vector2(0, (float)population_Critical3.Count / population.Count * lR_MaxHeight));
                for (int i = 0; i < lR_Critical3.Points.Count; i++)
                {
                    Vector2 v = lR_Critical3.Points[i];
                    v = new Vector2(intervalX * i, v.y);
                    lR_Critical3.Points[i] = v;
                }
                lR_Critical3.SetVerticesDirty();

                lR_Dead4.Points.Add(new Vector2(0, (float)population_Dead4.Count / population.Count * lR_MaxHeight));
                for (int i = 0; i < lR_Dead4.Points.Count; i++)
                {
                    Vector2 v = lR_Dead4.Points[i];
                    v = new Vector2(intervalX * i, v.y);
                    lR_Dead4.Points[i] = v;
                }
                lR_Dead4.SetVerticesDirty();

                lR_Cured5.Points.Add(new Vector2(0, (float)population_Cured5.Count / population.Count * lR_MaxHeight));
                for (int i = 0; i < lR_Cured5.Points.Count; i++)
                {
                    Vector2 v = lR_Cured5.Points[i];
                    v = new Vector2(intervalX * i, v.y);
                    lR_Cured5.Points[i] = v;
                }
                lR_Cured5.SetVerticesDirty();
            }
            else
            {
                lRTimer += Time.deltaTime;
            }

            //Daily Properties Change
            dayTime               += Time.deltaTime;
            text_Day.text          = "Day " + (Mathf.FloorToInt(dayTime / dayLength) + 1);
            text_DataGroup[0].text = "" + population_Normal0.Count;
            text_DataGroup[1].text = "" + population_Incubation1.Count;
            text_DataGroup[2].text = "" + population_Mild2.Count;
            text_DataGroup[3].text = "" + population_Critical3.Count;
            text_DataGroup[4].text = "" + population_Dead4.Count;
            text_DataGroup[5].text = "" + population_Cured5.Count;

            //text_FatalityRate.text = PercentageConverter((float)population_Dead4.Count / Mathf.Max(1, (population.Count))) + "%";
            text_FatalityRate.text         = PercentageConverter((float)population_Dead4.Count / Mathf.Max(1, (population.Count - population_Normal0.Count))) + "%";
            text_FatalityRate_Student.text = PercentageConverter((float)ageNum_Student_Death / Mathf.Max(1, ageNum_Student)) + "%";
            text_FatalityRate_Adult.text   = PercentageConverter((float)ageNum_Adult_Death / Mathf.Max(1, ageNum_Adult)) + "%";
            text_FatalityRate_Elder.text   = PercentageConverter((float)ageNum_Elder_Death / Mathf.Max(1, ageNum_Elder)) + "%";
            text_EconomyLost.text          = "" + Mathf.RoundToInt(economyLost);
            text_Panic.text = "" + Mathf.RoundToInt(panic);
            text_Bed.text   = currentBed + "/" + currentBedTotal;

            for (int i = 0; i < population_Incubation1.Count; i++)
            {
                Human human = population_Incubation1[i];
                if (human.timeStamp_Incubation < dayTime)
                {
                    //Exposed
                    human.ChangeInfectedType(2);
                    human.timeStamp_Mild = dayTime + curve_MildDay.Evaluate(Random.value) * dayLength;
                    population_Mild2.Add(human);
                    population_Incubation1.Remove(human);
                    panic += 0.1f;
                    i--;
                    continue;
                }
                //Infect check
                float basicInfectRate = Random.value * 1000 / dayLength * Time.deltaTime;
                if (!human.isQuarantined && human.infectedPeopleNum <= num_R0 * 0.5f && basicInfectRate < num_R0 * 1.5f / dayLength)
                {
                    //Start infect
                    foreach (Human humanNormal in population_Normal0)
                    {
                        if (Vector3.Distance(human.transform.position, humanNormal.transform.position) < infectionRadius)
                        {
                            Infected(humanNormal);
                            break;
                        }
                    }
                }
            }

            for (int i = 0; i < population_Mild2.Count; i++)
            {
                Human human = population_Mild2[i];
                if (human.timeStamp_Mild < dayTime)
                {
                    //Become critical?
                    if (human.onlyMild)
                    {
                        human.ChangeInfectedType(5);
                        population_Mild2.Remove(human);
                        population_Cured5.Add(human);
                        panic -= 0.05f;

                        if (human.isQuarantined)
                        {
                            EndQuarantine(human);
                        }
                    }
                    else
                    {
                        human.ChangeInfectedType(3);
                        if (!human.isQuarantined)
                        {
                            TryQuarantined(human);
                        }

                        if (human.isSurvived)
                        {
                            //Check if he's on bed
                            if (!human.isQuarantined || human.useTempBed)
                            {
                                float criticalInHome = 0.5f;
                                if (human.age == 0)
                                {
                                    criticalInHome = ageFatality_Student * 16;
                                }
                                else if (human.age == 1)
                                {
                                    criticalInHome = ageFatality_Adult * 16;
                                }
                                else if (human.age == 2)
                                {
                                    criticalInHome = ageFatality_Elder * 16;
                                }
                                if (Random.value < criticalInHome)
                                {
                                    human.isSurvived = false;
                                }
                                else
                                {
                                    human.timeStamp_Critical = dayTime + curve_CriticalDay.Evaluate(Random.value) * dayLength;
                                }
                            }
                        }
                        if (!human.isSurvived)
                        {
                            human.timeStamp_Critical = dayTime + curve_DeathDay.Evaluate(Random.value) * dayLength;
                        }
                        panic += 0.2f;
                        population_Critical3.Add(human);
                    }
                    population_Mild2.Remove(human);
                    i--;
                    continue;
                }
                //Infect check
                float basicInfectRate = Random.value * 1000 / dayLength * Time.deltaTime;
                if (!human.isQuarantined && human.infectedPeopleNum <= num_R0 && basicInfectRate < num_R0 * 30 / dayLength)
                {
                    //Start infect
                    foreach (Human humanNormal in population_Normal0)
                    {
                        if (Vector3.Distance(human.transform.position, humanNormal.transform.position) < infectionRadius)
                        {
                            Infected(humanNormal);
                            break;
                        }
                    }
                }


                if (!rule3_MildRefuse && !human.isQuarantined)
                {
                    TryQuarantined(human);
                }
            }

            for (int i = 0; i < population_Critical3.Count; i++)
            {
                Human human = population_Critical3[i];
                if (human.timeStamp_Critical < dayTime)
                {
                    if (!human.isSurvived && human.isQuarantined)
                    {
                        if (Random.value < 0.7f)
                        {
                            human.isSurvived = true;
                        }
                    }
                    //Become critical?
                    if (human.isSurvived)
                    {
                        human.ChangeInfectedType(5);
                        population_Cured5.Add(human);
                    }
                    else
                    {
                        //Dead
                        human.ChangeInfectedType(4);
                        population_Dead4.Add(human);
                        economyLost += 1;
                        panic       += 1;

                        if (human.age == 0)
                        {
                            ageNum_Student_Death++;
                        }
                        else if (human.age == 1)
                        {
                            ageNum_Adult_Death++;
                        }
                        else if (human.age == 2)
                        {
                            ageNum_Elder_Death++;
                        }
                    }

                    if (human.isQuarantined)
                    {
                        EndQuarantine(human);
                    }
                    population_Critical3.Remove(human);
                    i--;
                    continue;
                }
                //Infect check
                float basicInfectRate = Random.value * 1000 / dayLength * Time.deltaTime;
                if (!human.isQuarantined && human.infectedPeopleNum <= num_R0 * 2f && basicInfectRate < num_R0 * 3 / dayLength)
                {
                    //Start infect
                    foreach (Human humanNormal in population_Normal0)
                    {
                        if (Vector3.Distance(human.transform.position, humanNormal.transform.position) < infectionRadius * 2)
                        {
                            Infected(humanNormal);
                            break;
                        }
                    }
                }

                if (!human.isQuarantined)
                {
                    TryQuarantined(human);
                }
            }

            economyLost += (0.1f * population_Mild2.Count + 0.5f * population_Critical3.Count + 0.1f * panic) * Time.deltaTime / dayLength;
            if (rule6_TempHospital)
            {
                economyLost += (10 * Time.deltaTime / dayLength);
            }
            panic = Mathf.Max(0, panic - Time.deltaTime / dayLength);
        }

        if (Input.GetButtonDown("Cancel"))
        {
            Application.Quit();
        }
    }
 public void OnFuzzinessValueChanged(float value)
 {
     FuzzinessPlot.Decay = FuzzinessSlider.value;
     FuzzinessPlot.Gamma = CurveSlider.value;
     FuzzinessPlot.SetVerticesDirty();
 }