rpgminigame(改进中。。。)

本文档详细介绍了如何使用PathPoint和GameInstance类来构建一个角色扮演游戏的小游戏。通过阅读头文件和cpp实现,可以理解游戏实例的创建及路径点在游戏逻辑中的应用。
摘要由CSDN通过智能技术生成

PathPoint 头文件:

#pragma once
#include <unordered_map>
enum class EPathPointType:int
{
	HealthBottle = 0,
	StrenthGem,
	DenfenceGem,
	ExpBottle,
	Slime,
	BigSlime,
	GiantSlime,
	SlimeImp,
	SlimeDevil,
	EliterSlime,
	SlimeKing
};

struct SlimeProperty
{
	int Health;
	int Attack;
	int Defence;
	int Exp;
	SlimeProperty() {}
	SlimeProperty(int _Health, int _Attack, int _Defence, int _Exp);
};

struct PlayerState
{
	int Health;
	int Attack;
	int Denfence;
	int ownExp;
	int Position;
	PlayerState();
};

class PathPoint {
public:
	void Draw();
	virtual void StepOn(PlayerState&player) = 0;
	PathPoint(EPathPointType _Type);
protected:
	EPathPointType Type;
};

class MonsterPoint :public PathPoint {
public:
	MonsterPoint(EPathPointType _Type);
	virtual void StepOn(PlayerState&Player) override;
private:
	static std::unordered_map<int, SlimeProperty> SlimeProperties;
};

class TreasurePoint :public PathPoint {
public:
	TreasurePoint(EPathPointType _Type);
	virtual void StepOn(PlayerState&Player) override;
};

PathPoint cpp

#include "PathPoint.h"
#include<iostream>
SlimeProperty::SlimeProperty(int _Health, int _Attack, int _Defence, int _Exp):
Health(_Health),
Attack(_Attack),
Defence(_Defence),
Exp(_Exp)
{
}

PlayerState::PlayerState():
Health(200),
Attack(10),
Denfence(10),
ownExp(0),
Position(-1)
{
	
}

void PathPoint::Draw()
{
	switch (Type)
	{
	case EPathPointType::HealthBottle:
		std::cout << "\tHB";
		break;
	case EPathPointType::StrenthGem:
		std::cout << "\tSG";
		break;
	case EPathPointType::DenfenceGem:
		std::cout << "\tDG";
		break;
	case EPathPointType::ExpBottle:
		std::cout << "\tEB";
		break;
	case EPathPointType::Slime:
		std::cout << "\to.o";
		break;
	case EPathPointType::BigSlime:
		std::cout << "\tO.O";
		break;
	case EPathPointType::GiantSlime:
		std::cout << "\tUoU";
		break;
	case EPathPointType::SlimeImp:
		std::cout << "\tT.T";
		break;
	case EPathPointType::SlimeDevil:
		std::cout << "\tMoM";
		break;
	case EPathPointType::EliterSlime:
		std::cout << "\tQvQ";
		break;
	case EPathPointType::SlimeKing:
		std::cout << "\tioi";
		break;
	default:
		break;
	}
}

PathPoin
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值