string Board::ToString(Pos sharpPosition) { // TODO : -1 = magic number. string s = " "; for (int x = 0; x < kStageWidth; x++) s += (to_string(x) + " "); s += "\n"; for (int y = 0; y < kStageHeight; y++) { s += (to_string(y) + " "); for (int x = 0; x < kStageWidth; x++) { Pos cur = Pos(x,y); if ( cur == sharpPosition ) s += "##"; else s += GetUnitID(cur); if (x != kStageWidth - 1) s += " "; } if (y != kStageHeight - 1) { s += "\n "; for (int x = 0; x < kStageWidth; x++) s += " "; s += "\n"; } } s += "\n====================================\n"; return s; }
void Map::InitMap(Player* player, int roomId) { for (int i = 0; i < INIT_ROCK_NUM; ++i) { auto pos = b2Vec2(static_cast<float>(rand() % MAX_MAP_SIZE_X), static_cast<float>(rand() % MAX_MAP_SIZE_Y)); auto rock = new MoveRock(player, b2Vec2(CONVERT_IN(pos, roomId))); player->GetClient()->SendMapInfo(player->GetPlayerID(), rock->GetUnitID(), rock->GetBody()->GetPosition()); } }
void Map::LavaCreate(Player* player, int roomId) { if (player->GetClient()->GetPlayer() == nullptr) { return; } auto pos = b2Vec2(static_cast<float>(rand() % MAX_MAP_SIZE_X), static_cast<float>(rand() % MAX_MAP_SIZE_Y)); auto lava = new Lava(player, b2Vec2(CONVERT_IN(pos, roomId))); player->GetClient()->SendMapInfo(player->GetPlayerID(), lava->GetUnitID(), lava->GetPos()); }
void IceballSkill::SkillCast(SkillKey key, const b2Vec2& heroPos, const b2Vec2& targetPos) { auto hero = m_Owner->GetMyHero(); hero->EndMove(); m_TargetPos = targetPos; ShootMissile(GenerateInitPos(heroPos, targetPos)); auto client = m_Owner->GetClient(); client->SkillBroadCast(hero->GetUnitID(), heroPos, targetPos, key); }