本文整理汇总了C++中Tile::GetTileType方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::GetTileType方法的具体用法?C++ Tile::GetTileType怎么用?C++ Tile::GetTileType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::GetTileType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveMap
/*
returns true or false if it saved----->do something with result to show user
Saves the map in XML format
hmmm using standard type members as attributes
using complex objects members as nodes
<map attrib1="" attrib2="" attrib3="">
<tileset>
<tile attribute1="blah" />
<tile attribute1="blah" />
<tile attribute1="blah" />
<tile attribute1="blah" />
</tileset>
</map>
*/
bool Map::SaveMap()
{
pugi::xml_document xmlDoc;
pugi::xml_node xmlMap = xmlDoc.append_child("map");
xmlMap.append_attribute("width").set_value(width_);
xmlMap.append_attribute("height").set_value(height_);
//objectify player soon
xmlMap.append_attribute("playerplaced").set_value(playerplaced_);
xmlMap.append_attribute("playerx").set_value(playerStartX_);
xmlMap.append_attribute("playery").set_value(playerStartY_);
pugi::xml_node xmlTileSet = xmlMap.append_child("tilevector");
for(int i = 0; i < tiles_.size(); i++)
{
for(int j = 0; j < tiles_[i].size(); j++)
{
Tile *currentTile = &tiles_[i][j];
pugi::xml_node xmlCurrentTile = xmlTileSet.append_child("tile");
xmlCurrentTile.append_attribute("tiletype").set_value(currentTile->GetTileType());
xmlCurrentTile.append_attribute("x").set_value(currentTile->GetCurrentPositionX());
xmlCurrentTile.append_attribute("y").set_value(currentTile->GetCurrentPositionY());
xmlCurrentTile.append_attribute("clickable").set_value(currentTile->GetClickable());
xmlCurrentTile.append_attribute("color_a").set_value(currentTile->GetColor().a);
xmlCurrentTile.append_attribute("color_b").set_value(currentTile->GetColor().b);
xmlCurrentTile.append_attribute("color_g").set_value(currentTile->GetColor().g);
xmlCurrentTile.append_attribute("color_r").set_value(currentTile->GetColor().r);
xmlCurrentTile.append_attribute("height").set_value(currentTile->GetHeight());
xmlCurrentTile.append_attribute("width").set_value(currentTile->GetWidth());
xmlCurrentTile.append_attribute("movespeed").set_value(currentTile->GetMoveSpeed());
if(currentTile->GetHasImage())
{
pugi::xml_node xmlCurrentImage = xmlCurrentTile.append_child("image");
xmlCurrentImage.append_attribute("id").set_value(currentTile->GetObjectImage()->GetId());
}
}
}
return xmlDoc.save_file(al_path_cstr(mapPath_,'/'));
}
示例2: UpdatePlayingState
///=====================================================
///
///=====================================================
void Game::UpdatePlayingState(OpenGLRenderer* renderer){
PROFILE_CATEGORY(Gameplay);
if (s_theInputSystem->GetKeyWentDown(VK_ESCAPE)){ //go back to Quest
SetState(Quest);
m_titleRenderer.ClearText();
m_titleRenderer.PrintText("Quests");
DestroyCurrentGame(renderer);
}
else if (s_theInputSystem->GetKeyWentDown('M')){ //toggle map visibility
m_forceMapVisible = !m_forceMapVisible;
}
else if (s_theInputSystem->IsKeyDown('P')){ //test pathfinding
static IntVec2 goal;
if (m_player->m_path.HasFinishedPath()){
Tile randomTile = m_map->GetRandomTile();
while (randomTile.GetTileType() != TileType::Air)
randomTile = m_map->GetRandomTile();
goal = randomTile.m_position;
}
m_player->PathfindToDestination(goal, true, false);
}
else if (m_messageBar.m_isWaitingForPlayer){
if (s_theInputSystem->GetKeyWentDown(VK_SPACE)){ //read more messages in the message bar
m_messageBar.m_isWaitingForPlayer = false;
m_messageBar.m_text.clear();
}
}
else if (m_savedGame){ //return to main menu after save game
SetState(MainMenu);
m_player->Die();
DestroyCurrentGame(renderer);
m_titleRenderer.ClearText();
m_titleRenderer.PrintText("Dagger", RGBAchars::RED);
m_menuRenderer.ClearText();
m_menuRenderer.PrintText("N) New Game");
m_menuRenderer.PrintText("L) Load Game");
m_menuRenderer.PrintText("Q) Quit");
m_menuRenderer.ToggleRenderFromCenter();
m_bottomMessageRenderer.ClearText();
m_savedGame = false;
}
else if (s_theInputSystem->GetCurrentCharacterDown() == 'S'){ //save game
HandleDeadEntities(renderer);
SaveGame();
}
///==========================================================================================================================================
/// GAMEPLAY
///==========================================================================================================================================
else{
if (Actor::s_actorsOnMap.size() == 1){ //only have a player... the following code would crash in that case
UpdatePlayer(renderer);
return;
}
//pre-compute what each AI plans to do, so the Group AI system can make adjustments before actually making moves
Actors::const_iterator actorIter = Actor::s_actorsOnMap.cbegin();
float maxSpeed = actorIter->first + 1.0f;
if (!actorIter->second->IsPlayer()){
for (; actorIter != Actor::s_actorsOnMap.cend(); ++actorIter){
Actor* actor = actorIter->second;
if (actor->IsPlayer()){
break;
}
else{
((NPC*)actor)->PlanNextThink();
}
}
m_AISystem.PlanNextMove(*m_player);
actorIter = Actor::s_actorsOnMap.cbegin();
}
//everyone moves
for (; actorIter != Actor::s_actorsOnMap.cend() && actorIter->first < maxSpeed;){
Actor* actor = actorIter->second;
if (actor->IsPlayer()){
bool didMove = UpdatePlayer(renderer);
if (didMove){
float turnOrder = actorIter->first;
actorIter = Actor::s_actorsOnMap.erase(actorIter);
Actor::s_actorsOnMap.emplace(++turnOrder, actor);
}
return;
}
else{
actor->Think(true);
//.........这里部分代码省略.........