代码拉取完成,页面将自动刷新
#include "hub.h"
#include "config.h"
Hub::Hub()
{
need = LevelNeed::NEED_CYCLE;
need_shape_name = CYCLE;
current_have = 0;
money = 0;
increase_item_value = false;
upgradehub = false;
}
bool Hub::getUpgradehub() const
{
return upgradehub;
}
void Hub::setUpgradehub(bool newUpgradehub)
{
upgradehub = newUpgradehub;
}
bool Hub::getIncrease_item_value() const
{
return increase_item_value;
}
void Hub::setIncrease_item_value(bool newIncrease_item_value)
{
increase_item_value = newIncrease_item_value;
}
int Hub::getMoney() const
{
return money;
}
int Hub::getCurrent_have() const
{
return current_have;
}
void Hub::setCurrent_have(int newCurrent_have)
{
current_have = newCurrent_have;
}
int Hub::getNeed_shape_name() const
{
return need_shape_name;
}
void Hub::setNeed_shape_name(int newNeed_shape_name)
{
need_shape_name = newNeed_shape_name;
}
int Hub::getNeed() const
{
return need;
}
void Hub::setNeed(int newNeed)
{
need = newNeed;
}
void Hub::consume(int value)
{
money -= value;
}
void Hub::setMoney(int newMoney)
{
money = newMoney;
}
std::vector<GridVec> Hub::BuildingAllPos()
{
GridVec temp;
std::vector<GridVec> allpos;
if (upgradehub)
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
temp.i = pos.i + i;
temp.j = pos.j + j;
allpos.push_back(temp);
}
}
}
else
{
allpos.push_back(pos);
allpos.push_back(GridVec{pos.j, pos.i + 1});
allpos.push_back(GridVec{pos.j + 1, pos.i + 1});
allpos.push_back(GridVec{pos.j + 1, pos.i});
}
return allpos;
}
bool Hub::CanReceive(GridVec source, int directionin, int shapename)
{
return true;
}
bool Hub::IsPlace(const GridVec &click, int picdirection, GameMap &gamemap)
{
return true;
}
void Hub::Receive(GridVec source, int directionin, int shapename)
{
switch (shapename)
{
case CYCLE:
money += increase_item_value ? CYCLE_MONEY_2 : CYCLE_MONEY_1;
break;
case Goods::RECT:
money += increase_item_value ? RECT_MONEY_2 : RECT_MONEY_1;
break;
case Goods::LEFT_CYCLE:
money += increase_item_value ? LEFT_CYCLE_MONEY_2 : LEFT_CYCLE_MONEY_1;
break;
case Goods::RIGHT_CYCLE:
money += increase_item_value ? RIGHT_CYCLE_MONEY_2 : RIGHT_CYCLE_MONEY_1;
break;
default:
break;
}
if (shapename == need_shape_name)
{
current_have++;
}
return;
}
void Hub::UpdateTickableState(GameMap &gamemap)
{
return;
}
void Hub::TickableRunning()
{
return;
}
void Hub::UpdateNeed()
{
switch (need_shape_name)
{
case Goods::RECT:
need_shape_name = Goods::LEFT_CYCLE;
current_have = 0;
need = LevelNeed::NEED_LEFT_CYCLE;
break;
case CYCLE:
need_shape_name = Goods::RECT;
current_have = 0;
need = LevelNeed::NEED_RECT;
break;
case Goods::LEFT_CYCLE:
need_shape_name = Goods::RIGHT_CYCLE;
current_have = 0;
need = LevelNeed::NEED_RIGHT_CYCLE;
break;
default:
break;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。