Ejemplo n.º 1
0
        public int compare(object o1, object o2)
        {
            //显示物品从左到右按品质顺序显示,相同品质,按 装备,卡片,道具的顺序显示
            if (o1 == null)
            {
                return(1);
            }
            if (o2 == null)
            {
                return(-1);
            }
            if (!(o1 is GameObject) || !(o2 is GameObject))
            {
                return(0);
            }
            GameObject obj1  = (GameObject)o1;
            GameObject obj2  = (GameObject)o2;
            GoodsView  view1 = obj1.transform.GetComponent <GoodsView> ();
            GoodsView  view2 = obj2.transform.GetComponent <GoodsView> ();

            if (view1 == null || view2 == null)
            {
                return(0);
            }
            if (view1.getQuality() == view2.getQuality())
            {
                if (view1.getStortType() > view2.getStortType())
                {
                    return(-1);
                }
                if (view1.getStortType() < view2.getStortType())
                {
                    return(1);
                }
                return(0);
            }
            else
            {
                if (view1.getQuality() > view2.getQuality())
                {
                    return(-1);
                }
                if (view1.getQuality() < view2.getQuality())
                {
                    return(1);
                }
                return(0);
            }
        }
Ejemplo n.º 2
0
        public int compare(object o1, object o2)
        {
            //显示物品从左到右按品质顺序显示,相同品质,按 装备,卡片,道具的顺序显示
            if (o1 == null)
            {
                return(1);
            }
            if (o2 == null)
            {
                return(-1);
            }
            if (!(o1 is GameObject) || !(o2 is GameObject))
            {
                return(0);
            }
            GameObject obj1  = (GameObject)o1;
            GameObject obj2  = (GameObject)o2;
            GoodsView  view1 = obj1.transform.GetComponent <GoodsView> ();
            GoodsView  view2 = obj2.transform.GetComponent <GoodsView> ();

            if ((view1 == null) || (view2 == null))
            {
                return(0);
            }
            int quality1 = view1.getQuality();

            ;
            int quality2   = view2.getQuality();
            int stortType1 = view1.getStortType();
            int stortType2 = view2.getStortType();

            if (quality1 == quality2)
            {
                if (stortType1 > stortType2)
                {
                    return(-1);
                }
                if (stortType1 < stortType2)
                {
                    return(1);
                }
                return(0);
            }
            else
            {
                if (quality1 > quality2)
                {
                    return(-1);
                }
                if (quality1 < quality2)
                {
                    return(1);
                }
                return(0);
            }
        }