示例#1
0
        public static List <int> GetRandomOutfit(bool allowBeanie)
        {
            List <int> list = new List <int>();
            Dictionary <ClothingItem, int> ponderatedClothingByTypeChance  = ClothingItemDatabase.GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes.TShirt, (ClothingItem.DisplayTypes) 0);
            Dictionary <ClothingItem, int> ponderatedClothingByTypeChance2 = ClothingItemDatabase.GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes.Pants, ClothingItem.DisplayTypes.FullBody);
            Dictionary <ClothingItem, int> ponderatedClothingByTypeChance3 = ClothingItemDatabase.GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes.TopPartial_Hands | ClothingItem.DisplayTypes.TopPartial_Arms | ClothingItem.DisplayTypes.TopFull_Hands | ClothingItem.DisplayTypes.TopFull_Arms, (ClothingItem.DisplayTypes) 0);
            int max        = ponderatedClothingByTypeChance.Sum((KeyValuePair <ClothingItem, int> s) => s.Value);
            int max2       = ponderatedClothingByTypeChance2.Sum((KeyValuePair <ClothingItem, int> s) => s.Value);
            int max3       = (int)((float)ponderatedClothingByTypeChance3.Sum((KeyValuePair <ClothingItem, int> s) => s.Value) * 1.5f);
            int tshirtRand = UnityEngine.Random.Range(0, max);
            int pantsRand  = UnityEngine.Random.Range(0, max2);
            int topRand    = UnityEngine.Random.Range(0, max3);
            KeyValuePair <ClothingItem, int> keyValuePair = ponderatedClothingByTypeChance.SkipWhile(delegate(KeyValuePair <ClothingItem, int> c)
            {
                tshirtRand -= c.Value;
                return(tshirtRand > 0);
            }).FirstOrDefault <KeyValuePair <ClothingItem, int> >();
            KeyValuePair <ClothingItem, int> keyValuePair2 = ponderatedClothingByTypeChance2.SkipWhile(delegate(KeyValuePair <ClothingItem, int> c)
            {
                pantsRand -= c.Value;
                return(pantsRand > 0);
            }).FirstOrDefault <KeyValuePair <ClothingItem, int> >();
            KeyValuePair <ClothingItem, int> keyValuePair3 = ponderatedClothingByTypeChance3.SkipWhile(delegate(KeyValuePair <ClothingItem, int> c)
            {
                topRand -= c.Value;
                return(topRand > 0);
            }).FirstOrDefault <KeyValuePair <ClothingItem, int> >();
            ClothingItem key  = keyValuePair.Key;
            ClothingItem key2 = keyValuePair2.Key;
            ClothingItem key3 = keyValuePair3.Key;

            if (key3 != null && (key3._id != 9 || (AccountInfo.StoryCompleted && LocalPlayer.Clothing.AmountOf(9) == 0)))
            {
                if (key3._displayType != ClothingItem.DisplayTypes.FullBody)
                {
                    allowBeanie = false;
                }
                list.Add(key3._id);
            }
            if (key3 == null || key3._displayType != ClothingItem.DisplayTypes.FullBody)
            {
                if (key != null)
                {
                    ClothingItemDatabase.CombineClothingItemWithOutfit(list, key);
                }
                if (key2 != null)
                {
                    ClothingItemDatabase.CombineClothingItemWithOutfit(list, key2);
                }
            }
            if (allowBeanie)
            {
                IEnumerable <ClothingItem> source = ClothingItemDatabase.ItemsByType(ClothingItem.DisplayTypes.Hat);
                int num     = ponderatedClothingByTypeChance.Count <KeyValuePair <ClothingItem, int> >();
                int hatRand = UnityEngine.Random.Range(0, num * 3);
                if (hatRand < num)
                {
                    ClothingItem clothingItem = source.Where((ClothingItem ci, int i) => i == hatRand).FirstOrDefault <ClothingItem>();
                    if (clothingItem != null)
                    {
                        ClothingItemDatabase.CombineClothingItemWithOutfit(list, clothingItem);
                    }
                }
            }
            return(list);
        }