⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 npc.cpp

📁 一个文字游戏 非常间的的小游戏 。。。。。。。。。。。。。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include"NPC.h"
#include<iostream>
#include"head.h"
#include"CRole.h"
#include"Color.h"
extern color c;//调用已经声明的对象
extern mygame call;//调用已经声明的对象
extern CRole k;//调用已经声明的对象
using namespace std;



NPC::NPC()
{
	d=0;
	panduan=0;
}
NPC::~NPC()
{
}
void NPC::message()//安全行走提示
{
  c.anqingse();
  cout<<"【"<<"消息】:"<<"现在很安全,没有发现任何动静!";
  cout<<"按";
  c.huangse();
  cout<<" w a d";
  c.anqingse();
  cout<<"键继续行走";
}

void NPC::message2()//玩家昵称 ,【玩家】青色
{
         c.qingse();
	     cout<<"【";
		 cout<<k.player;
		 cout<<"】:"<<endl;
		  
}
void NPC::message3()//信息提示,【消息】红色
{
	 c.Hongse();
    cout<<"【";
	c.huangse();
     cout<<"消息";
	 c.Hongse();
	 cout<<"】:";
}

void NPC::npc1_penglai()//前往蓬莱的怪物分布
{
	 message3();
	 c.anbaise();
	 cout<<"前方发现 ";
	 c.Hongse();
	 cout<<"『巨鼠』";
	 c.anbaise();
	 cout<<" 正虎视耽耽的看着你,位置:";
	 cout<<" X:50  Y:40  数量:1  等级:1"<<"\n";
	 cout<<"选择攻击方式:"<<"\n";
C:	 c.huangse();
	 cout<<"1.取出『强化乌龙剑』近距离刺杀 2.利用『暗夜连环斩』直线冲杀(会消耗2点的力量)";
	 cout<<"\n";
	 cin>>in;
	 
	 switch(in[0])
	 {
	 case '1':
		message2();
		 c.anqingse();
         call.image("  暗笑,区区一只巨鼠竟敢挡我去路!,真是找死!",45);
		 cout<<"\n";
         message2();
		 call.image("  提剑冲向『巨鼠』,刹那间,眼看",32);
		 c.Hongse();
		 cout<<"『强化乌龙剑』";
         c.anqingse();
		 cout<<"就要索取『巨鼠』之性命,但『巨鼠』  动作敏捷,并能看清黑夜中的一切,轻松躲过";
		 c.qingse();cout<<"【";cout<<k.player;cout<<"】";c.anqingse();
		 cout<<"的攻击,并称机反咬一口~~!\n"; 
         message3();//受到攻击消息报告
		   
		  c.Hongse();
	   	  cout<<"  你的血值丢失3\n";
         k.setHP(k.getHP()-3);
		 k.gameover();
         k.shuxing();//输出属性回执单
		 message2();
		 c.anbaise();
		 cout<<"  此处非平常之地,连老鼠都那么狡猾!"<<endl;
         message3();
		 c.huangse();
		 cout<<"  在漆黑的洞内建议使用";
		 c.Hongse();
		 cout<<"『暗夜连环斩』"<<"\n";
		 c.anqingse();
		 cout<<"  选择再次攻击方式:"<<"\n";
	goto C;
         
		 break;
	 case '2':
          message2();
		 c.anlvse();
		 call.image("  开始运起内力,身边紫光环绕,瞬间一条光剑射向『巨鼠』,『巨鼠』当场毙命~!",72);
		 cout<<"\n";
		 message3();
		 c.anqingse();
         cout<<"  由于你的内力消耗,暂时损失了2点的力量,经验值增加1,级别升高1;"<<endl;
		 k.setEP(k.getEP()+1);//经验加1
		 k.setBI(k.getBI()-2);//力量减2
		 k.setLEVL(k.getLEVL()+1);//等级加1
         k.shuxing();//输出属性回执单
        
		    
            cout<<"\n";
            message3();
			cout<<"\n";
			c.anqingse();
		    cout<<"  巨鼠掉落一瓶生命药水,是否捡起放入物品栏?(y/n)"<<endl;
			cin>>in;
			switch(in[0])
			{
			case 'y':
				 message3();
				cout<<"  生命药水已经放入物品栏!"<<endl;
				call.wupin2=" 生命药水   ";
				call.wupin();

				break;
			case 'n':
				break;
			default:
				break;
			}
		cout<<"\n";
		 message();//安全信息
      break;

	  default:
		 c.Hongse();
		 cout<<"  输入错误!"<<"\n";
       goto C;
	 }
     cout<<"\n";
	 c.anbaise();
	 cout<<"  洞内甚是黑暗";
	 c.qingse();
	 cout<<k.player;
	 c.anbaise();
	 cout<<"只能放慢脚步,摸索前进..."<<endl;
	 
}
void NPC::chose_wupin()   //游戏中的物品选择
{        
	     int i = 1;
	        c.baise();
			
			call.wupin();////////////////////////////////////
        	
			while(i)
			{
                cin>>k.W;
				switch(k.W[0])
				{
				case '1':
                    message3();
					c.Hongse();
					cout<<"  『强化乌龙剑』不是消耗物品!"<<endl;
					c.anbaise();
					cout<<"   请选择其他物品."; 
					c.huangse();
					cout<<"按 6 键退出物品栏!"<<endl;
					break;
				case '2':
					if(call.wupin2=="             ")
					{
						c.huangse();
						cout<<"此栏目为空!"<<endl;
					    c.anbaise();
					    cout<<"   请选择其他物品.";
						c.huangse();
					    cout<<"按 6 键退出物品栏!"<<endl;
					}
					if(call.wupin2==" 生命药水   ")
					{
						message3();
						c.qingse();
						call.image("生命药水已经服用.",20);
						cout<<"\n";
						call.wupin2="             ";
						 message3();
						  if(k.getHP()<80)
					     	 {
								 cout<<"生命值增加";
								 c.qingse();
								 cout<<"20."<<endl;
								 k.setHP(k.getHP()+20);
							 }else
								{
                                 cout<<"生命值增加10"<<endl;
								 k.setHP(k.getHP()+10);
								 if(k.getHP()>100)
								 {
									 k.setHP(100);
								 }
								}
								call.wupin();
								k.shuxing();
								c.huangse();
					            cout<<"按";
								c.qingse();
								cout<<"1,2,3,4";
								c.huangse();
								cout<<"继续选择物品,按 6 键退出物品栏!"<<endl;
								
					}

					break;
				case '3':///////////////////////////////////////////////////////????????

		                

					    if(call.wupin3=="             ")
							{
								c.huangse();
								cout<<"  此栏目为空!"<<endl;
								c.anbaise();
								cout<<"   请选择其他物品.";
							    c.huangse();
					            cout<<"按 6 键退出物品栏!"<<endl;
							}
						if(call.wupin3=="    战盔      ");
							{
							   message3();
								c.qingse();
								call.image("  你选择的物品已经装备完毕.",27);
								cout<<"\n";
								call.wupin3 = "             ";
								 
								call.wupin();//物品 回执报告
                                c.huangse();
					            cout<<"  按 6 键退出物品栏!"<<endl;
								
							} 
				         break;
				case '4':

					if(call.wupin4=="             ")
					{
						 c.huangse();
						 cout<<"  此栏目为空!"<<endl;
						 c.anbaise();
						 cout<<"   请选择其他物品.";
						 c.huangse();
						 cout<<"按 6 键退出物品栏!"<<endl;             
					}
					if(call.wupin4=="   强酸花     ")
					{
                        message3();
			            c.qingse();
						call.image("  你选择的物品已成功使用!.",27);
                        cout<<"\n";
						message3();
						c.anlvse();
                        cout<<"使用";
						c.qingse();
						cout<<"『强酸花』";
						c.anlvse();
						cout<<"后力量增加 ";
						c.Hongse();
						cout<<"10  ";
						c.anlvse();
						cout<<"魔法增加 ";
						c.Hongse();
						cout<<"5"<<endl;
						cout<<"\n";
						call.wupin4 = "             ";
						k.setBI(k.getBI()+10);
						k.setID(k.getID()+5);
						call.wupin();//物品 回执报告
						k.shuxing();//属性报告
						c.huangse();
						cout<<"  按 6 键退出物品栏!"<<endl;
						panduan=1;

					}

					break;
				case '5':

					cout<<"此栏目为空"<<endl;
					break;
				case '6':
					c.anbaise();
                     cout<<"物品栏已关闭,请继续行走!(w/a/d)"<<endl;
					 i=0;//跳出循环
					break;
				default:
					cout<<"输入错误!请选择1-5,按 6 键退出物品栏:"<<endl;
					break;
				}
			}
}

void NPC::flower_penglai()//强酸花
{
	        if(k.gety()==34)
              {
					  message3();
					  c.anhuangse();
					  cout<<"前方发现";
					  c.qingse();
					  cout<<"『强酸花』";
					  c.anhuangse();
					  cout<<"能化解";
					  c.Hongse();
					  cout<<"「吸血虫」";
					  c.anhuangse();
					  cout<<"和";
					  c.Hongse();
					  cout<<"「毒蝎」";
					  c.anhuangse();
					  cout<<"的毒素!";
					  c.anhuangse();
					  cout<<"坐标:";
					  c.Hongse();
					  cout<<"X:55  Y:30 "<<endl;
				 /*
						  cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
						  cout<<"\n";*/
				}

			if(d==0){

                   if(k.getx()==50&&k.gety()==34)
					   {
						  cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
                          }
				   if(k.getx()==50&&k.gety()==32)
						  {
                              message3();
							  cout<<"按 w 键 再向前走几步!"<<endl;
						  }
				   if(k.getx()==50&&k.gety()==30)
						  {
                              message3();
							  cout<<"按 d 键 再向右走几步!"<<endl;
							    cout<<"\n";
						  }
 
			   if(k.getx()==55&&k.gety()==34)
						  {
                           message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
                          }
				if(k.getx()==55&&k.gety()==32)
						  {
                          message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"再向前走几步。 ";
						    cout<<"\n";
						  }
				     
                if(k.getx()==60&&k.gety()==34)
						 {
                           message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
                            }
				if(k.getx()==60&&k.gety()==32)
						  {
							  message3();
							  cout<<"按 w 键 再向前走几步!"<<endl;
							    cout<<"\n";
						  }

                if(k.getx()==60&&k.gety()==30)
						  {
							  message3();
							  cout<<"按 a 键 再向左走几步!"<<endl;
							    cout<<"\n";
						  }


				 if(k.getx()==45&&k.gety()==34)
				    {
                          message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
						  cout<<"\n";
				    }

				if(k.getx()==45&&k.gety()==32)
						  {
							  message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(再向前走几步。 ";
						    cout<<"\n";

						  }
				if(k.getx()==45&&k.gety()==30)
						  {
                           message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" d ";
						  c.anhuangse();
						  cout<<"向右走几步。 ";
						    cout<<"\n";
						  }
			   if(k.getx()==40&&k.gety()==34)
				 {
					      message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
						  cout<<"\n";
				 }
				 if(k.getx()==40&&k.gety()==32)
				 {
					     message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" w ";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向前走几步。 ";
						  cout<<"\n";
				 }
				 if(k.getx()==40&&k.gety()==30)
				 {
					     message3();
                          cout<<"  按";
						  c.anlvse();
						  cout<<" d";
						  c.anhuangse();
						  cout<<"(控制Y坐标) 向右走几步。 ";
						  cout<<"\n";
				       }
				if(k.gety()==30&&k.getx()<55)
					  {
						    message3();
							c.qingse();
							cout<<" 『强酸花』";
							c.lvse();
							cout<<"在你的右方向--> X:55  Y:30";
							cout<<" 按 d 键靠近..."<<endl;
							 
					  }
                     
					 if(k.getx()==55&&k.gety()==30)
					  {
						  if(panduan==0)
						  {
                         message3();
						 c.qingse();
						 cout<<" 『强酸花』";
						 c.Hongse();
						 cout<<"已经采集到~!"<<endl;
						 c.anlvse();
						 cout<<"  是否放入物品栏?";
						 c.huangse();
						 cout<<"(y / n) ";
						 c.anlvse();
						 cout<<" 按其他键则默认丢弃~!"<<endl;
						  //panduan=1;
						  
						 cin>>k.W;
						 if(k.W[0]=='y')
						 {
							 message3();
							 c.qingse();
							 cout<<" 『强酸花』";
							 c.lvse();
							 cout<<"已经放入物品栏!按w a d 继续行走";
							 cout<<"\n";
							 call.wupin4="   强酸花     ";
							 call.zhuangtai=1;
							 call.wupin();
						 }else
							 {  message3();
								 c.anqingse();
								 cout<<"『强酸花』已经仍掉~!"<<endl;
								 d=1;
							 }
						/* c.anbaise();
						 cout<<"游戏继续....";*/



                        if(k.getx()==60&&k.gety()==30)/////////////////////////
						 {
                           if(panduan=0)
						   {
                           message3();
						   cout<<"按 a 向左走几步!"<<endl;
						     cout<<"\n";
						       }
						 }
						

}
}
					
}
}

void NPC::last()//////寻找田不易
{
	          if(k.getx()<60&&k.gety()>=20)
			  {
                 message3();
				 c.anhuangse();
				  cout<<"方向走反了,应该按 d 键向东走。这个方向根本找不到 田不易!";
			  }
				 
               if(k.getx()==60&&k.gety()==24)
			   {
                 message3();
				 cout<<"按 w 向前走一段距离或按 d 向右拐。"<<endl;
			   }
			   if(k.getx()==60&&k.gety()==22)
			   {
                 message3();
				 cout<<" 按 w 向前走一段距离或按 d 向右拐。"<<endl;
			   }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -