Exemplo n.º 1
0
        /// <summary>
        /// Adds a new category to the pyramid chart. Each category has it's own material and name. each category corresponds to one pie slice
        /// </summary>
        /// <param name="name">the name of the category</param>
        /// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
        public void AddCategory(string name, ChartDynamicMaterial material, String title, String text, Sprite image, float alpha = 1f, float heightRatio = 1f, float leftSlope = 45f, float rightSlope = 45f, float positionBlend = 1f, float scale = 1f, float shiftX = 0f, float shiftY = 0f)
        {
            if (title == null)
            {
                title = "";
            }
            if (text == null)
            {
                text = "";
            }

            ChartDataColumn column = new ChartDataColumn(name);

            column.Material = material;
            CategoryData d = new CategoryData();

            d.Title         = title;
            d.Text          = text;
            d.Image         = image;
            d.Alpha         = alpha;
            d.HeightRatio   = heightRatio;
            d.LeftSlope     = leftSlope;
            d.RightSlope    = rightSlope;
            d.PositionBlend = positionBlend;
            d.Scale         = scale;
            d.ShiftX        = shiftX;
            d.ShiftY        = shiftY;
            column.UserData = d;
            mDataSource.mColumns.Add(column);
            SetValueInternal(name, "Pyramid", heightRatio);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a new category to the bar chart. Each category has it's own material and name.
        /// Note: you must also add groups to the bar data.
        /// Example: you can set the chart categories to be "Player 1","Player 2","Player 3" in order to compare player achivments
        /// </summary>
        /// <param name="name">the name of the category</param>
        /// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
        public void AddCategory(string name, ChartDynamicMaterial material)
        {
            ChartDataColumn column = new ChartDataColumn(name);

            column.Material = material;
            mDataSource.mColumns.Add(column);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a new category to the bar chart. Each category has it's own material and name.
        /// Note: you must also add groups to the bar data.
        /// Example: you can set the chart categories to be "Player 1","Player 2","Player 3" in order to compare player achivments
        /// </summary>
        /// <param name="name">the name of the category</param>
        /// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
        public void AddCategory(string name, ChartDynamicMaterial material, int position)
        {
            ChartDataColumn column = new ChartDataColumn(name);

            column.Material = material;
            mDataSource.mColumns.Insert(position, column);
        }
        /// <summary>
        /// Adds a new category to the pie chart. Each category has it's own material and name. each category corresponds to one pie slice
        /// </summary>
        /// <param name="name">the name of the category</param>
        /// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
        public void AddCategory(string name, ChartDynamicMaterial material, float radiusScale, float depthScale, float depthOffset)
        {
            radiusScale = Mathf.Clamp(radiusScale, 0f, 1f);
            ChartDataColumn column = new ChartDataColumn(name);

            column.Material = material;
            CategoryData d = new CategoryData();

            d.RadiusScale   = radiusScale;
            d.DepthScale    = depthScale;
            d.DepthOffset   = depthOffset;
            column.UserData = d;
            mDataSource.mColumns.Add(column);
        }
 /// <summary>
 /// sets the material for the specified category
 /// </summary>
 /// <param name="category">the name of the category</param>
 /// <param name="material">the dynamic material of the category. dynamic materials allows setting the material for different events</param>
 public void SetMaterial(string category, ChartDynamicMaterial material)
 {
     mDataSource.Columns[category].Material = material;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a single bar game object using the chart parameters and the bar prefab
        /// </summary>
        /// <param name="innerPosition">the local position of the bar in the chart</param>
        /// <returns>the new bar game object</returns>
        private GameObject CreateBar(Vector3 innerPosition, double value, float size, float elevation, float normalizedSize, string category, string group, int index, int categoryIndex)
        {
            if (BarPrefabLink == null)
            {
                GameObject dummy = new GameObject();
                dummy.AddComponent <ChartItem>();
                dummy.transform.parent = transform;
                return(dummy);
            }

            GameObject topLevel = new GameObject();

            topLevel.AddComponent <ChartItem>();
            topLevel.layer = gameObject.layer;
            topLevel.transform.SetParent(transform, false);
            topLevel.transform.localScale    = new Vector3(1f, 1f, 1f);
            topLevel.transform.localPosition = innerPosition;
            GameObject obj = (GameObject)GameObject.Instantiate(BarPrefabLink);

            Vector3 initialScale = obj.transform.localScale;

            obj.transform.SetParent(topLevel.transform, false);
            obj.transform.localScale = new Vector3(1f, 1f, 1f);

            CharItemEffectController effect = obj.GetComponent <CharItemEffectController>();

            if (effect == null)
            {
                effect = obj.AddComponent <CharItemEffectController>();
            }
            effect.WorkOnParent = true;
            effect.InitialScale = false;
            BarInfo inf = obj.AddComponent <BarInfo>();

            obj.AddComponent <ChartItem>();
            topLevel.transform.localRotation = Quaternion.identity;
            obj.transform.localRotation      = Quaternion.identity;
            obj.transform.localPosition      = Vector3.zero;
            ChartCommon.HideObject(obj, hideHierarchy);
            IBarGenerator generator = obj.GetComponent <IBarGenerator>();

            obj.layer = gameObject.layer;   // put the bar on the same layer as this object
            BarObject barObj = new BarObject();

            ChartCommon.HideObject(topLevel, hideHierarchy);
            barObj.Bar           = generator;
            barObj.BarGameObject = obj;
            barObj.InitialScale  = initialScale;
            barObj.TopObject     = topLevel;
            barObj.InnerPosition = innerPosition;
            barObj.Size          = size;
            barObj.Category      = category;
            barObj.Group         = group;
            barObj.Value         = value;
            barObj.Elevation     = elevation;
            inf.BarObject        = barObj;
            mBars.Add(new ChartItemIndex(index, categoryIndex), barObj);
            ChartItemEvents[] events = obj.GetComponentsInChildren <ChartItemEvents>();
            for (int i = 0; i < events.Length; ++i)
            {
                if (events[i] == null)
                {
                    continue;
                }
                InternalItemEvents comp = (InternalItemEvents)events[i];
                comp.Parent   = this;
                comp.UserData = barObj;
            }

            ChartMaterialController[] materialController = obj.GetComponentsInChildren <ChartMaterialController>();

            for (int i = 0; i < materialController.Length; i++)
            {
                ChartMaterialController m   = materialController[i];
                ChartDynamicMaterial    mat = Data.GetMaterial(category);
                if (mat != null)
                {
                    m.Materials = mat;
                    m.Refresh();
                }
            }

            float ySize = 1f * size * initialScale.y;

            if (generator != null)
            {
                generator.Generate(normalizedSize, ySize);
            }

            SetBarSize(obj, new Vector3(BarSizeLink.Breadth * initialScale.x, ySize, BarSizeLink.Depth * initialScale.z), elevation);

            if (mItemLabels != null && mItemLabels.isActiveAndEnabled)
            {
                string toSet = mItemLabels.TextFormat.Format(ChartAdancedSettings.Instance.FormatFractionDigits(mItemLabels.FractionDigits, value),
                                                             category, group);
                Vector3 labelPos = AlignLabel(mItemLabels, innerPosition, size + elevation);
                float   angle    = 45f;
                if (mItemLabels.Alignment == ChartLabelAlignment.Base)
                {
                    angle = -45f;
                }
                BillboardText billboard = ChartCommon.CreateBillboardText(null, mItemLabels.TextPrefab, topLevel.transform, toSet, labelPos.x, labelPos.y, labelPos.z, angle, obj.transform, hideHierarchy, mItemLabels.FontSize, mItemLabels.FontSharpness);
                //                billboard.UserData =
                //                billboard.UIText.fontSize = ItemLabels.FontSize;
                // billboard.transform.parent =;
                barObj.ItemLabel = billboard;
                TextController.AddText(billboard);
            }

            if (mGroupLabels != null && mGroupLabels.isActiveAndEnabled)
            {
                if (mGroupLabels.Alignment == GroupLabelAlignment.BarBottom || mGroupLabels.Alignment == GroupLabelAlignment.BarTop || (mGroupLabels.Alignment == GroupLabelAlignment.FirstBar && index == 0))
                {
                    Vector3 labelPos = AlignLabel(mGroupLabels, innerPosition, size + elevation);
                    string  toSet    = mGroupLabels.TextFormat.Format(group, category, group);
                    // float angle = 45f;
                    BillboardText billboard = ChartCommon.CreateBillboardText(null, mGroupLabels.TextPrefab, topLevel.transform, toSet, labelPos.x, labelPos.y, labelPos.z, 0f, obj.transform, hideHierarchy, mGroupLabels.FontSize, mGroupLabels.FontSharpness);
                    barObj.GroupLabel = billboard;
                    TextController.AddText(billboard);
                }
            }
            if (mCategoryLabels != null && mCategoryLabels.isActiveAndEnabled)
            {
                if (mCategoryLabels.VisibleLabels != CategoryLabels.ChartCategoryLabelOptions.FirstOnly ||
                    index == 0)
                {
                    Vector3 labelPos = AlignLabel(mCategoryLabels, innerPosition, size + elevation);
                    string  toSet    = mCategoryLabels.TextFormat.Format(category, category, group);
                    float   angle    = 45f;
                    if (mCategoryLabels.Alignment == ChartLabelAlignment.Base)
                    {
                        angle = -45f;
                    }
                    BillboardText billboard = ChartCommon.CreateBillboardText(null, mCategoryLabels.TextPrefab, topLevel.transform, toSet, labelPos.x, labelPos.y, labelPos.z, angle, obj.transform, hideHierarchy, mCategoryLabels.FontSize, mCategoryLabels.FontSharpness);
                    barObj.CategoryLabel = billboard;
                    TextController.AddText(billboard);
                }
            }

            if (Orientation == ChartOrientation.Horizontal)
            {
                obj.transform.localRotation = Quaternion.Euler(0f, 0, -90f);
            }
            return(obj);
        }
Exemplo n.º 7
0
 /// <summary>
 /// sets the material for the specified category
 /// </summary>
 /// <param name="category">the name of the category</param>
 /// <param name="material">the dynamic material of the category. dynamic materials allow setting the material for different events</param>
 public void SetMaterial(string category, ChartDynamicMaterial material)
 {
     mDataSource.Columns[category].Material = material;
     RaisePropertyUpdated();
 }