gameengine.cpp

来自「巫魔问题求解」· C++ 代码 · 共 96 行

CPP
96
字号
#include "GameEngine.h"
#include "WorldModel.h"
#include "Explorer.h"
#include "ServerMap.h"

using namespace _server;

///////////////////////////////////////
GameEngine::GameEngine(void)
{
    this->mScore = 0;
    this->mpWorldModel = 0;
}

///////////////////////////////////////
GameEngine::GameEngine(const _server::GameEngine &from)
{
}

///////////////////////////////////////
GameEngine::~GameEngine(void)
{
}

///////////////////////////////////////
void GameEngine::Reset(unsigned int x_border, unsigned int y_border)
{
    if (this->mpWorldModel)
    {
        this->mpWorldModel->Reset();
    }
    else 
    {
        this->mpWorldModel = new WorldModel(4,4,*this);
    }
}

///////////////////////////////////////
void GameEngine::Reset(char *filename)
{
    if (this->mpWorldModel)
    {
        this->mpWorldModel->Reset(filename);
    }
    else 
    {
        this->mpWorldModel = new WorldModel(filename, *this);
    }
}

///////////////////////////////////////
WorldModel &GameEngine::TheWorldModel(void)
{
    return *mpWorldModel;
}

///////////////////////////////////////
const WorldModel &GameEngine::GetWorldModel(void) const
{
    return *mpWorldModel;
}

///////////////////////////////////////
void GameEngine::ReDraw(void)
{
}

///////////////////////////////////////
void GameEngine::Update(void)
{
    //Solve all events here, except shooting and escaping
    if (this->TheWorldModel().TheServerMap().GetCell(this->TheWorldModel().TheExplorer().GetX(), this->TheWorldModel().TheExplorer().GetY()).GetType() & (_base::Cell::CT_Wumpus | _base::Cell::CT_Trap))
    {
        this->_su_TheScore() -= 1000;
        this->Reset(4,4);
    }
    if (this->TheWorldModel().TheServerMap().GetCell(this->TheWorldModel().TheExplorer().GetX(), this->TheWorldModel().TheExplorer().GetY()).GetType() & _base::Cell::CT_Gold)
    {
        this->_su_TheScore() += 500;
        this->Reset(4,4);
    }

}

///////////////////////////////////////
const int GameEngine::GetScore(void) const
{
    return this->mScore;
}

///////////////////////////////////////
int &GameEngine::_su_TheScore(void)
{
    return this->mScore;
}

⌨️ 快捷键说明

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