private void __AddCardsButton_Click(object sender, EventArgs e) { // Convert the set to a pool of skills: List <Skill> pool = new List <Skill>(); SkillBoosterSet set = SkillBoosterSet.Sets[__SelectedSet.SelectedIndex < 0 ? 0 : __SelectedSet.SelectedIndex]; foreach (int i in set.SetSkills) { pool.Add(SkillDatabase.Data[i]); } // Pool is now added to a grab bag: GrabBag bag = new GrabBag(pool); // Now I need to grab some number of skills and add 'em to the league! BoosterLeaguePool newBooster = new BoosterLeaguePool(); foreach (Skill skill in bag.PullXFromBag((int)__NumberOfBoostersToAdd.Value)) { League.AddSkill(skill); newBooster.AddSkill(skill); } // And redraw the league pool: __LeaguePoolDisplay.Redraw(); // Let's show the player what they got! NewBoostersForLeagueDialog.ShowAddedBoostersDialog(1, newBooster); }
private void buttonClose_Click(object sender, RoutedEventArgs e) { if (GrabBag.IsRunning) { GrabBag.Cancel(); } this.Close(); }
public bool MoveNext() { GrabBag <T> .KlassEnumerator klassEnumerator = this; int num = klassEnumerator.index + 1; int num1 = num; klassEnumerator.index = num; return(num1 < this.array._length); }
public GrabBag <T> .Enumerator GetEnumerator() { GrabBag <T> .Enumerator enumerator = new GrabBag <T> .Enumerator(); enumerator.array = this; enumerator.nonNull = true; enumerator.index = -1; return(enumerator); }
public void RemoveAt(int index) { GrabBag <T> grabBag = this; int num = grabBag._length - 1; int num1 = num; grabBag._length = num; this._array[index] = this._array[num1]; this._array[this._length] = default(T); }
public void Clear() { while (this._length > 0) { GrabBag <T> grabBag = this; int num = grabBag._length - 1; int num1 = num; grabBag._length = num; this._array[num1] = default(T); } }
public AvailablePlayerFeatures( AssetDatabase assetdb, Random random, IEnumerable <Faction> factions) { this._random = random; this._factions = new Dictionary <Faction, AvailableFactionFeatures>(); this.ReplaceFactions(factions); this.Factions = new ReadOnlyDictionary <Faction, AvailableFactionFeatures>((IDictionary <Faction, AvailableFactionFeatures>) this._factions); this.EmpireColors = new GrabBag <int>(random, Generators.Sequence(0, Player.DefaultPrimaryPlayerColors.Count, 1)); }
static List <CardData> DrawCards(List <CardData> library, int count) { GrabBag grabBag = new GrabBag(library.Count); List <CardData> draw = new List <CardData>(); for (int i = 0; i < count; i++) { draw.Add(library[grabBag.Grab()]); } return(draw); }
public MainWindow() { BaseDirectory = Configuration.Current.Directory; InitializeComponent(); InitializeDirectory(); GrabBag = new GrabBag(); this.DataContext = this; gridContent.DataContext = GrabBag; }
ShopItem GetRandomItem(GrabBag grabBag, bool isLast) // last item if in the big one has a 61.74% of being a character { int randNum = 0; if (grabBag.HasCharacters && !grabBag.HasSubSkills) { randNum = Random.Range(0, characterItems.Count); return(characterItems[randNum]); } if (grabBag.HasSubSkills && !grabBag.HasCharacters) { randNum = Random.Range(0, subSkillItems.Count); return(subSkillItems[randNum]); } if (grabBag.HasCharacters && grabBag.HasSubSkills) { if (!isLast) { randNum = Random.Range(1, 101); if (randNum > 20) // 80% chance of getting a subskill { randNum = Random.Range(0, subSkillItems.Count); return(subSkillItems[randNum]); } else // 20% chance of getting a character { randNum = Random.Range(0, characterItems.Count); return(characterItems[randNum]); } } else { float n = Random.Range(1f, 101f); if (n > 61.74f) // 80% chance of getting a subskill { randNum = Random.Range(0, subSkillItems.Count); return(subSkillItems[randNum]); } else // 20% chance of getting a character { randNum = Random.Range(0, characterItems.Count); return(characterItems[randNum]); } } } return(null); }
public GrabBag(GrabBag <T> copy) { if (copy == null || copy._length == 0) { this._length = 0; this._array = EmptyArray <T> .array; } else { this._length = copy._length; this._array = new T[this._length]; Array.Copy(copy._array, this._array, this._length); } }
public int Grow(int count) { int num = this._length; int num1 = this._length + count - (int)this._array.Length; if (num1 > 0) { Array.Resize <T>(ref this._array, num1 / 2 * 4 + 1 + this._length); } GrabBag <T> grabBag = this; grabBag._length = grabBag._length + count; return(num); }
IEnumerator System.Collections.IEnumerable.GetEnumerator() { IEnumerator klassEnumerator; if (this._length != 0) { klassEnumerator = new GrabBag <T> .KlassEnumerator(this); } else { klassEnumerator = EmptyArray <T> .emptyEnumerator; } return(klassEnumerator); }
public void AddRecoil(float duration, ref Angle2 angle2) { if (duration > 0f && (angle2.pitch != 0f || angle2.yaw != 0f)) { if (this.recoilImpulses == null) { this.recoilImpulses = new GrabBag <RecoilSimulation.Recoil>(4); Debug.Log("Created GrabBag<Recoil>", this); } if (this.recoilImpulses.Add(new RecoilSimulation.Recoil(ref angle2, duration)) == 0) { base.enabled = true; } } }
public void AddRecoil(float duration, ref Angle2 angle2) { if (duration > 0f && (angle2.pitch != 0f || angle2.yaw != 0f)) { if (this.recoilImpulses == null) { this.recoilImpulses = new GrabBag<RecoilSimulation.Recoil>(4); Debug.Log("Created GrabBag<Recoil>", this); } if (this.recoilImpulses.Add(new RecoilSimulation.Recoil(ref angle2, duration)) == 0) { base.enabled = true; } } }
public void OpenGrabBag(GrabBag g) { Debug.Log("<color=green> Now opening..." + g.Name + "</color>"); //we don't know how many items are in the grab bag so lets say 4 for (int i = 0; i < 4; i++) { bool isLast = false; if (i == 3) { isLast = true; } GrabRandomItem(g, isLast); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (GrabBag.IsRunning) { GrabBag.Unpause(); } else { GrabBag.ActiveDirectory = ActiveDirectory; GrabBag.Span = new TimeSpan(0, 0, Convert.ToInt16(timeSlider.Value)); Worker = new BackgroundWorker(); Worker.DoWork += ExecuteTest; Worker.RunWorkerAsync(); } }
public bool Remove(T item) { int num = Array.IndexOf <T>(this._array, item, 0, this._length); if (num == -1) { return(false); } GrabBag <T> grabBag = this; int num1 = grabBag._length - 1; int num2 = num1; grabBag._length = num1; this._array[num] = this._array[num2]; this._array[this._length] = default(T); return(true); }
public void GrabRandomItem(GrabBag g, bool isLast) { Debug.Log("Grabbing random item..."); ShopItem item = GetRandomItem(g, isLast); Debug.Log("Grabbed " + item.itemName); if (player.HasItem(item)) { Debug.Log("Rerolling..."); GrabRandomItem(g, isLast); // run the function again until we get an item we don't have } else { AddItemtoInventory(item); Debug.Log("Adding " + item.itemName + " to the player's inventory!"); } }
public bool MoveNext() { bool flag; if (!this.nonNull) { flag = false; } else { GrabBag <T> .Enumerator enumerator = this; int num = enumerator.index + 1; int num1 = num; enumerator.index = num; flag = num1 < this.array._length; } return(flag); }
protected void DoSpawn(Vector3 pos) { var effectBag = new GrabBag <Entities.Effect>(true); effectBag.AddItems(effects, effectWeights); steeringBag = new GrabBag <Entities.SteeringEffect>(true); steeringBag.AddItems(steerings, steeringWeights); var maxEnemyIndex = (int)(GameManager.Instance.depth / 100f); maxEnemyIndex = Mathf.Clamp(maxEnemyIndex, 0, enemies.Count - 1); var enemy = enemies[Mathf.Clamp(enemyBag.GetItem(), 0, maxEnemyIndex)]; var numSteerings = rand.RandomIntLessThan((int)steeringsPerDepth.Evaluate(GameManager.Instance.depth)); var numEffects = rand.RandomIntLessThan((int)effectsPerDepth.Evaluate(GameManager.Instance.depth)); var spawned = Instantiate(enemy); var enem = spawned.GetComponent <Entities.BasicEnemy>(); for (int i = 0; i < numSteerings; i++) { if (steeringBag.IsEmpty()) { break; } enem.AddSteering(steeringBag.GetItem()); } for (int i = 0; i < numEffects; i++) { if (effectBag.IsEmpty()) { break; } enem.AddEffect(effectBag.GetItem()); } spawned.transform.position = pos; spawned.transform.parent = holder.transform; }
public void SetEmpireColor(int slot, int?empireColorId) { int?nullable1; if (empireColorId.HasValue) { nullable1 = empireColorId; int num1 = -1; if (!(nullable1.GetValueOrDefault() == num1 & nullable1.HasValue)) { nullable1 = empireColorId; int?empireColor = this.Players[slot].EmpireColor; if (nullable1.GetValueOrDefault() == empireColor.GetValueOrDefault() & nullable1.HasValue == empireColor.HasValue) { this.AvailablePlayerFeatures.EmpireColors.Take(empireColorId.Value); return; } if (this.AvailablePlayerFeatures.EmpireColors.IsTaken(empireColorId.Value)) { return; } empireColor = this.Players[slot].EmpireColor; if (empireColor.HasValue) { GrabBag <int> empireColors = this.AvailablePlayerFeatures.EmpireColors; empireColor = this.Players[slot].EmpireColor; int num2 = empireColor.Value; empireColors.Replace(num2); } this.AvailablePlayerFeatures.EmpireColors.Take(empireColorId.Value); this.Players[slot].EmpireColor = new int?(empireColorId.Value); return; } } PlayerSetup player = this.Players[slot]; nullable1 = new int?(); int?nullable2 = nullable1; player.EmpireColor = nullable2; }
private void btnNext_Click(object sender, RoutedEventArgs e) { GrabBag.Next(); }
private void btnStop_Click(object sender, RoutedEventArgs e) { GrabBag.Cancel(); }
public void ExecuteTest(object sender, DoWorkEventArgs args) { GrabBag.Execute(); }
public AvailableFactionFeatures(Random random, Faction faction) { this.Avatars = new GrabBag <string>(random, ((IEnumerable <string>)faction.AvatarTexturePaths).Select <string, string>((Func <string, string>)(x => Path.GetFileNameWithoutExtension(x)))); this.Badges = new GrabBag <string>(random, ((IEnumerable <string>)faction.BadgeTexturePaths).Select <string, string>((Func <string, string>)(x => Path.GetFileNameWithoutExtension(x)))); }
private void btnPause_Click(object sender, RoutedEventArgs e) { GrabBag.Pause(); }
public void Dispose() { this.array = null; }
public KlassEnumerator(GrabBag <T> array) { this.array = array; this.index = -1; }
public void Dispose() { this = new GrabBag <T> .Enumerator(); }