static void Main(string[] args) { //===================================== Character Plyer = new Character(); Plyer.CreateCharacter("Ali"); Plyer.Rull = "Player"; Plyer.Line = 2; Plyer.MoveIcon = '#'; BattleA.characterList.Add(Plyer); Plyer = new Character(); for (int q = 0; q < 4; q++) { //Character Plyer = new Character(); Plyer.CreateCharacter("Rabite" + q); Plyer.Rull = "Opponent"; BattleA.characterList.Add(Plyer); Plyer.Line = 3; Plyer.MoveIcon = '?'; Plyer = new Character(); } BattleA.StartFight(); //============================================ #region SetConsoleWinow Console.WindowTop = 0; Console.WindowLeft = 0; Console.WindowHeight = 50; Console.WindowWidth = 100; #endregion person player = new person(); Console.Write("Skriv in spelare namn."); player.Name = Console.ReadLine(); //player.MoveIcon = "->*"; player.MoveIcon = "J"; player.setStrengthHealth(); player.Line = 2; person opponent = new person(); Console.Write("Skriv in spelare namn."); opponent.Name = Console.ReadLine(); //opponent.MoveIcon = "->>*"; opponent.MoveIcon = "H"; opponent.setStrengthHealth(); opponent.Line = 3; Personal personal = new Personal(); BattleLog battle = new BattleLog(); int usualPosition = 0; Console.Clear(); for (int k = 0; k < 5; k++) { Console.WriteLine(); } Console.WriteLine(" player Opponen "); Console.WriteLine(" [{0,5}] [{1,-5}]", player.Name, opponent.Name); Console.WriteLine("---------------------------------------------"); Console.WriteLine("[Dice Strength Health] [Dice Strength Health]"); Console.WriteLine("---------------------------------------------"); Console.WriteLine("{0,7}{0,9}{2,14}{3,9}", player.Strength, player.Health, opponent.Strength, opponent.Health); //Console.WriteLine("{0,-5} {1,-15} {2,-1}{3,-1}", player.Strength, player.Health, opponent.Strength, opponent.Health); //Console.WriteLine(" {0,-8} {3,-10}", player.Health, opponent.Health); //Console.WriteLine(" \t{0,-10}\t{1,-10}",player.Name,opponent.Name); //Console.WriteLine("PLAYER {0,-10}\t{1,-10}", player.Strength, opponent.Strength); //Console.WriteLine("OPPNENT {0,-10}\t{1,-10}", player.Health, opponent.Health); Console.WriteLine("----------------------------------------------"); usualPosition = Console.CursorTop; Console.SetCursorPosition(10, 2); Console.WriteLine("-"); Console.SetCursorPosition(10, 3); Console.WriteLine("-"); Console.SetCursorPosition(15, 2); Console.WriteLine("*"); Console.SetCursorPosition(15, 3); Console.WriteLine("*"); Console.SetCursorPosition(25, 2); Console.WriteLine("+"); Console.SetCursorPosition(25, 3); Console.WriteLine("+"); Console.SetCursorPosition(50, 2); Console.WriteLine(";"); Console.SetCursorPosition(50, 3); Console.WriteLine(":"); Console.SetCursorPosition(0, usualPosition); Console.WriteLine("roll Dice"); Console.ReadKey(); //for (int j = 0; j < 10; j++) int nyckel = 1; bool endFlag = false; while (endFlag == false) { player.release(); opponent.release(); player.RollDice(); opponent.RollDice(); Console.SetCursorPosition(0, usualPosition); Console.WriteLine("{0,2}\t\t{1,9}", player.Dice, opponent.Dice); player.moveAhead(player.Dice); player.changestrength(); if (player.LastPosition >= 50) { endFlag = true; Console.SetCursorPosition(0, usualPosition); Console.WriteLine("{0,2}{1,5}\t\t{2,9}", player.Dice, (player.LastPosition >= 26 ? 1 : 0), opponent.Dice); } else { opponent.moveAhead(opponent.Dice); opponent.changestrength(); if (opponent.LastPosition >= 50) { endFlag = true; Console.SetCursorPosition(0, usualPosition); Console.WriteLine("{0,2}\t\t{1,9}{2,5}", player.Dice, opponent.Dice, (opponent.LastPosition >= 26 ? 1 : 0)); } else { Console.SetCursorPosition(0, usualPosition + 1); usualPosition = Console.CursorTop; Console.WriteLine("roll Dice"); Console.ReadKey(); } } personal.playerDice = player.Dice; personal.playerStrength = player.Strength; personal.playerHealth = player.Health; personal.opponentDice = opponent.Dice; personal.opponentStrength = opponent.Strength; personal.opponentHealth = opponent.Health; battle.PersonLog.Add(nyckel, personal); nyckel++; } //foreach (var entry in battle) //{ // // do something with entry.Value or entry.Key //} Console.ReadKey(); }
static void Main(string[] args) { Console.Title = "ArenaFighter"; string key; Player player = new Player(); PlayerCharacter pc; Console.WriteLine("Please set a name for your character:"); key = Console.ReadLine(); pc = new PlayerCharacter { Name = key }; do { pc.RollAttributes(); pc.Health = new Dice().RollDice() + 2; Console.WriteLine("Figher name:" + pc.Name); Console.WriteLine("Stats: \n" + "Health:" + pc.Health + "\n" + "Strenght:" + pc.Strenght + "\n" + "Defense: " + pc.Defense + "\n" + "Initiative:" + pc.Initiative); pc.MaxHealth = pc.Health; ConsoleKey response; do { Console.Write("Use this character? (y/n)"); response = Console.ReadKey(false).Key; if (response != ConsoleKey.Enter) { Console.WriteLine(); } } while (response != ConsoleKey.Y && response != ConsoleKey.N); charSelectConfirmed = response == ConsoleKey.Y; } while (!charSelectConfirmed); Console.ReadLine(); Console.Clear(); DoIntro(); player.PlayerCharacter = pc; BattleLog battleLog = new BattleLog(); Battle battle = new Battle(player, battleLog); battle.Play(); if (battle.BattleEnded) { Console.WriteLine("A history of events:"); battleLog.ShowLog(); int totalScore = 0; totalScore += player.DefeatedOpponents; if (!player.PlayerCharacter.IsDefeated && player.DefeatedOpponents > 0) { totalScore += 50; } Console.WriteLine($"\nFinal score: {totalScore}"); Console.ReadLine(); } }