Example #1
0
    private DistributionBar NewDistribBar(Color color, float percentageVal)
    {
        DistributionBar dBar = Instantiate(distribBarPrefab, distributionContainer);

        dBar.SetColor(color);
        // Set bar's width depending on percentage
        dBar.SetPercentageVal(percentageVal);
        float newWidth = percentageVal * distributionContainer.rect.width;

        dBar.SetDistribBarWidth(newWidth);

        return(dBar);
    }
Example #2
0
 public void SetGraphProperties(string barName, float percentageVal, float width, bool prefix = false)
 {
     if (garphs.TryGetValue(barName, out RectTransform bar))
     {
         if (!barName.Contains("Dot"))
         {
             DistributionBar dBar = bar.GetComponent <DistributionBar>();
             dBar.SetPercentageVal(percentageVal, prefix);
             dBar.SetDistribBarWidth(width);
         }
         else
         {
             bar.sizeDelta = new Vector2(width, bar.rect.height);
         }
     }
     else
     {
         Debug.LogWarning(barName + " doesn't exist. Eligible barNames are OriginalGraphDot, CurrentGraphBar, TargetGraphDot, OrigTargetSameGraphDot");
     }
 }
Example #3
0
    private void AddOrUpdateGroupDistribBars(PlanningGroup group)
    {
        List <PlanningCell> cells = group.cells;

        foreach (PlanningCell cell in cells)
        {
            Typology typology = cell.typology;
            if (distributionBars.ContainsKey(typology))
            {
                UpdateDistributionBar(typology);
            }
            else
            {
                DistributionBar dBar = NewDistribBar(typology.color, typologyCounts[typology] / (float)totalTypologyCount);
                distributionBars.Add(typology, dBar);
            }

            distributionContainer.gameObject.SetActive((distributionBars.Count > 1) ? true : false);
        }
    }