|
|
|
 |
Console.WriteLine("2.상점");
Console.WriteLine("4. 종료");
Console.WriteLine("게임 종료");
Console.WriteLine("==========전투========== ");
Console.WriteLine();
Console.WriteLine("1. 공격");
Console.WriteLine("3.도망");
if(!monster.IsA ive())
|
|
|
 |
C#텍스트RPG 만들기
stringplayerName=Console.ReadLine();// 플레이어 이름을 입력
유저의 입력을 처리하는 상태 부분
Console.WriteLine("==========로비========== ");
Console.WriteLine("4. 종료");
Console.Write("커맨드를 입력하세요>>>>> ");
Console.WriteLine("상점미구현");
Console.WriteLine("상태 보기 미구현");
Console.WriteLine("게임 종료");
mbExit=true;//bExit=true를 대입한다.
Console.ReadKey();
Console.WriteLine(randval);// 랜덤값출력
if(!monster.IsA ive())
캐릭터 클래스
몬스터 클래스를 캐릭터 클래스에게 상속받습니다.
Character. cs
Monster. cs
Hit 메소드 오버라이드 추가
publicMonster(stringname, inthp, intattack, intdef, intdropGold, intexp) // 이름, 체력, 공격력, 방어력, [New 드랍되는 골드], [New 경험치]
protectedintmAttack;//공격력
mHP= hp;
if(mHP > 0)
Console.WriteLine(string. Form at("HP: {0}/{1}",mHP.ToString(), mMax Hp. ToString())) ;//HP: 체력/최대 체력
if(mHP<=0) {retu rn;}
Console.WriteLine(string. Form at("{0}(이)가{ 1}에게 {2}의 피해를 줬다.", mName, target.mName, mAttack.ToString()));
param name= "dam age "> 인가된 피해량이며, 항상 양수여야 합니다.
retu rns> 해당 피격후, 캐릭터가 사망했을 때 true를 반환합니다.
intrealDam age=damage-mDefense;
mHP-=realDam age;
Console.WriteLine(string. Form at("{0}(은)는 {1}의 피해를 입었다.", mName, realDam age. ToString())); |
 |
console, writeline, hp, 력, 이름, 체력, tostring, mname, monster, 플레이어, 입력, form, at, string, if, true, 캐릭터, 공격, 방어, mplayer |
|
|
|
|
|
 |
|
|
|
|
|
|
|
|
|
|
|
|