本文整理汇总了C++中Tower::get_type方法的典型用法代码示例。如果您正苦于以下问题:C++ Tower::get_type方法的具体用法?C++ Tower::get_type怎么用?C++ Tower::get_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tower
的用法示例。
在下文中一共展示了Tower::get_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: left_mousebutton
void Game::left_mousebutton(int m_x, int m_y)
{
if (m_x <= GRIDWIDTH && m_y <= GRIDHEIGHT)
{ //Mouse within Grid
Tile* tile = grid->get_tile_from_mouse(m_x, m_y);
if (optionbox_visible())
{
bool done = false;
iter_op_box = optionbox.begin();
// if mouse is inside OptionBox
if ((*iter_op_box)->overlaps(m_x, m_y))
{
if (tile_selection != NULL)
tile = tile_selection;
for (iter_op_box = optionbox.begin()++; iter_op_box != optionbox.end(); iter_op_box++)
{
if ((*iter_op_box)->overlaps(m_x, m_y))
{
if (tile != NULL)
done = optbox_do_selection((*iter_op_box), tile->get_position());
}
if (done)
break;
}
}
else //if mouse is outside the box
{
if (tile != NULL && tile->get_tower() == NULL)
{
cancel_selection();
hide_option_box();
}
else
{
//Select Tower on this position
cancel_selection();
option_box_visible = false;
select(tile);
}
/*****/
}
} //(ShowOptionBox)
else //if (!ShowOptionBox)
{
if (buildmenu_selection != NULL && tile->get_tower() == NULL )
{
//Create new tower
create_new_tower(buildmenu_selection->get_type(), tile->get_position());
}
else if (buildmenu_selection == NULL)
{
select(tile);
}
else // tower is occupying this tile, cannot build there
{
SFX_cant_build->play();
}
}
} //Mouse on grid
else //Mouse on menu
{
if (optionbox_visible())
hide_option_box();
//Stuff on menu
for (iter_ingame_button = ingame_buttons.begin(); iter_ingame_button != ingame_buttons.end(); iter_ingame_button++)
{
if ((m_x > (*iter_ingame_button)->get_x()) && (m_x < (*iter_ingame_button)->get_x() + (*iter_ingame_button)->get_width()) && (m_y
> (*iter_ingame_button)->get_y()) && (m_y < (*iter_ingame_button)->get_y() + (*iter_ingame_button)->get_height()))
{
if ((*iter_ingame_button)->get_type() == BUTTON_TOGGLEGRID)
{
((*iter_ingame_button))->update();
grid_visible = !grid_visible;
}
if ((*iter_ingame_button)->get_type() == BUTTON_MENU) {
old_game_state = game_state;
game_state = INGAMEMENU;
}
if (tile_selection != NULL &&
((*iter_ingame_button)->get_type() > BUTTONS) &&
buildmenu_selection == NULL
&& !optionbox_visible())
{
switch ((*iter_ingame_button)->get_type())
{
case BUTTON_UPGR:
{
Tower* t = tile_selection->get_tower();
if (t != NULL)
//.........这里部分代码省略.........
示例2: optbox_do_selection
bool Game::optbox_do_selection(int type, GridPosition position)
{
/**
* Selects an option on the optionbox
*/
switch (type)
{
case BUTTON_BASE:
{
if (grid->get_tile(position)->get_tower() == NULL)
{
create_new_tower(towers::SIMPLE, position);
return true;
}
break;
}
case BUTTON_BOOST:
{
if (grid->get_tile(position)->get_tower() == NULL)
{
create_new_tower(towers::BOOST, position);
return true;
}
break;
}
case BUTTON_BASIC:
{
upgrade_tower(towers::BASIC);
return true;
}
case BUTTON_BOMB:
{
upgrade_tower(towers::BOMB);
return true;
}
case BUTTON_RANGE:
{
upgrade_tower(towers::RANGE);
return true;
}
case BUTTON_SELL:
{
sell(tile_selection);
return true;
}
case BUTTON_SPEED:
{
upgrade_tower(towers::SPEED);
return true;
}
case BUTTON_UPGRADE:
{
Tower* t = grid->get_tile(position)->get_tower();
if (t != NULL) {
upgrade_tower(t->get_type());
return true;
} else {
return false;
}
break;
}
case BUTTON_WALL:
{
create_new_tower(towers::WALL, position);
return true;
}
default:
break;
} //Switch
return false;
}