1 Star 0 Fork 0

Mrack/ MyShapez

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
hub.cpp 3.29 KB
一键复制 编辑 原始数据 按行查看 历史
Mrack 提交于 2024-06-25 00:28 . asd
#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;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/stucky/MyShapez-new.git
[email protected]:stucky/MyShapez-new.git
stucky
MyShapez-new
MyShapez
master

搜索帮助