Пример #1
0
        public void Refresh(ColorBar_ModelCollection modelCollection)
        {
            Dictionary <int, decimal>       ExpenseTotals     = DataReformatter.GetExpenseTotalsDict(modelCollection.CatagoryModels, modelCollection.ExpenseModels);
            Dictionary <int, CatagoryModel> CatagoryModelDict = DataReformatter.GetCatagoryModelsDict(modelCollection.CatagoryModels);

            float fullWidth = 0.00f;

            foreach (ColorBarElement colorBarElement in ColorBarElements)
            {
                colorBarElement.transform.localPosition = new Vector3(fullWidth, 0, 0);
                float currentWidth = ((float)ExpenseTotals[colorBarElement.CatagoryID] / (float)modelCollection.GoalModel.Amount) * ScreenWidth;
                // Fixes a float inaccuracy bug where a sliver of color for catagories that have no expenses was showing.
                currentWidth = currentWidth >= 1 ? currentWidth : 0;
                colorBarElement.UpdateView(CatagoryModelDict[colorBarElement.CatagoryID], currentWidth);
                fullWidth += currentWidth;
            }
        }
Пример #2
0
        public void ConstructView(ColorBar_ModelCollection modelCollection, ColorBarElement original)
        {
            int count = 0;

            foreach (CatagoryModel catagoryModel in modelCollection.CatagoryModels)
            {
                ColorBarElement newBar;
                if (count++ == 0)
                {
                    newBar = original;
                }
                else
                {
                    newBar = GameObject.Instantiate <ColorBarElement>(original: original, parent: original.transform.parent.gameObject.transform);
                }
                newBar.SetID(catagoryModel.CatagoryID);
                ColorBarElements.Add(newBar);
            }
            Refresh(modelCollection);
        }