public CandleBall(float xpos, float ypos, FlareGun owner, int numFlames = 8) : base(xpos, ypos) { this._sprite = new SpriteMap("candleBall", 16, 16); this._sprite.AddAnimation("burn", (float)(0.400000005960464 + (double)Rando.Float(0.2f)), true, 0, 1); this._sprite.SetAnimation("burn"); this._sprite.imageIndex = Rando.Int(4); this.graphic = (Sprite)this._sprite; this.center = new Vec2(8f, 8f); this.collisionOffset = new Vec2(-4f, -2f); this.collisionSize = new Vec2(9f, 4f); this.depth = new Depth(0.9f); this.thickness = 1f; this.weight = 1f; this.breakForce = 1E+08f; this._owner = owner; this.weight = 0.5f; this.gravMultiplier = 0.7f; this._numFlames = numFlames; Color[] colorArray = new Color[4] { Color.Red, Color.Green, Color.Blue, Color.Orange }; this._sprite.color = colorArray[Rando.Int(((IEnumerable <Color>)colorArray).Count <Color>() - 1)]; this.xscale = this.yscale = Rando.Float(0.4f, 0.8f); }
private static void FinishedTotalQuery(object sender) { WorkshopQueryAll workshopQueryAll = sender as WorkshopQueryAll; if (workshopQueryAll.numResultsTotal <= 0U) { return; } int num = Rando.Int((int)(workshopQueryAll.numResultsTotal / 50U)) + 1; if (RandomLevelDownloader.numSinceLowRating > 3) { RandomLevelDownloader.numSinceLowRating = 0; } else { num %= 10; } RandomLevelDownloader._orderMode = RandomLevelDownloader.numSinceLowRating != 2 ? WorkshopQueryFilterOrder.RankedByVote : WorkshopQueryFilterOrder.RankedByTrend; if (num == 0) { num = 1; } ++RandomLevelDownloader.numSinceLowRating; WorkshopQueryAll queryAll = Steam.CreateQueryAll(RandomLevelDownloader._orderMode, WorkshopType.Items); queryAll.requiredTags.Add("Deathmatch"); queryAll.ResultFetched += new WorkshopQueryResultFetched(RandomLevelDownloader.Fetched); queryAll.page = (uint)num; queryAll.justOnePage = true; queryAll.Request(); }
public override void Initialize() { List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables); physicsObjects.RemoveAll((Predicate <System.Type>)(t => t == typeof(Present) || t == typeof(LavaBarrel) || t == typeof(Grapple))); this._contains = physicsObjects[Rando.Int(physicsObjects.Count - 1)]; }
private static SpawnPoint AttemptCTFSpawn( Profile profile, List <SpawnPoint> usedSpawns, List <Duck> spawned, bool red) { int num = red ? 1 : 2; List <SpawnPoint> spawnPointList = new List <SpawnPoint>(); foreach (FreeSpawn freeSpawn in Level.current.things[typeof(FreeSpawn)]) { if (!usedSpawns.Contains((SpawnPoint)freeSpawn) && (int)freeSpawn.spawnType == num) { spawnPointList.Add((SpawnPoint)freeSpawn); } } if (spawnPointList.Count == 0) { return((SpawnPoint)null); } SpawnPoint spawnPoint = spawnPointList[Rando.Int(spawnPointList.Count - 1)]; usedSpawns.Add(spawnPoint); Duck duck = new Duck(spawnPoint.x, spawnPoint.y - 7f, profile); duck.offDir = spawnPoint.offDir; spawned.Add(duck); return(spawnPoint); }
private static SpawnPoint AttemptAnySpawn( Profile profile, List <SpawnPoint> usedSpawns, List <Duck> spawned) { List <SpawnPoint> spawnPointList = new List <SpawnPoint>(); foreach (SpawnPoint spawnPoint in Level.current.things[typeof(SpawnPoint)]) { if (!usedSpawns.Contains(spawnPoint)) { spawnPointList.Add(spawnPoint); } } if (spawnPointList.Count == 0) { if (usedSpawns.Count <= 0) { return((SpawnPoint)null); } spawnPointList.AddRange((IEnumerable <SpawnPoint>)usedSpawns); } SpawnPoint spawnPoint1 = spawnPointList[Rando.Int(spawnPointList.Count - 1)]; usedSpawns.Add(spawnPoint1); Duck duck = new Duck(spawnPoint1.x, spawnPoint1.y - 7f, profile); duck.offDir = spawnPoint1.offDir; spawned.Add(duck); return(spawnPoint1); }
public override void Initialize() { Layer.HUD.camera.size *= 4f; int num1 = 19; int num2 = 3; TourneyGroup tourneyGroup1 = new TourneyGroup(); int num3 = 0; foreach (Team p in Teams.allRandomized) { tourneyGroup1.AddPlayer(p, true); if (tourneyGroup1.players.Count == num2) { this._groups.Add(tourneyGroup1); tourneyGroup1 = new TourneyGroup(); tourneyGroup1.groupIndex = this._groups.Count; } ++num3; if (num3 == num1) { break; } } if (tourneyGroup1.players.Count > 0) { this._groups.Add(tourneyGroup1); } List <TourneyGroup> tourneyGroupList1 = this._groups; List <TourneyGroup> tourneyGroupList2 = new List <TourneyGroup>(); int num4 = 1; while (tourneyGroupList1.Count > 1) { int num5 = 0; TourneyGroup tourneyGroup2 = (TourneyGroup)null; foreach (TourneyGroup tourneyGroup3 in tourneyGroupList1) { if (tourneyGroup2 == null) { num5 = 0; tourneyGroup2 = new TourneyGroup(); tourneyGroup2.groupIndex = tourneyGroupList2.Count; tourneyGroup2.depth = num4; tourneyGroupList2.Add(tourneyGroup2); } tourneyGroup3.next = tourneyGroup2; tourneyGroup3.next.AddPlayer(tourneyGroup3.players[Rando.Int(tourneyGroup3.players.Count - 1)]); ++num5; if (num5 == num2) { tourneyGroup2 = (TourneyGroup)null; } } ++num4; tourneyGroupList1 = tourneyGroupList2; tourneyGroupList2 = new List <TourneyGroup>(); } base.Initialize(); }
public T2 GetRandom(T group) { if (this._items.ContainsKey(group)) { return(this._items[group][Rando.Int(this._items[group].Count - 1)]); } return(this._globalItems.Count > 0 ? this._globalItems[Rando.Int(this._globalItems.Count - 1)] : default(T2)); }
protected override string OnGetLocalName() { if (this._localName == "") { this._localName = "test " + Rando.Int(235645).ToString(); } return(this._localName); }
public override void AddFire() { SpriteMap spriteMap = new SpriteMap("surfaceFire", 16, 10); spriteMap.AddAnimation("idle", 0.2f, true, 0, 1, 2, 3); spriteMap.SetAnimation("idle"); spriteMap.center = new Vec2(8f, 10f); spriteMap.frame = Rando.Int(3); this._surfaceFire.Add(spriteMap); }
public UIGachaBox( 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(); 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); bool flag = false; if (Rando.Int(10) == 5) { flag = true; } this._contains = UIGachaBox.GetRandomFurniture(this._rare ? Rarity.VeryVeryRare : Rarity.Common, 1, flag ? 0.75f : (this._rare ? 0.75f : 1f), true)[0]; this._rareCapsule = this._contains.rarity >= Rarity.VeryVeryRare; if (this._rareCapsule) { this._gachaEgg.frame = 36; } else { this._gachaEgg.frame = Rando.Int(2) * 12; if (Rando.Int(1000) == 1) { this._gachaEgg.frame += 9; } else if (Rando.Int(500) == 1) { this._gachaEgg.frame += 6; } else if (Rando.Int(100) == 1) { this._gachaEgg.frame += 3; } } this._gachaEgg.CenterOrigin(); }
private static void Fetched(object sender, WorkshopQueryResult result) { if (RandomLevelDownloader._toFetchIndex == -1) { RandomLevelDownloader._toFetchIndex = Rando.Int((int)(sender as WorkshopQueryAll).numResultsFetched); } if (RandomLevelDownloader._toFetchIndex == RandomLevelDownloader._numFetch && Steam.DownloadWorkshopItem(result.details.publishedFile)) { RandomLevelDownloader._downloading = result.details.publishedFile; } RandomLevelDownloader._currentQuery = (WorkshopQueryAll)null; ++RandomLevelDownloader._numFetch; }
public UnlockableHats( string identifier, List <Team> t, Func <bool> condition, string nam, string desc, string achieve = "") : base(identifier, condition, nam, desc, achieve) { this._teams = t; this._showScreen = true; this._persona = Persona.all.ElementAt <DuckPersona>(Rando.Int(3)); }
public List <DuckStory> CalculateStory(List <Profile> p) { List <DuckStory> duckStoryList = new List <DuckStory>(); Script.activeNewsStory = this; if (p == null || p.Count > 0) { Script.activeProfile = p[0]; } foreach (ScriptStatement requirement in this._requirements) { if (requirement.result is bool result && !result) { return(duckStoryList); } } if (this._dialogue.Count > 0) { DuckStory duckStory = new DuckStory() { section = this._section, text = this._dialogue[Rando.Int(this._dialogue.Count - 1)] }; duckStory.text = this.FillString(duckStory.text, p); duckStoryList.Add(duckStory); } foreach (DuckNews subStorey in this._subStories) { if (subStorey._valueCalculation == null) { subStorey._valueCalculation = this._valueCalculation; } if (subStorey._valueCalculation2 == null) { subStorey._valueCalculation2 = this._valueCalculation2; } if (subStorey._section == NewsSection.None) { subStorey._section = this._section; } if (subStorey._cycle == CycleMode.None) { duckStoryList.AddRange((IEnumerable <DuckStory>)subStorey.CalculateStory(p)); } else { duckStoryList.AddRange((IEnumerable <DuckStory>)subStorey.CalculateStory()); } } return(duckStoryList); }
public ExtinguisherSmoke(float xpos, float ypos, bool network = false) : base(xpos, ypos) { this.center = new Vec2(8f, 8f); this.hSpeed = Rando.Float(-0.2f, 0.2f); this.vSpeed = Rando.Float(-0.2f, 0.2f); this._life += Rando.Float(0.2f); this.angleDegrees = Rando.Float(360f); this._gravMult = 0.8f; this._sticky = 0.2f; this._life = 3f; this._bounceEfficiency = 0.2f; this.xscale = this.yscale = Rando.Float(0.4f, 0.5f); this._smokeID = FireManager.GetFireID(); this._collisionSize = new Vec2(4f, 4f); this._collisionOffset = new Vec2(-2f, -2f); this.needsSynchronization = true; this._sprite = new SpriteMap("tinySmokeTestFront", 16, 16); int num1 = Rando.Int(3) * 4; this._sprite.AddAnimation("idle", 0.1f, true, num1); this._sprite.AddAnimation("puff", Rando.Float(0.15f, 0.25f), false, num1, 1 + num1, 2 + num1, 3 + num1); this._orbiter = new SpriteMap("tinySmokeTestFront", 16, 16); int num2 = Rando.Int(3) * 4; this._orbiter.AddAnimation("idle", 0.1f, true, num2); this._orbiter.AddAnimation("puff", Rando.Float(0.15f, 0.25f), false, num2, 1 + num2, 2 + num2, 3 + num2); this._sprite2 = new SpriteMap("tinySmokeTestBack", 16, 16); this.graphic = (Sprite)this._sprite; this.center = new Vec2(8f, 8f); if (Network.isActive && !network) { GhostManager.context.particleManager.AddLocalParticle((PhysicsParticle)this); } this.isLocal = !network; this._orbitInc += 0.2f; this._sprite.SetAnimation("idle"); this._sprite.angleDegrees = Rando.Float(360f); this._orbiter.angleDegrees = Rando.Float(360f); this.s1 = Rando.Float(0.8f, 1.1f); this.s2 = Rando.Float(0.8f, 1.1f); float num3 = 0.6f - Rando.Float(0.2f); float num4 = 1f; this._sprite.color = new Color(num4, num4, num4); this.depth = new Depth(0.8f); this.alpha = 1f; this.layer = Layer.Game; this.s1 = this.xscale; this.s2 = this.xscale; }
public Present(float xpos, float ypos) : base(xpos, ypos) { this._sprite = new SpriteMap("presents", 16, 16); this._sprite.frame = Rando.Int(0, 7); this.graphic = (Sprite)this._sprite; this.center = new Vec2(8f, 8f); this.collisionOffset = new Vec2(-7f, -4f); this.collisionSize = new Vec2(14f, 11f); this.depth = new Depth(-0.5f); this.thickness = 0.0f; this.weight = 3f; this.collideSounds.Add("presentLand"); }
public override PhysicsObject GetSpawnItem() { List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables); physicsObjects.RemoveAll((Predicate <System.Type>)(t => t == typeof(LavaBarrel) || t == typeof(Grapple))); this.contains = physicsObjects[NetRand.Int(physicsObjects.Count - 1)]; PhysicsObject thing = Editor.CreateThing(this.contains) as PhysicsObject; if (Rando.Int(1000) == 1 && thing is Gun && (thing as Gun).CanSpawnInfinite()) { (thing as Gun).infiniteAmmoVal = true; (thing as Gun).infinite.value = true; } return(thing); }
private SmallSmoke() : base() { this._sprite = new SpriteMap("tinySmokeTestFront", 16, 16); int num1 = Rando.Int(3) * 4; this._sprite.AddAnimation("idle", 0.1f, true, num1); this._sprite.AddAnimation("puff", Rando.Float(0.15f, 0.25f), false, num1, 1 + num1, 2 + num1, 3 + num1); this._orbiter = new SpriteMap("tinySmokeTestFront", 16, 16); int num2 = Rando.Int(3) * 4; this._orbiter.AddAnimation("idle", 0.1f, true, num2); this._orbiter.AddAnimation("puff", Rando.Float(0.15f, 0.25f), false, num2, 1 + num2, 2 + num2, 3 + num2); this._sprite2 = new SpriteMap("tinySmokeTestBack", 16, 16); this.graphic = (Sprite)this._sprite; this.center = new Vec2(8f, 8f); }
public override void OnPressAction() { if (this.owner == null) { return; } Thing owner = this.owner; Duck duck = this.duck; if (duck != null) { ++duck.profile.stats.presentsOpened; this.duck.ThrowItem(); } Level.Remove((Thing)this); Level.Add((Thing) new OpenPresent(this.x, this.y, this._sprite.frame)); for (int index = 0; index < 4; ++index) { Level.Add((Thing)SmallSmoke.New(this.x + Rando.Float(-2f, 2f), this.y + Rando.Float(-2f, 2f))); } SFX.Play("harp", 0.8f); if (this._contains == (System.Type)null) { this.Initialize(); } if (!(Editor.CreateThing(this._contains) is Holdable thing)) { return; } if (Rando.Int(500) == 1 && thing is Gun && (thing as Gun).CanSpawnInfinite()) { (thing as Gun).infiniteAmmoVal = true; (thing as Gun).infinite.value = true; } thing.x = owner.x; thing.y = owner.y; Level.Add((Thing)thing); if (duck == null) { return; } duck.GiveHoldable(thing); duck.resetAction = true; }
public static void Update() { int targetsPerFrame = DamageManager._targetsPerFrame; int index = 0; while (targetsPerFrame > 0 && DamageManager._hits.Count > 0 && index < DamageManager._hits.Count) { DamageHit hit = DamageManager._hits[index]; if (hit.thing.graphic.renderTexture == null) { hit.thing.graphic = hit.thing.GetEditorImage(0, 0, true, target: DamageManager.Get16x16Target()); ++index; --targetsPerFrame; } else { DamageManager._hits.RemoveAt(index); float num = (float)hit.thing.graphic.width / (float)hit.thing.graphic.width; Camera camera = new Camera(0.0f, 0.0f, (float)hit.thing.graphic.width, (float)hit.thing.graphic.height); camera.position = new Vec2(hit.thing.x - hit.thing.centerx * num, hit.thing.y - hit.thing.centery * num); DuckGame.Graphics.SetRenderTarget(hit.thing.graphic.renderTexture); DepthStencilState depthStencilState = new DepthStencilState() { StencilEnable = true, StencilFunction = CompareFunction.Equal, StencilPass = StencilOperation.Keep, ReferenceStencil = 1, DepthBufferEnable = false }; DuckGame.Graphics.screen.Begin(SpriteSortMode.BackToFront, DamageManager._blendState, SamplerState.PointClamp, depthStencilState, RasterizerState.CullNone, (MTEffect)null, camera.getMatrix()); foreach (Vec2 point in hit.points) { DamageManager._bulletHoles.depth = new Depth(1f); DamageManager._bulletHoles.x = point.x + Rando.Float(-1f, 1f); DamageManager._bulletHoles.y = point.y + Rando.Float(-1f, 1f); DamageManager._bulletHoles.imageIndex = Rando.Int(4); DamageManager._bulletHoles.Draw(); } DuckGame.Graphics.screen.End(); DuckGame.Graphics.device.SetRenderTarget((Microsoft.Xna.Framework.Graphics.RenderTarget2D)null); --targetsPerFrame; } } }
public GameLevel(string lev, int seedVal = 0, bool validityTest = false, bool editorTestMode = false) : base(lev) { this.levelInputString = lev; this._followCam = new FollowCam(); this._followCam.lerpMult = 1.2f; this.camera = (Camera)this._followCam; this._validityTest = validityTest; if (Network.isActive) { this._readyForTransition = false; } if (seedVal == 0) { seedVal = Rando.Int(2147483646); } this.seed = seedVal; this._editorTestMode = editorTestMode; }
private static SpawnPoint AttemptTeamSpawn( Team team, List <SpawnPoint> usedSpawns, List <Duck> spawned) { Level current = Level.current; List <TeamSpawn> teamSpawnList = new List <TeamSpawn>(); foreach (TeamSpawn teamSpawn in Level.current.things[typeof(TeamSpawn)]) { if (!usedSpawns.Contains((SpawnPoint)teamSpawn)) { teamSpawnList.Add(teamSpawn); } } if (teamSpawnList.Count <= 0) { return((SpawnPoint)null); } TeamSpawn teamSpawn1 = teamSpawnList[Rando.Int(teamSpawnList.Count - 1)]; usedSpawns.Add((SpawnPoint)teamSpawn1); for (int index = 0; index < team.numMembers; ++index) { Vec2 position = teamSpawn1.position; if (team.numMembers == 2) { float num = 18.82353f; position.x = (float)((double)teamSpawn1.position.x - 16.0 + (double)num * (double)index); } else if (team.numMembers == 3) { float num = 9.411764f; position.x = (float)((double)teamSpawn1.position.x - 16.0 + (double)num * (double)index); } Duck duck = new Duck(position.x, position.y - 7f, team.activeProfiles[index]); duck.offDir = teamSpawn1.offDir; spawned.Add(duck); } return((SpawnPoint)teamSpawn1); }
public override void Apply() { if (DuckGame.Graphics.device.Textures[0] != null) { Tex2D texture = (Tex2D)(DuckGame.Graphics.device.Textures[0] as Texture2D); this.SetValue("width", texture.frameWidth / (float)texture.width); this.SetValue("height", texture.frameHeight / (float)texture.height); this.SetValue("frameWidth", texture.frameWidth); this.SetValue("amount", this.amount); this.SetValue("yoff", this.yoffset); this.SetValue("xpos", this._thing.x); this.SetValue("ypos", this._thing.y); } DuckGame.Graphics.device.Textures[1] = (Texture)(Texture2D)this._goldTexture; DuckGame.Graphics.device.SamplerStates[1] = SamplerState.PointWrap; foreach (EffectPass pass in this._effect.effect.CurrentTechnique.Passes) { pass.Apply(); } if (this.lockframes > 0) { --this.lockframes; } else { if ((double)Rando.Float(1f) > 0.850000023841858) { this.lockframes = Rando.Int(2, 12); } if ((double)Rando.Float(1f) > 0.200000002980232) { this.amount = Lerp.Float(this.amount, 0.0f, 0.05f); } if ((double)Rando.Float(1f) <= 0.980000019073486) { return; } this.amount += 0.3f; } }
private static bool TryReroll( RandomLevelData combined, List <RandomLevelNode> available, Func <RandomLevelData, bool> problem, Func <RandomLevelData, bool> solution, RandomLevelNode specific = null) { if (available.Count == 0 && specific == null) { return(false); } if (problem(combined)) { List <RandomLevelNode> randomLevelNodeList = new List <RandomLevelNode>(); if (specific != null) { randomLevelNodeList.Add(specific); } else { randomLevelNodeList.AddRange((IEnumerable <RandomLevelNode>)available); } do { RandomLevelNode randomLevelNode = randomLevelNodeList[Rando.Int(randomLevelNodeList.Count - 1)]; if (randomLevelNode.Reroll(solution)) { available.Remove(randomLevelNode); goto label_10; } else { randomLevelNodeList.Remove(randomLevelNode); } }while (randomLevelNodeList.Count != 0); return(false); } label_10: return(true); }
public DeathCrate(float xpos, float ypos) : base(xpos, ypos) { this._maxHealth = 15f; this._hitPoints = 15f; this._sprite = new SpriteMap("deathcrate", 16, 19); this.graphic = (Sprite)this._sprite; this.center = new Vec2(8f, 11f); this.collisionOffset = new Vec2(-8f, -11f); this.collisionSize = new Vec2(16f, 18f); this.depth = new Depth(-0.5f); this._editorName = "Death Crate"; this.thickness = 2f; this.weight = 5f; this._sprite.AddAnimation("idle", 1f, true, new int[1]); this._sprite.AddAnimation("activate", 0.35f, false, 1, 2, 3, 4, 4, 5, 4, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 5, 7, 7, 7, 7, 7, 7, 7, 7, 5, 8, 8, 8, 8, 8, 8, 8, 8, 5, 9, 9, 5); this._sprite.SetAnimation("idle"); this._holdOffset = new Vec2(2f, 0.0f); this.flammable = 0.0f; this.collideSounds.Add("crateHit"); this.settingIndex = (byte)Rando.Int(DeathCrate._settings.Count - 1); }
public void Spawn() { if (this.randomSpawn) { List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables); this.contains = physicsObjects[Rando.Int(physicsObjects.Count - 1)]; } this._spawnWait = 0.0f; ++this._numSpawned; if (!(Editor.CreateThing(this.contains) is PhysicsObject thing)) { return; } Vec2 vec2 = Maths.AngleToVec(Maths.DegToRad(this.direction)) * this.firePower; thing.position = this.position + vec2.normalized * 8f; thing.hSpeed = vec2.x; thing.vSpeed = vec2.y; Level.Add((Thing)thing); Level.Add((Thing)SmallSmoke.New(thing.x, thing.y)); Level.Add((Thing)SmallSmoke.New(thing.x, thing.y)); SFX.Play("netGunFire", Rando.Float(0.9f, 1f), Rando.Float(-0.1f, 0.1f)); if (thing is Equipment) { (thing as Equipment).autoEquipTime = 0.5f; } if (thing is ChokeCollar) { (thing as ChokeCollar).ball.hSpeed = thing.hSpeed; (thing as ChokeCollar).ball.vSpeed = thing.vSpeed; } if (!(thing is Sword)) { return; } (thing as Sword)._wasLifted = true; (thing as Sword)._framesExisting = 16; }
private void PopUpItems() { bool flag1 = false; while (this._up.Count < this.max_up.value) { List <Thing> list = Level.current.things[typeof(ISequenceItem)].ToList <Thing>(); list.RemoveAll((Predicate <Thing>)(v => !v.sequence.isValid)); if (this._up.Count >= list.Count) { break; } int num1 = 0; List <SequenceItem> sequenceItemList = new List <SequenceItem>(); bool flag2 = false; while (list.Count > 0) { Thing thing = list[Rando.Int(0, list.Count - 1)]; list.Remove(thing); SequenceItem sequence = thing.sequence; if ((!sequence.activated || sequence.finished) && sequence.isValid) { flag2 = true; if (sequence != this._lastUp || flag1) { ++sequence.likelyhood; num1 += sequence.likelyhood; sequenceItemList.Add(sequence); } } } if (!flag2) { break; } if (num1 == 0) { num1 = 1; } float num2 = Rando.Float(1f); float num3 = 0.0f; if (sequenceItemList.Count == 0) { flag1 = true; } foreach (SequenceItem sequenceItem in sequenceItemList) { float num4 = (float)sequenceItem.likelyhood / (float)num1; if ((double)num2 > (double)num3 && (double)num2 < (double)num3 + (double)num4) { sequenceItem.randomMode = true; RandomController.isRand = true; sequenceItem.Activate(); RandomController.isRand = false; ++this._totalUp; this._up.Add(sequenceItem); break; } num3 += num4; } } }
public override void Update() { this._scroll += 0.1f; if ((double)this._scroll > 9.0) { this._scroll = 0.0f; } this._dots += 0.01f; if ((double)this._dots > 1.0) { this._dots = 0.0f; } if (this.open) { foreach (BlacklistServer failedAttempt in this._failedAttempts) { failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer()); } if (this._signalCrossLocal.currentAnimation == "idle") { if (UIMatchmakingBox.pulseLocal) { this._signalCrossLocal.SetAnimation("flicker"); UIMatchmakingBox.pulseLocal = false; } } else if (this._signalCrossLocal.finished) { this._signalCrossLocal.SetAnimation("idle"); } if (this._signalCrossNetwork.currentAnimation == "idle") { if (UIMatchmakingBox.pulseNetwork) { this._signalCrossNetwork.SetAnimation("flicker"); UIMatchmakingBox.pulseNetwork = false; } } else if (this._signalCrossNetwork.finished) { this._signalCrossNetwork.SetAnimation("idle"); } if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting) { this.ChangeState(MatchmakingState.Connecting); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White); } if (DuckNetwork.status == DuckNetStatus.Connected) { if (this._tryHostingLobby != null) { (Level.current as TeamSelect2).CloseAllDialogs(); Level.current = (Level) new TeamSelect2(); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White); return; } if (Level.current is TeamSelect2) { (Level.current as TeamSelect2).CloseAllDialogs(); Level.current = (Level) new ConnectingScreen(); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White); return; } Network.Disconnect(); this.ChangeState(MatchmakingState.SearchForLobbies); DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White); return; } switch (UIMatchmakingBox._state) { case MatchmakingState.ConnectToMoon: Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); Steam.RequestGlobalStats(); UIMatchmakingBox.pulseLocal = true; this.ChangeState(MatchmakingState.ConnectingToMoon); break; case MatchmakingState.ConnectingToMoon: if (Steam.lobbySearchComplete) { if (this.searchTryIndex == 0) { this._totalInGameLobbies = Steam.lobbiesFound; if (this._totalInGameLobbies < 0) { this._totalInGameLobbies = 0; } ++this.searchTryIndex; Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); break; } UIMatchmakingBox.pulseNetwork = true; this._totalLobbiesFound = Steam.lobbiesFound; List <User> users = Steam.GetSearchLobbyAtIndex(0).users; this._newStatusList.Add("|DGGREEN|Connected to Moon!"); this._newStatusList.Add(""); this._newStatusList.Add("|DGYELLOW|Searching for companions."); this.ChangeState(MatchmakingState.SearchForLobbies); break; } break; case MatchmakingState.SearchForLobbies: if (this._triesSinceSearch == 3) { Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal); Steam.SearchForLobby((User)null); this.ChangeState(MatchmakingState.CheckingTotalGames); return; } if (this._tries > 0 && this._tryHostingLobby == null) { DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public); this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby; if (!this.triedHostingAlready) { this._newStatusList.Add("|DGYELLOW|Searching even harder."); } else { this._newStatusList.Add("|DGYELLOW|Searching."); } this.triedHostingAlready = true; DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White); this._tryHostingWait = 5f + Rando.Float(2f); } foreach (MatchSetting matchSetting in TeamSelect2.matchSettings) { if (matchSetting.value is int) { if (matchSetting.filtered) { Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode); } else if (!matchSetting.filtered) { Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue); } } if (matchSetting.value is bool) { if (matchSetting.filtered) { Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode); } else if (!matchSetting.filtered) { Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0); } } } foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings) { if (onlineSetting.value is int) { if (onlineSetting.filtered) { Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode); } else if (!onlineSetting.filtered) { Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue); } } if (onlineSetting.value is bool) { if (onlineSetting.id == "modifiers") { if (onlineSetting.filtered) { Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal); } } else if (onlineSetting.filtered) { Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode); } else if (!onlineSetting.filtered) { Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0); } } } Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal); Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal); if (!Steam.waitingForGlobalStats) { this._globalKills = (long)Steam.GetDailyGlobalStat("kills"); } Steam.RequestGlobalStats(); UIMatchmakingBox.pulseLocal = true; this.ChangeState(MatchmakingState.Searching); ++this._triesSinceSearch; ++this._tries; break; case MatchmakingState.CheckingTotalGames: if (Steam.lobbySearchComplete) { this._totalInGameLobbies = Steam.lobbiesFound; if (this._totalInGameLobbies < 0) { this._totalInGameLobbies = 0; } this.ChangeState(MatchmakingState.SearchForLobbies); this._triesSinceSearch = 0; break; } break; case MatchmakingState.Searching: if (Steam.lobbySearchComplete) { this._totalLobbiesFound = Steam.lobbiesFound; if (this._tryHostingLobby != null) { --this._totalLobbiesFound; } List <Lobby> lobbyList = new List <Lobby>(); DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White); for (int index1 = 0; index1 < 2; ++index1) { int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound; for (int index2 = 0; index2 < num1; ++index2) { Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2); if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id) { if (index2 == Steam.lobbiesFound - 1) { this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0)); } if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0) { lobbyList.Add(lobby); DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White); } else if (this.IsBlacklisted(lobby.id)) { DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White); } else { if (this._tryHostingLobby != null) { int num2 = -1; try { string lobbyData = lobby.GetLobbyData("randomID"); if (lobbyData != "") { num2 = Convert.ToInt32(lobbyData); } } catch { } if (num2 == -1) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White); num2 = Rando.Int(2147483646); } if (num2 >= this._tryHostingLobby.randomID) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White); } else { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White); NCSteam.UpdateRandomID(this._tryHostingLobby); continue; } } this._tryConnectLobby = lobby; if (lobby.owner != null) { this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + "."); } else { this._newStatusList.Add("|LIME|Trying to join server."); } this.ChangeState(MatchmakingState.Disconnect); break; } } } } if (this._tryConnectLobby == null) { DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White); this.ChangeState(MatchmakingState.SearchForLobbies, 3f); break; } break; } break; case MatchmakingState.Waiting: this._stateWait -= Maths.IncFrameTimer(); if ((double)this._stateWait <= 0.0) { this._stateWait = 0.0f; this.OnStateChange(this._pendingState); break; } break; default: int state = (int)UIMatchmakingBox._state; break; } if (Input.Pressed("QUACK")) { this._quit = true; this.ChangeState(MatchmakingState.Disconnect); } } if (this._newStatusList.Count > 0) { this._newStatusWait -= 0.1f; if ((double)this._newStatusWait <= 0.0) { this._newStatusWait = 1f; while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0) { this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1); } this._statusList.Add(this._newStatusList[0]); if (this._statusList.Count > 7) { this._statusList.RemoveAt(0); } this._newStatusList.RemoveAt(0); } } base.Update(); }
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 ArcadeFrame GetFrame() { float challengeSkillIndex = Challenges.GetChallengeSkillIndex(); foreach (ArcadeFrame arcadeFrame in (IEnumerable <ArcadeFrame>) this._frames.OrderBy <ArcadeFrame, int>((Func <ArcadeFrame, int>)(x => x.saveData == null ? Rando.Int(100) : Rando.Int(100) + 200))) { if ((double)challengeSkillIndex >= (double)(float)arcadeFrame.respect && ChallengeData.CheckRequirement(Profiles.active[0], (string)arcadeFrame.requirement)) { return(arcadeFrame); } } return((ArcadeFrame)null); }
public static void AddRandomPerk(Profile p) { IEnumerable <PartyPerks> source = Enum.GetValues(typeof(PartyPerks)).Cast <PartyPerks>(); Party.AddPerk(p, source.ElementAt <PartyPerks>(Rando.Int(source.Count <PartyPerks>() - 1))); }