public Trap BuildTrap(int x, int y, Random random) { Tile tile = GetTile(x, y); var generator = PossibleTraps.GetWeighted(random); return(generator(this, x, y)); }
public Template Pick(Random random) { WeightedList <Template> templates = new WeightedList <Template>(); foreach (var template in Template.Puzzles[Tag]) { templates.Add(template, template.Weight); } return(templates.GetWeighted(random)); }
public override void Create(float x, float y) { Box = World.Create(x, y, 12, 14); Box.AddTags(CollisionTag.Character); Box.Data = this; foreach (var weapon in Weapon.PresetWeaponList) { Inventory.Add(weapon); } WeightedList <Func <Potion> > potions = new WeightedList <Func <Potion> >() { { () => new PotionHealth(), 10 }, { () => new PotionAntidote(), 10 }, { () => new PotionPoison(), 10 }, { () => new PotionIdentify(), 10 }, { () => new PotionEnergy(), 10 }, { () => new PotionWater(), 10 }, { () => new PotionHolyWater(), 10 }, { () => new PotionBlood(), 10 }, }; for (int i = 0; i < 20; i++) { Inventory.Add(potions.GetWeighted(Random)()); } WeightedList <Func <Device> > machines = new WeightedList <Func <Device> >() { //{ () => new DeviceBrew(true), 10 }, //{ () => new DeviceTrash(true), 10 }, //{ () => new DeviceDuplicate(true), 10 }, { () => new DeviceBrew(false), 10 }, { () => new DeviceTrash(false), 10 }, { () => new DeviceDuplicate(false), 10 }, { () => new DeviceFlamebringer(false), 100 } }; for (int i = 0; i < 5; i++) { Inventory.Add(machines.GetWeighted(Random)()); } }
public void PrintBackground(int id, Map map, int x, int y, Random random) { WeightedList <TileBG> RandomBricks = new WeightedList <TileBG>(); RandomBricks.Add(TileBG.Brick, 80); RandomBricks.Add(TileBG.BrickMiss1, 30); RandomBricks.Add(TileBG.BrickMiss2, 15); switch (id) { default: map.Background[x, y] = TileBG.Empty; break; case (0): map.Background[x, y] = TileBG.Brick; break; case (1): map.Background[x, y] = TileBG.Tile4; break; case (2): map.Background[x, y] = TileBG.TileDetail; break; case (3): map.Background[x, y] = TileBG.Statue; break; case (4): map.Background[x, y] = TileBG.BrickMiss1; break; case (5): map.Background[x, y] = TileBG.BrickMiss2; break; case (6): map.Background[x, y] = TileBG.BrickOpening; break; case (7): map.Background[x, y] = RandomBricks.GetWeighted(random); break; case (8): map.Background[x, y] = TileBG.RailLeft; break; case (9): map.Background[x, y] = TileBG.RailMiddle; break; case (10): map.Background[x, y] = TileBG.RailRight; break; case (11): map.Background[x, y] = TileBG.PillarTop; break; case (12): map.Background[x, y] = TileBG.BrickPlatform; break; case (13): map.Background[x, y] = TileBG.Black; break; case (14): map.Background[x, y] = TileBG.BrickHole; break; case (16): map.Background[x, y] = TileBG.Window; break; case (17): map.Background[x, y] = TileBG.WindowBigLeft; break; case (18): map.Background[x, y] = TileBG.WindowBigRight; break; case (19): map.Background[x, y] = TileBG.PillarDetail; break; case (27): map.Background[x, y] = TileBG.Pillar; break; case (35): map.Background[x, y] = TileBG.PillarBottomBroken; break; case (63): //Keep as is break; } }