private void Awake()
    {
        instance          = this;
        graphContainer    = transform.Find("graphContainer").GetComponent <RectTransform>();
        labelTemplateX    = graphContainer.Find("labelTemplateX").GetComponent <RectTransform>();
        lableTemplateY    = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();
        dashTemplateX     = graphContainer.Find("dashTemplateX").GetComponent <RectTransform>();
        dashTemplateY     = graphContainer.Find("dashTemplateY").GetComponent <RectTransform>();
        tooltipGameObject = graphContainer.Find("ToolTip").gameObject;

        gameObjectList        = new List <GameObject>();
        yLabelList            = new List <RectTransform>();
        graphVisualObjectList = new List <IGraphVisualObject>();

        //List<int> valueList = new List<int>() { 5, 98, 56, 45, 30, 22, 17, 15, 13, 17, 25, 37, 40, 36, 33,60,54,22,67,98,34,25,2,7,87 };

        IGraphVisual lineGraphVisual = new LineGraphVisual(graphContainer, dot, Color.green, Color.white);
        IGraphVisual barGraphVisual  = new BarChartVisual(graphContainer, Color.green, 0.8f);

        transform.Find("barGraphButton").GetComponent <Button>().onClick.AddListener(() => SetGraphVisual(barGraphVisual));
        transform.Find("LineGraphButton").GetComponent <Button>().onClick.AddListener(() => SetGraphVisual(lineGraphVisual));
        transform.Find("increaseVisibleButton").GetComponent <Button>().onClick.AddListener(() => IncreaseGraphVisual());
        transform.Find("decreaseVisibleButton").GetComponent <Button>().onClick.AddListener(() => DecreaseGraphVisual());
        transform.Find("DollarYlabelButton").GetComponent <Button>().onClick.AddListener(() => SetGetAxisLabelY((float _f) => "$" + Mathf.RoundToInt(_f)));
        transform.Find("EuroYlabelButton").GetComponent <Button>().onClick.AddListener(() => SetGetAxisLabelY((float _f) => "€" + Mathf.RoundToInt(_f / 1.18f)));

        HideToolTip();
        //ShowGraph(valueList, barGraphVisual, -1, (int _i) => "Day" + (_i + 1), (float _f) => "$" + Mathf.RoundToInt(_f));
    }
示例#2
0
    /// <summary>
    ///
    /// </summary>
    public void Start()
    {
        InfectionRadius   = 1.5f;
        scaleFactor       = 1f;
        buildingHalfWidth = scaleFactor / 2.0f;
        sepForceMult      = 20.0f;
        isRunning         = false;
        simValues         = GameObject.Find("SimValues").GetComponent <SimulationValues>();
        GameObject simulation = GameObject.Find("Simulation");

        actors           = GameObject.Find("Actors");
        healthyGraph     = GameObject.Find("healthyGraph").GetComponent <Window_Graph>();
        infectedGraph    = GameObject.Find("infectedGraph").GetComponent <Window_Graph>();
        StartResetButton = GameObject.Find("Start_Reset_Button");

        graphTimer = 0;
        highest    = 0;
        GraphTexts = new List <TextMeshProUGUI>();
        GraphTexts.AddRange(GameObject.Find("GraphData").GetComponentsInChildren <TextMeshProUGUI>());
        GraphTexts.AddRange(GameObject.Find("GraphStats").GetComponentsInChildren <TextMeshProUGUI>());

        StartResetButton.GetComponent <Button>().onClick.AddListener(() =>
        {
            StartButtonPress();
        });
        SimulationExtents  = simulation.GetComponent <BoxCollider2D>().bounds.extents;
        SimulationPosition = simulation.transform.position;
        InitializePrefabs();
    }
示例#3
0
 public BarChartVisual(RectTransform graphContainer, Color barColor, float barWidthMultiplier, Window_Graph windowGraph)
 {
     this.graphContainer     = graphContainer;
     this.barColor           = barColor;
     this.barWidthMultiplier = barWidthMultiplier;
     this.windowGraph        = windowGraph;
 }
 private void Awake()
 {
     graphContainer = transform.Find("graphContainer").GetComponent <RectTransform>();
     background     = transform.Find("background").GetComponent <RectTransform>();
     instance       = this;
     CreateLinesGraph();
 }
示例#5
0
 public LineGraphVisual(RectTransform graphContainer, Sprite dotSprite, Color dotColor, Color dotConnectionColor, Window_Graph windowGraph)
 {
     this.graphContainer       = graphContainer;
     this.dotSprite            = dotSprite;
     this.dotColor             = dotColor;
     this.dotConnectionColor   = dotConnectionColor;
     this.windowGraph          = windowGraph;
     lastLineGraphVisualObject = null;
 }
示例#6
0
 private void Awake()
 {
     window_Graph   = this;
     graphicObjects = new GameObject("graphicObjects");         /* Se crea un objeto PADRE donde se almacenaran como hijos todos los objetos de la grafica*/
     graphContainer = transform.Find("graphContainer").GetComponent <RectTransform>();
     graphicObjects.transform.SetParent(graphContainer, false); /* El objeto graphic objects sera hijo de graphContainer*/
     labelTemplateX = graphContainer.Find("labelTemplateX").GetComponent <RectTransform>();
     labelTemplateY = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();
     dashTemplateX  = graphContainer.Find("dashTemplateX").GetComponent <RectTransform>();
     dashTemplateY  = graphContainer.Find("dashTemplateY").GetComponent <RectTransform>();
 }
    private void ShowResult()
    {
        GameObject   resultCanvas = GameObject.Find("Canvas");
        Window_Graph resultGraph  = GameObject.Find("Window_Graph").GetComponent <Window_Graph>();

        resultCanvas.transform.GetComponent <Canvas>().enabled = true;
        Debug.Log(resultGraph);
        Debug.Log(PositionList);
        resultGraph.valueList = PositionList;
        resultGraph.ShowGraph(resultGraph.valueList);
        CancelInvoke("RecordDistance");
    }
示例#8
0
            public LineGraphVisualObject(GameObject dotGameObject, GameObject dotConnectionGameObject, LineGraphVisualObject lastVisualObject, Window_Graph windowGraph)
            {
                this.dotGameObject           = dotGameObject;
                this.dotConnectionGameObject = dotConnectionGameObject;
                this.lastVisualObject        = lastVisualObject;
                this.windowGraph             = windowGraph;

                if (lastVisualObject != null)
                {
                    lastVisualObject.OnChangedGraphVisualObjectInfo += LastVisualObject_OnChangedGraphVisualObjectInfo;
                }
            }
    private void Awake()
    {
        instance = this;
        // Grab base objects references
        graphContainer = transform.Find("graphContainer").GetComponent <RectTransform>();
        labelTemplateY = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();

        startYScaleAtZero     = true;
        gameObjectList        = new List <GameObject>();
        yLabelList            = new List <RectTransform>();
        graphVisualObjectList = new List <IGraphVisualObject>();

        IGraphVisual lineGraphVisual = new LineGraphVisual(graphContainer, dotSprite, Color.green, new Color(1, 1, 1, .5f));



        // Set up base values
        List <int> valueList = new List <int>()
        {
            0, 0
        };

        ShowGraph(valueList, lineGraphVisual, -1, (int _i) => "Day " + (_i + 1), (float _f) => Mathf.RoundToInt(_f).ToString());

        /*
         * // Automatically modify graph values and visual
         * bool useBarChart = true;
         * FunctionPeriodic.Create(() => {
         *  for (int i = 0; i < valueList.Count; i++) {
         *      valueList[i] = Mathf.RoundToInt(valueList[i] * UnityEngine.Random.Range(0.8f, 1.2f));
         *      if (valueList[i] < 0) valueList[i] = 0;
         *  }
         *  if (useBarChart) {
         *      ShowGraph(valueList, barChartVisual, -1, (int _i) => "Day " + (_i + 1), (float _f) => "$" + Mathf.RoundToInt(_f));
         *  } else {
         *      ShowGraph(valueList, lineGraphVisual, -1, (int _i) => "Day " + (_i + 1), (float _f) => "$" + Mathf.RoundToInt(_f));
         *  }
         *  useBarChart = !useBarChart;
         * }, .5f);
         * //*/

        int index = 0;

        FunctionPeriodic.Create(() => {
            //int index = UnityEngine.Random.Range(0, valueList.Count);
            //UpdateValue(index, valueList[index] + UnityEngine.Random.Range(1, 3));
            addValue(GameLogic.instance.infectedCount);
            ShowGraph(valueList, lineGraphVisual, valueList.Count, (int _i) => "Day " + (_i + 1), (float _f) => Mathf.RoundToInt(_f).ToString());
        }, 10f);
    }
示例#10
0
    private void Awake()
    {
        instance = this;
        // Grab base objects references
        graphContainer = transform.Find("graphContainer").GetComponent <RectTransform>();
        labelTemplateX = graphContainer.Find("labelTemplateX").GetComponent <RectTransform>();
        labelTemplateY = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();

        gameObjectList        = new List <GameObject>();
        yLabelList            = new List <RectTransform>();
        graphVisualObjectList = new List <IGraphVisualObject>();

        // Set up base values
        ShowGraph(store.Scores, -1);
    }
    public void ChiSquareRandom()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float minRange = UI_Conversions.UserInputToFloat(rangeMinimum);
        float maxRange = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || minRange == -1 || maxRange == -1)
        {
            return;
        }

        List <float> chiSquareRandomNumbers = new List <float>();

        Randomness.Instance.UnityRandom(numToGen, 0.0f, 1.0f, ref chiSquareRandomNumbers);

        //Square the values
        for (int i = 0; i < chiSquareRandomNumbers.Count; i++)
        {
            chiSquareRandomNumbers[i] *= chiSquareRandomNumbers[i];
            //Values are still between 0.0f and 1.0f, need to scale them to min and max values
            chiSquareRandomNumbers[i] = minRange + (chiSquareRandomNumbers[i] * ((maxRange - minRange)));
        }

        if (roundingToggle.isOn)
        {
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref chiSquareRandomNumbers, decimalPlaceRound);
        }
        chiSquareRandomNumbers.Sort();

        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(chiSquareRandomNumbers, ref minCount, ref maxCount);

        wg.Graph(counts, new Vector2(minRange, maxRange), new Vector2(minCount, maxCount));
    }
    public void UnityRandomRange()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float minRange = UI_Conversions.UserInputToFloat(rangeMinimum);
        float maxRange = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || minRange == -1 || maxRange == -1)
        {
            return;
        }

        List <float> unityRandomRangeNumbers = new List <float>();

        Randomness.Instance.UnityRandom(numToGen, minRange, maxRange, ref unityRandomRangeNumbers);

        if (roundingToggle.isOn)
        {
            //Mild rounding to make it easier
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref unityRandomRangeNumbers, decimalPlaceRound);
        }
        //Sort the list
        unityRandomRangeNumbers.Sort();

        //Count the number of occurences of each value
        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(unityRandomRangeNumbers, ref minCount, ref maxCount);

        //plot that count vs the value
        wg.Graph(counts, new Vector2(minRange, maxRange), new Vector2(minCount, maxCount));
    }
    public void CSharpRandom()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float minRange = UI_Conversions.UserInputToFloat(rangeMinimum);
        float maxRange = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || minRange == -1 || maxRange == -1)
        {
            return;
        }

        List <float> cSharpRandomNumbers = new List <float>();

        Randomness.Instance.CSharpRandom(numToGen, minRange, maxRange, ref cSharpRandomNumbers);

        if (roundingToggle.isOn)
        {
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref cSharpRandomNumbers, decimalPlaceRound);
        }

        cSharpRandomNumbers.Sort();

        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(cSharpRandomNumbers, ref minCount, ref maxCount);

        wg.Graph(counts, new Vector2(minRange, maxRange), new Vector2(minCount, maxCount));
    }
    public void GaussianRandom()
    {
        wg = windowGraph.GetComponent <Window_Graph>();
        if (wg == null)
        {
            Debug.Log("wg is null");
            return;
        }

        Clear(wg);

        int   numToGen = UI_Conversions.UserInputToInt(numberToGenerate);
        float mean     = UI_Conversions.UserInputToFloat(rangeMinimum);
        float stdDev   = UI_Conversions.UserInputToFloat(rangeMaximum);

        if (numToGen == -1 || mean == -1 || stdDev == -1)
        {
            return;
        }

        List <float> standardDistributionRandomNumbers = new List <float>();

        Randomness.Instance.GaussianRandom(numToGen, mean, stdDev, ref standardDistributionRandomNumbers);

        if (roundingToggle.isOn)
        {
            int decimalPlaceRound = UI_Conversions.UserInputToInt(roundingPlaces.options[roundingPlaces.value].text);
            RoundToDecimalPlaces(ref standardDistributionRandomNumbers, decimalPlaceRound);
        }

        standardDistributionRandomNumbers.Sort();

        int            minCount = System.Int32.MaxValue;
        int            maxCount = System.Int32.MinValue;
        List <Vector2> counts   = CountOccurences(standardDistributionRandomNumbers, ref minCount, ref maxCount);

        wg.Graph(counts, new Vector2(mean + stdDev * -3.0f, mean + stdDev * 3.0f), new Vector2(minCount, maxCount));
    }
示例#15
0
    private void Awake()
    {
        instance = this;
        // Grab base objects references
        graphContainer    = transform.Find("graphContainer").GetComponent <RectTransform>();
        labelTemplateX    = graphContainer.Find("labelTemplateX").GetComponent <RectTransform>();
        labelTemplateY    = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();
        dashContainer     = graphContainer.Find("dashContainer").GetComponent <RectTransform>();
        dashTemplateX     = dashContainer.Find("dashTemplateX").GetComponent <RectTransform>();
        dashTemplateY     = dashContainer.Find("dashTemplateY").GetComponent <RectTransform>();
        tooltipGameObject = graphContainer.Find("tooltip").gameObject;

        gameObjectList        = new List <GameObject>();
        graphVisualObjectList = new List <IGraphVisualObject>();

        lineGraphVisual = new LineGraphVisual(graphContainer, dotSprite, Color.green, new Color(1, 1, 1, .5f));
        barChartVisual  = new BarChartVisual(graphContainer, Color.white, .8f);

        HideTooltip();

        //valueList = graphValues;
        //ShowGraph(valueList, barChartVisual, -1, (int _i) => "", (float _f) => Mathf.RoundToInt(_f) + " °C");
    }
示例#16
0
 private void Start()
 {
     _originalRotX = bikeBody.rotation.x;
     _originalRotZ = bikeBody.rotation.z;
     window_graph  = GameObject.FindGameObjectWithTag("myWindowGraph").GetComponent <Window_Graph>();
 }
示例#17
0
 public BarChartVisualObject(GameObject barGameObject, float barWidthMultiplier, Window_Graph windowGraph)
 {
     this.barGameObject      = barGameObject;
     this.barWidthMultiplier = barWidthMultiplier;
     this.windowGraph        = windowGraph;
 }
 public void Clear(Window_Graph wg)
 {
     wg.Clear();
 }
示例#19
0
    private void Awake()
    {
        instance = this;
        // Grab base objects references
        graphContainer    = transform.Find("graphContainer").GetComponent <RectTransform>();
        labelTemplateX    = graphContainer.Find("labelTemplateX").GetComponent <RectTransform>();
        labelTemplateY    = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();
        dashContainer     = graphContainer.Find("dashContainer").GetComponent <RectTransform>();
        dashTemplateX     = dashContainer.Find("dashTemplateX").GetComponent <RectTransform>();
        dashTemplateY     = dashContainer.Find("dashTemplateY").GetComponent <RectTransform>();
        tooltipGameObject = graphContainer.Find("tooltip").gameObject;

        startYScaleAtZero     = true;
        gameObjectList        = new List <GameObject>();
        yLabelList            = new List <RectTransform>();
        graphVisualObjectList = new List <IGraphVisualObject>();

        lineGraphVisual = new LineGraphVisual(graphContainer, dotSprite, Color.green, new Color(1, 1, 1, .5f));
        barChartVisual  = new BarChartVisual(graphContainer, Color.white, .8f);
        // Set up buttons
        //transform.Find("barChartBtn").GetComponent<Button_UI>().ClickFunc = () => {
        //    SetGraphVisual(barChartVisual);
        //};
        //transform.Find("lineGraphBtn").GetComponent<Button_UI>().ClickFunc = () => {
        //    SetGraphVisual(lineGraphVisual);
        //};

        //transform.Find("decreaseVisibleAmountBtn").GetComponent<Button_UI>().ClickFunc = () => {
        //    DecreaseVisibleAmount();
        //};
        //transform.Find("increaseVisibleAmountBtn").GetComponent<Button_UI>().ClickFunc = () => {
        //    IncreaseVisibleAmount();
        //};

        //transform.Find("dollarBtn").GetComponent<Button_UI>().ClickFunc = () => {
        //    SetGetAxisLabelY((float _f) => "$" + Mathf.RoundToInt(_f));
        //};
        //transform.Find("euroBtn").GetComponent<Button_UI>().ClickFunc = () => {
        //    SetGetAxisLabelY((float _f) => "€" + Mathf.RoundToInt(_f / 1.18f));
        //};

        HideTooltip();

        // Set up base values
        //List<int> valueList = new List<int>() { 12, 17, 19, 22, 30, 12, 17, 19, 22, 30 };
        //ShowGraph(valueList, lineGraphVisual, -1, (int _i) => "" + (_i + 1), (float _f) => "" + _f);

        /*
         * // Automatically modify graph values and visual
         * bool useBarChart = true;
         * FunctionPeriodic.Create(() => {
         *  for (int i = 0; i < valueList.Count; i++) {
         *      valueList[i] = Mathf.RoundToInt(valueList[i] * UnityEngine.Random.Range(0.8f, 1.2f));
         *      if (valueList[i] < 0) valueList[i] = 0;
         *  }
         *  if (useBarChart) {
         *      ShowGraph(valueList, barChartVisual, -1, (int _i) => "Day " + (_i + 1), (float _f) => "$" + Mathf.RoundToInt(_f));
         *  } else {
         *      ShowGraph(valueList, lineGraphVisual, -1, (int _i) => "Day " + (_i + 1), (float _f) => "$" + Mathf.RoundToInt(_f));
         *  }
         *  useBarChart = !useBarChart;
         * }, .5f);
         * //*/

        //int index = 0;
        //FunctionPeriodic.Create(() => {
        //    index = (index + 1) % valueList.Count;
        //}, .1f);
        //FunctionPeriodic.Create(() => {
        //    //int index = UnityEngine.Random.Range(0, valueList.Count);
        //    UpdateValue(index, valueList[index] + UnityEngine.Random.Range(1, 3));
        //}, .02f);
    }
示例#20
0
    IEnumerator Start()
    {
        instance          = this;
        graphContainer    = transform.Find("graphContainer").GetComponent <RectTransform>();
        labelTemplateX    = graphContainer.Find("labelTemplateX").GetComponent <RectTransform>();
        labelTemplateY    = graphContainer.Find("labelTemplateY").GetComponent <RectTransform>();
        dashTemplateX     = graphContainer.Find("dashTemplateX").GetComponent <RectTransform>();
        dashTemplateY     = graphContainer.Find("dashTemplateY").GetComponent <RectTransform>();
        tooltipGameObject = graphContainer.Find("tooltip").gameObject;

        startYScaleAtZero     = true;
        gameObjectList        = new List <GameObject>();
        yLabelList            = new List <RectTransform>();
        graphVisualObjectList = new List <IGraphVisualObject>();

        IGraphVisual lineGraphVisual = new LineGraphVisual(graphContainer, dotSprite, new Color32(85, 165, 255, 255), new Color32(85, 165, 255, 100));
        IGraphVisual barChartVisual  = new BarChartVisual(graphContainer, new Color32(85, 165, 255, 255), .8f);

        //buttons to change graph interface
        transform.Find("barChartBtn").GetComponent <Button_UI>().ClickFunc = () =>
        {
            SetGraphVisual(barChartVisual);
        };
        transform.Find("lineGraphBtn").GetComponent <Button_UI>().ClickFunc = () =>
        {
            SetGraphVisual(lineGraphVisual);
        };
        transform.Find("decreaseVisibleAmountBtn").GetComponent <Button_UI>().ClickFunc = () => {
            DecreaseVisibleAmount();
        };
        transform.Find("increaseVisibleAmountBtn").GetComponent <Button_UI>().ClickFunc = () => {
            IncreaseVisibleAmount();
        };


        //values to be used in the graph
        List <int> valueList = new List <int>()
        {
        };
        WWW tagsTime = new WWW("http://localhost:81/percentsdata/showTotalTime.php");

        yield return(tagsTime);

        string[] timeArray = tagsTime.text.Split(';');

        int numrows = int.Parse(timeArray[0]);

        bool skipFirst = false;

        foreach (string str in timeArray)
        {
            if (skipFirst)
            {
                int mins = (Int32.Parse(str)) / 60 / 60;
                valueList.Add(mins);
            }
            skipFirst = true;
        }

        WWW tagsName = new WWW("http://localhost:81/percentsdata/ShowTags.php");

        yield return(tagsName);

        //string tagsDataString = tagsData.text;
        string[] nameArray = tagsName.text.Split(';');
        int      num       = Int32.Parse(nameArray[0]);

        string[] names = new string[num];
        Array.Copy(nameArray, 1, names, 0, num);

        //to be performed on startup
        ShowGraph(valueList, barChartVisual, -1, (int _i) => names[(_i)], (float _f) => Mathf.RoundToInt(_f) + " hrs");
    }