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