worldmodel.cpp
来自「巫魔问题求解」· C++ 代码 · 共 138 行
CPP
138 行
#include "WorldModel.h"
#include "GameEngine.h"
#include "ServerMap.h"
using namespace _server;
///////////////////////////////////////////////////
WorldModel::WorldModel(unsigned int x_border, unsigned int y_border, GameEngine &ge)
{
this->mpServerMap = new ServerMap(x_border, y_border);
this->mpGameEngine = ≥
this->mpExplorer = new Explorer(*this);
this->mIsBump = false;
this->mIsHawl = false;
this->mIsNewlyCreated = true;
}
///////////////////////////////////////////////////
WorldModel::WorldModel(char *filename, GameEngine &ge)
{
this->mpServerMap = new ServerMap(filename);
this->mpGameEngine = ≥
this->mpExplorer = new Explorer(*this);
this->mIsBump = false;
this->mIsHawl = false;
this->mIsNewlyCreated = true;
}
///////////////////////////////////////////////////
WorldModel::WorldModel(const _server::WorldModel &from)
{
}
///////////////////////////////////////////////////
WorldModel::~WorldModel(void)
{
delete this->mpExplorer;
delete this->mpServerMap;
}
///////////////////////////////////////////////////
void WorldModel::Update(void)
{
if (this->mpServerMap->TheCell(this->mpExplorer->GetX(), this->mpExplorer->GetY()).GetType() == _base::Cell::CT_None)
{
this->mpServerMap->TheCell(this->mpExplorer->GetX(), this->mpExplorer->GetY())._su_AddType(_base::Cell::CT_HasCame);
}
this->TheGameEngine().Update();
}
///////////////////////////////////////////////////
void WorldModel::Reset(void)
{
this->mpServerMap->Reset();
this->mpExplorer->Reset();
this->mIsNewlyCreated = true;
}
///////////////////////////////////////////////////
void WorldModel::Reset(char *filename)
{
this->mpServerMap->Reset(filename);
this->mpExplorer->Reset();
this->mIsNewlyCreated = true;
}
///////////////////////////////////////////////////
bool WorldModel::IsBump(void) const
{
return mIsBump;
}
///////////////////////////////////////////////////
bool & WorldModel::_su_IsBump(void)
{
return mIsBump;
}
///////////////////////////////////////////////////
bool WorldModel::IsHawl(void) const
{
return mIsHawl;
}
///////////////////////////////////////////////////
bool & WorldModel::_su_IsHawl(void)
{
return mIsHawl;
}
///////////////////////////////////////////////////
bool WorldModel::IsNewlyCreated(void) const
{
return mIsNewlyCreated;
}
///////////////////////////////////////////////////
bool & WorldModel::_su_IsNewlyCreated(void)
{
return mIsNewlyCreated;
}
///////////////////////////////////////////////////
ServerMap & WorldModel::TheServerMap(void)
{
return *mpServerMap;
}
///////////////////////////////////////////////////
Explorer & WorldModel::TheExplorer(void)
{
return *mpExplorer;
}
///////////////////////////////////////////////////
GameEngine & WorldModel::TheGameEngine(void)
{
return *mpGameEngine;
}
///////////////////////////////////////////////////
const ServerMap & WorldModel::GetServerMap(void) const
{
return *mpServerMap;
}
///////////////////////////////////////////////////
const Explorer & WorldModel::GetExplorer(void) const
{
return *mpExplorer;
}
///////////////////////////////////////////////////
const GameEngine & WorldModel::GetGameEngine(void) const
{
return *mpGameEngine;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?