public UIGachaBoxNew( float xpos, float ypos, float wide = -1f, float high = -1f, bool rare = false, UIMenu openOnClose = null) : base("", xpos, ypos, wide, high) { this._openOnClose = openOnClose; this._rare = rare; this._duckCoin = new SpriteMap("duckCoin", 18, 18); this._duckCoin.CenterOrigin(); this._gachaMachine = new Sprite("arcade/gotcha/machine"); this._gachaMachine.CenterOrigin(); this._gachaGlass = new Sprite("arcade/gotcha/glass"); this._gachaGlass.CenterOrigin(); this._gachaDoor = new Sprite("arcade/gotcha/door"); this._gachaDoor.CenterOrigin(); this._gachaTwister = new Sprite("arcade/gotcha/twister"); this._gachaTwister.CenterOrigin(); this._gachaBall = new SpriteMap("arcade/gotcha/balls", 40, 42); this._gachaBall.CenterOrigin(); this._gachaTwisterShadow = new Sprite("arcade/gotcha/twisterShadow"); this._gachaTwisterShadow.CenterOrigin(); this._whiteCircle = new Sprite("furni/whiteCircle"); this._whiteCircle.CenterOrigin(); this._coin = new SpriteMap("arcade/gotcha/coin", 22, 22); this._coin.CenterOrigin(); this._coinSlot = new Sprite("arcade/gotcha/coinSlot"); this._coinSlot.CenterOrigin(); this._rainbow = new Sprite("arcade/rainbow"); Graphics.fade = 1f; this._frame = new Sprite("unlockFrame"); this._frame.CenterOrigin(); this._furni = new Sprite("furni/tub"); this._furni.center = new Vec2((float)(this._furni.width / 2), (float)this._furni.height); this._star = new Sprite("prettyStar"); this._star.CenterOrigin(); this._font = new BitmapFont("biosFontUI", 8, 7); this._fancyFont = new FancyBitmapFont("smallFontGacha"); this._gachaEgg = new SpriteMap("gachaEgg", 44, 36); this._capsule = new SpriteMap("arcade/egg", 40, 23); this._capsule.CenterOrigin(); this._capsuleBorder = new SpriteMap("arcade/eggBorder", 66, 65); this._capsuleBorder.CenterOrigin(); this._rare = false; this.numGenerate = MonoMain.core.gachas; this.numGenerateRare = MonoMain.core.rareGachas; for (int index = 0; index < this.numGenerate; ++index) { Furniture furniture = UIGachaBox.GetRandomFurniture(Rarity.Common, 1, gacha: true)[0]; furniture.ballRot = Rando.Float(360f); furniture.rareGen = false; this.prizes.Add(furniture); } for (int index = 0; index < this.numGenerateRare; ++index) { Furniture furniture = UIGachaBox.GetRandomFurniture(Rarity.VeryVeryRare, 1, 0.4f, true).OrderBy <Furniture, int>((Func <Furniture, int>)(x => - x.rarity)).ElementAt <Furniture>(0); furniture.ballRot = Rando.Float(360f); furniture.rareGen = true; this.prizes.Add(furniture); } for (int index = 0; index < 3; ++index) { Furniture furniture = UIGachaBox.GetRandomFurniture(Rarity.Common, 1, gacha: true)[0]; furniture.ballRot = Rando.Float(360f); furniture.rareGen = false; this.prizes.Add(furniture); } this.LoadNextPrize(); this._gachaEgg.CenterOrigin(); }
public static List <Furniture> GetRandomFurniture( int minRarity, int num, float rarityMult = 1f, bool gacha = false, int numDupes = 0) { List <Furniture> furnitureList = new List <Furniture>(); IOrderedEnumerable <Furniture> source = RoomEditor.AllFurnis().Where <Furniture>((Func <Furniture, bool>)(x => x.rarity >= minRarity)).OrderBy <Furniture, int>((Func <Furniture, int>)(x => Rando.Int(999999))); for (int index = 0; index < num; ++index) { Furniture winner = (Furniture)null; Furniture furniture1 = (Furniture)null; List <int> intList = new List <int>(); foreach (Furniture furniture2 in (IEnumerable <Furniture>)source) { if (!gacha || furniture2.canGetInGacha) { if (furniture1 == null) { furniture1 = furniture2; } bool flag = Profiles.experienceProfile.GetNumFurnitures((int)furniture2.index) > 0; int _max = 35; if (furniture2.rarity >= Rarity.VeryRare) { _max = 10; } if (furniture2.rarity >= Rarity.SuperRare) { _max = 6; } if ((!flag || furniture2.type == FurnitureType.Prop && (Rando.Int(_max) == 0 || numDupes > 0)) && !intList.Contains(furniture2.rarity)) { if (Profiles.experienceProfile.GetNumFurnitures((int)furniture2.index) <= 0 || Rando.Int(2) == 0) { intList.Add(furniture2.rarity); } if (furniture1 == null || furniture2.rarity < furniture1.rarity) { furniture1 = furniture2; } if ((winner == null || furniture2.rarity > winner.rarity) && (furniture2.rarity == Rarity.Common || Rando.Int((int)((double)furniture2.rarity * (double)rarityMult)) == 0)) { winner = furniture2; } } } } if (winner == null) { winner = furniture1; } if (Profiles.experienceProfile.GetNumFurnitures((int)winner.index) > 0) { --numDupes; } furnitureList.Add(winner); if (index != num - 1) { source = source.Where <Furniture>((Func <Furniture, bool>)(x => x != winner)).OrderBy <Furniture, int>((Func <Furniture, int>)(x => Rando.Int(999999))); } } return(furnitureList); }
public void LoadNextPrize() { this._contains = this.prizes.ElementAt <Furniture>(0); this._capsule.frame = this.FigureFrame(this._contains); }