我想做的就是,当玩家或怪物的HP达到0时,战斗就结束了。就目前的情况来看,即使数字变为负数,循环也继续运行。我无法弄清楚这是循环本身还是当播放器选择其类时尝试切换以实例化新播放器类对象的方式出现问题。创建播放器类的代码:using System;using static System.Console;namespace _350_final_project{ public class Story { public Player choosenClass; //player's choosen class Encounter newEncounter = new Encounter(); public Player ChooseClass(string choice) //to run and allow player to pick from 3 different classes by intantiate an instance depending on their answer { switch (choice.ToLower()) { case "warrior": choosenClass = new Player() { maxPlayerHealth = 150, currentPlayerHealth = 150, playerDamage = 35, playerDef = 120, playerStrength = 95, playerAgility = 30, playerExperience = 0 }; WriteLine("You have choosen the path of the Warrior. Live by the sword. Die by the sword! \n"); return choosenClass; case "theif": choosenClass = new Player() { maxPlayerHealth = 85, currentPlayerHealth = 85, playerDamage = 27, playerDef = 43, playerStrength = 20, playerAgility = 125, playerExperience = 0 }; WriteLine("You have choosen to lurk in the shadows as a theif \n"); return choosenClass; case "gunner": choosenClass = new Player() }; } }}
- 1 回答
- 0 关注
- 114 浏览
添加回答
举报
0/150
提交
取消