本文整理汇总了C++中Tower::get_cost方法的典型用法代码示例。如果您正苦于以下问题:C++ Tower::get_cost方法的具体用法?C++ Tower::get_cost怎么用?C++ Tower::get_cost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tower
的用法示例。
在下文中一共展示了Tower::get_cost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_mode_run
void Game::build_mode_run() {
draw_all_views();
if( keyboard.isKeyPressed() ) {
coord xy = gs->cursor->get_coord(); //get current location of cursor
coord oldxy = xy;
switch( keyboard.getKeyPressed() ) {
case 'K': //left arrow
if( xy.x > 0 ) {
xy.x = xy.x - 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case 'M': //right arrow
if( xy.x < 14 ) {
xy.x = xy.x + 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case 'H': //up arrow
if( xy.y > 0 ) {
xy.y = xy.y - 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case 'P': //down arrow
if( xy.y < 14 ) {
xy.y = xy.y + 1;
update_cursor( xy, oldxy );
m_change = true;
}
break;
case (int)13:
Tower *t = new Laser(); //TODO: menu to choose a tower
if (gs->player->get_money() >= t->get_cost() && gs->map->check_can_build(const_cast<coord &>(gs->cursor->get_coord()))) { //check if player has enough money, and if the tile can be built on top of(if it's empty and if just a "plain" tile, ie. not path or base)
coord tower_xy = gs->cursor->get_coord();
gs->player->set_money(gs->player->get_money() - t->get_cost()); //update player money
tower_xy.layer = 1; //makes sure that tower is displayed on proper layer
t->set_coord(tower_xy);
gs->map->update(t); //update with tower
}
else
delete t;
gs->map->clear_cursor(gs->cursor->get_coord()); //clear cursor at current location
switch_to_edit();
m_change = true;
}
}
}