Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var stats = new Stat[] {
- new Stat ()
- {
- Name = "Str",
- Value = 10,
- IsPrimaryStat = true
- },
- new Stat ()
- {
- Name = "Dex",
- Value = 10,
- },
- new Stat ()
- {
- Name = "Int",
- Value = 5
- },
- new Stat ()
- {
- Name = "Hp",
- Value = 20
- }
- };
- var inventory = new List<IWeapon>
- {
- new Dagger(5, 100) { Name = "Bronze Dagger" },
- new Staff(5, 100) { Name = "Wooden Stick" },
- new Dagger(15, 500) { Name = "Iron Dagger" }
- };
- var sortedInventory = inventory.OrderBy(x => x.SortOrder).ToList();
- var player = new Player()
- {
- Name = "Cool Name",
- Stats = stats,
- Inventory = sortedInventory,
- Weapon = sortedInventory.First()
- };
- var goblin1 = new Enemy()
- {
- Name = "Goblin 1",
- Stats = stats,
- Inventory = sortedInventory, //items that can be dropped
- Weapon = sortedInventory.Last()
- };
- var goblin2 = new Enemy()
- {
- Name = "Goblin 2",
- Stats = stats,
- Inventory = sortedInventory, //items that can be dropped
- Weapon = sortedInventory.Last()
- };
- // play game
- var players = new List<IPlayer>() { player, goblin1, goblin2 };
- var fightingOrder = players.OrderBy(x => x.Speed).ToList();
- while (fightingOrder.Any(x => x is IPlayer && x.HP > 0)
- && fightingOrder.Any(x => x is IEnemy && x.HP > 0))
- {
- foreach (var fighter in fightingOrder)
- {
- IPlayer opponent = null;
- var test = fightingOrder.FirstOrDefault(x => x.GetType() != fighter.GetType());
- if (fighter is IPlayer)
- {
- //let player select enemy, skill,
- opponent = fightingOrder.FirstOrDefault(x => x is IEnemy);
- }
- if (fighter is IEnemy)
- {
- opponent = fightingOrder.FirstOrDefault(x => x is IPlayer);
- }
- fighter.Attack(opponent);
- }
- fightingOrder = fightingOrder.Where(x => x.HP > 0).ToList();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement