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

📄 mytool.h

📁 gamecode 很不错的小游戏源代码
💻 H
字号:
//************************************************************
//游戏物品基类
//作者:曾铮
//时间:2004年6月
//说明:提供物品类的接口。其它物品类从此类继承。
//      在角色类中建立此类的指针链表,实现中用虚函数实现不同物品的使用
//**************************************************************
#ifndef MyTool_h_
#define MyTool_h_
#include "MyMenus.h"

#define COMPMANAGER	0
#define	PASSPORT	1
#define	REMODICE	2
#define	STOPCARD	3
#define SUPERCAR	4
#define TORTCARD	5
#define BUYCARD		6
class MyTool
{
public:
	long price;//价格
	int kind;//类型标识
	int owner;//所属玩家
public:
	MyTool();
	void Setprice(int kind);//根据kind来设置price
	bool BeBought(const int& money,const int& toolowner);
	long GetPrice();
	virtual bool ToUse();
	virtual ~MyTool();
};

MyTool::MyTool()
{
	this->kind=FACTORY;
	this->Setprice(this->kind);
}

MyTool::~MyTool()
{
}
void MyTool::Setprice(int kind)
{
	switch (kind)
	{
	case STOPCARD:
		this->price=30;
		break;
	case SUPERCAR:
		this->price=100;
		break;
	case TORTCARD:
		this->price=35;
		break;
	case REMODICE:
		this->price=150;
		break;
	case PASSPORT:
		this->price=20;
		break;
	case COMPMANAGER:
		this->price=150;
		break;
	case BUYCARD:
		this->price=100;
		break;
	default:
		this->price=50;
		break;
	}
	return;
}

bool MyTool::BeBought(const int& money,const int& toolowner)
{
	if(money>=this->price)
	{
		this->owner=toolowner;
		return true;
	}
	else
		return false;
}
long MyTool::GetPrice()
{
	return this->price;
}

bool MyTool::ToUse()
{
	MyMenus usemenu(300,260,"pics/menu.fim",280,120,GetRect(0,0,280,120));
	char* choice[]={"使用","取消"};
	int select;
	select=usemenu.ShowtMenu("是否使用物品?",choice,2);
	return false;
}
#endif

⌨️ 快捷键说明

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