コード例 #1
0
void EnemyManager::UpdateWaves(float dt)
{
	if (!waves[currentWave - 1].allEnemiesSpawned())
	{
		int nextEnemy = waves[currentWave - 1].getEnemy(dt);
		if (nextEnemy != 0)
		{
			float spawnAngle = randomizer->GetInt(0, 360);
			if (nextEnemy == 1 || nextEnemy == 3)
			{
				for (int i = 0; i < 3; i++)
				{
					SpawnEnemy(currentWave, nextEnemy, spawnAngle+pmath::degreesToRadians(randomizer->GetFloat()*40));
				}
			}
			else if (nextEnemy == 5)
			{
				for (int i = 0; i < 2; i++)
				{
					SpawnEnemy(currentWave, nextEnemy, spawnAngle +pmath::degreesToRadians(randomizer->GetFloat()*15));
				}
			}
			else
				SpawnEnemy(currentWave, nextEnemy, spawnAngle);
			std::cout << "Spawned enemy with type " << nextEnemy << ", current wave is " << currentWave<< "." << std::endl;
		}
	}
	else if (enemies.size() == 0)
	{
		currentWave += 1;
	}
}
コード例 #2
0
ファイル: game.cpp プロジェクト: Sisky/Game-Programming
//read map from textfile
void 
Game::ReadMap()
{
	std::string line;
	std::ifstream file("assets\\map.txt");
	float y = 1;

	if (file.is_open())
	{
		while (getline(file, line))
		{
			for (std::string::size_type i = 1; i < line.size()+1; ++i) 
			{
				if (line[i] == 'X')
				{
					//spawn platform
					SpawnPlatform(tileSize *i-tileSize, tileSize *y);
				}
				else if (line[i] == 'E')
				{
					//spawn enemy
					SpawnEnemy(tileSize * i- tileSize, tileSize * y);
				}
			}
			y++;
		}
	}

}
コード例 #3
0
void SceneManagerDungeon::SpawnEnemy(int x, int y, float movementSpeed, float followSpeed, int followRange, Enums::EnemyTypes type)
{
    MapEventEnemy* mapEvent = new MapEventEnemy(movementSpeed, type);
    SpawnEnemy(mapEvent, type, x * TileMap::GetTileWidth(), y * TileMap::GetTileWidth());
    m_events.push_back(std::unique_ptr<MapEvent>(mapEvent));
    mapEvent->FollowPlayer(true, followRange, followSpeed);
}
コード例 #4
0
//==============================================================================
//
void MapEditor::OnLoop()
{
        // Move camera
        MoveCamera();

	// Check to make sure that the camera didn't move out of bounds - if so, change map view
	Camera::CameraControl.CheckBounds();

	// Change player character state
	Camera::CameraControl.AnimateCharacter();

	// De-spawn entities if too far from player or marked for despawning
	DeSpawnEntities();

	// Move entities and animate
	for(unsigned int i = 0; i < EntityList.size(); ++i) EntityList[i]->OnLoop();

	// Check for collision between player character and Entities
	CheckEntityCollisions();

	// Check for collision between bullets and enemies
	CheckBulletCollision();

	// Check to see if player is dead
	if(playerHealth < 1) Running = false;

	// Decide whether to spawn enemy
	if(numEnemies<20 && rand()%50<1) SpawnEnemy();

}
コード例 #5
0
ファイル: EnemySpawner.cpp プロジェクト: joeleon1/Flat-Flight
// Called every frame
void AEnemySpawner::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	timeToNextCheck -= DeltaTime;

	if (timeToNextCheck <= 0) {
		timeToNextCheck = spawnCheckRate;
		numOfLoops++;

		if (numOfLoops >= timesToIncreaseDifficulty) {
			numOfLoops = 0;
			speedToAssign += speedIncrease;
		}

		float temp = ((float)(rand() % 100)) / 100.0f;

		//GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Blue, "Checking for spawn: "+ FString::SanitizeFloat(temp));

		if (temp <= spawnChance) {

			SpawnEnemy();
		}

	}


}
コード例 #6
0
//
// ARandomEnemySpawnVolume::SpawnGroup_Implementation
//
void ARandomEnemySpawnVolume::SpawnGroup_Implementation()
{
    // Spawn the group in random locations within the spawn volume.
    for( int i = 0; i < EnemiesPerGroup; ++i )
    {
        FVector HalfExtents{ SpawnAreaBoxComponent->GetScaledBoxExtent() / 2.0f };
        FBox	Box{ GetActorLocation() - HalfExtents, GetActorLocation() + HalfExtents };
        FVector Location = FMath::RandPointInBox( Box );

        SpawnEnemy( Location, FRotator::ZeroRotator );
    }
}
コード例 #7
0
update_status ModuleEnemies::PreUpdate()
{
	// check camera position to decide what to spawn
	for(uint i = 0; i < MAX_ENEMIES; ++i)
	{
		if(queue[i].type != ENEMY_TYPES::NO_TYPE)
		{
				SpawnEnemy(queue[i]);
				queue[i].type = ENEMY_TYPES::NO_TYPE;
				LOG("Spawning enemy at %d", queue[i].x * SCREEN_SIZE);
		}
	}

	return UPDATE_CONTINUE;
}
コード例 #8
0
void EnemyManager::MainLoop(HDC hdc){
	static int cnt = SpawnInterval;

	enemyhdc = hdc;
	if (cnt >= SpawnInterval){
		SpawnEnemy();

		
		cnt = SpawnInterval / 2;
	}
	
	cnt++;
/*
	if(SpawnList.empty()){}
	else
		DebugStringVal("%d", SpawnList[0], hdc, 200, 200, 20);
*/	


	//敵の移動。キャラとの判定。消滅など。
	for (int i = 0; i < eobj.size(); i++) {
		//	DebugStringVal("Call=%d", i, hdc, 100, 50 + (10 * i), 15);
		int ex = eobj[i]->Enemy_x(), ey = eobj[i]->Enemy_y();
		eobj[i]->enemy_scroll(scroll_x, scroll_y);
		eobj[i]->bullet_scroll(scroll_x, scroll_y);

		if (ex > 0 && ey > 0 && ex < WINDOW_WIDTH && ey < WINDOW_HEIGHT) {
			eobj[i]->chara_strc(plstats);
			eobj[i]->move_enemy();
			eobj[i]->Enemy_paint(hdc);

			//敵からの死亡フラグを得る
			if (eobj[i]->get_deadflg()) {
				GetDeadflag(eobj[i]->get_deadflg());
			}

			//敵が消滅したらオブジェクトを外す //メモリはユニークポインタが開放してくれる
			if (eobj[i]->get_onActive() == 0) {
				SpawnList.push_back(eobj[i]->EnemyID());
				cnt = 0;
				eobj.erase(eobj.begin() + i);

				break;
			}
		}
	}
}
コード例 #9
0
void EnemyManager::UpdateEnemies(float deltaTime, int &health, float &money)
{
	float tempDistance = 0.0f;
	float tempAngle = 0.0f;
	for(int i = enemies.size() - 1; i >= 0; i--)
	{
		auto& enemy = enemies[i];
		auto& c = *enemy->GetComponent<Enemy>();
		if (!c.getCarrierStatus())
		{
			c.UpdateMovementSpeed(deltaTime);
			c.SetDistance(c.GetDistance() - c.GetSpeed() * deltaTime);
			enemy->Update(deltaTime);
			tempDistance = c.GetDistance();
			tempAngle = c.GetAngle();
			enemy->transform.SetPosition(cosf(tempAngle)*tempDistance, sinf(tempAngle) * tempDistance);
			enemy->transform.SetRotation(pmath::radiansToDegrees(tempAngle)+180);
		}
		else
		{
			tempAngle = c.GetAngle();
			if (c.GetDistance() > 400)
				c.SetDistance(c.GetDistance() - 30*deltaTime);
			enemy->transform.SetPosition(cosf(tempAngle)*c.GetDistance(), sinf(tempAngle)*c.GetDistance());
			enemy->transform.SetRotation(pmath::radiansToDegrees(tempAngle)+90);
			if (c.GetCarrierSpawn(deltaTime))
			{
				SpawnEnemy(currentWave, 7, tempAngle);
			}
			c.SetAngle(tempAngle + 0.002f);
		}
		if (c.GetDistance() <= 0)
		{
			RemoveChild(enemy);
			enemies.erase(enemies.begin() + i);
			health -= 1;
		}
		if (!c.GetAlive())
		{
			c.OnDeath();
			money += c.GetBounty();
			RemoveChild(enemy);
			enemies.erase(enemies.begin() + i);
		}
	}

}
コード例 #10
0
void SceneManagerDungeon::PlaceChest(bool loadSaved)
{
    std::pair<int, int>* pos;
    //Add a maximum number of tries to prevent endless loop
    //For the first 100 try to find a dead end to put the chest into
    int nrTries = 0;
    bool placed;
    do
    {
        nrTries++;
        pos = m_generator.GetFreePosition(nrTries < 100);
        int roomNr = m_map.GetRoomNr(pos->first, pos->second);
        if((roomNr == m_map.m_endRoomNr || roomNr == m_map.m_startRoomNr) && nrTries < 200)
        {
            //Do not place chest in start or end Room
            continue;
        }
        placed = m_mapFill->PlaceItemAt(1,2,4,MapFillDungeon::TileChest,pos->first, pos->second);
    }
    while(!placed && nrTries < 200);
    if(!loadSaved)
    {
        std::cout << "Chest at " << pos->first << " " << pos->second << " nr tries:" << nrTries << " placeable: " << placed << std::endl;
        m_events.push_back(std::unique_ptr<MapEvent>(new MapEventChest(pos->first, pos->second)));

        //look for adjacent free tile
        if(!m_map.DoesCollide(pos->first + 1, pos->second))
        {
            pos->first +=1;
        }
        else if(!m_map.DoesCollide(pos->first - 1, pos->second))
        {
            pos->first -=1;
        }
        else if(!m_map.DoesCollide(pos->first, pos->second + 1))
        {
            pos->second +=1;
        }
        else if(!m_map.DoesCollide(pos->first, pos->second - 1))
        {
            pos->second -=1;
        }

        SpawnEnemy(pos->first,pos->second, 0.0f, 256.0f,2, Enums::EnemyChest);
    }
}
コード例 #11
0
update_status ModuleEnemies::PreUpdate()
{
	// check camera position to decide what to spawn
	for (uint i = 0; i < MAX_ENEMIES; ++i)
	{
		if (queue[i].type != ENEMY_TYPES::NO_TYPE)
		{
			if (queue[i].x * SCREEN_SIZE < App->render->camera.x + (App->render->camera.w * SCREEN_SIZE) + SPAWN_MARGIN)
			{
				if (queue[i].born < SDL_GetTicks()){
					SpawnEnemy(queue[i]);
					queue[i].type = ENEMY_TYPES::NO_TYPE;
					LOG("Spawning enemy at %d", queue[i].x * SCREEN_SIZE);
				}
				
			}
		}
	}

	return UPDATE_CONTINUE;
}
コード例 #12
0
void SceneManagerDungeon::Tick()
{
    m_timeToNextSpawn -= GameController::getInstance()->GetTickTimeSeconds();
    if(m_timeToNextSpawn <= 0.0f)
    {
        SpawnEnemy();
    }
    SceneManagerMoveable::Tick();

    #ifdef DEBUG_FLAG

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::X))
    {
        m_roomNumberNode->setVisibility(true);
    }
    else
    {
        m_roomNumberNode->setVisibility(false);
    }

    #endif // DEBUG_FLAG
}
コード例 #13
0
void SceneManagerDungeon::SpawnEnemy()
{
    std::cout << "Spawn Enemy" << std::endl;
    sf::FloatRect heroPos = m_hero->getGlobalBoundingBox();
    float x = heroPos.left + heroPos.width/2;
    x /= TileMap::GetTileWidth();
    float y = heroPos.top + heroPos.height/2;
    y /= TileMap::GetTileWidth();
    int playerRoomNumber = m_map.GetRoomNr(x,y);
    std::pair<int, int>* pos;
    int nrTries = 0;
    //Try 10 Times to find a Position not in the same room as the Hero
    do
    {
        pos = m_generator.GetFreePosition();
        nrTries++;
    }
    while(m_map.GetRoomNr(pos->first, pos->second) == playerRoomNumber && nrTries < 10);

    SpawnEnemy(pos->first, pos->second, 110.0f, 220.0f, 4, Enums::EnemyDefault);

    m_timeToNextSpawn = rand()%10 + 10;
}
コード例 #14
0
ファイル: Main.cpp プロジェクト: yoiang/Google-Code-Dump
void DisplayHandler () // display callback function
{
	if (bRotate) 
	{
		fCameraAngle[0] += 1.0 ;
		fCameraAngle[2] += 1.0 ;
	}
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ;
	glLoadIdentity() ;

	SetCamera() ;

	if (!bPause)
	{
		GLfloat fTempX = GLfloat(iLastMouseX) / GLfloat(iWinWidth) ;
		GLfloat fTempY = GLfloat(iLastMouseY) / GLfloat(iWinHeight) ;
		GLfloat fFixedX = (Player.ptLocation.dX - 8.65) / -17.3 ;
		GLfloat fFixedZ = (Player.ptLocation.dZ - 8.65) / -17.3 ;
		if (bRightMouseDown)
		{
			if (!(fFixedX + 0.02 > fTempX && fFixedX - 0.02 < fTempX))
			{
				if (fFixedX > fTempX)
				{
					Player.ptLocation.dX += 0.1 ;
					if (Player.ptAngle.dZ > -20) 
						Player.ptAngle.dZ -= 5.0 ;
				} else
				{
					Player.ptLocation.dX -= 0.1 ;
					if (Player.ptAngle.dZ < 20) 
						Player.ptAngle.dZ += 5.0 ;
				}
			} else
			{
				if (Player.ptAngle.dZ < 0) Player.ptAngle.dZ += 5.0 ;
				else if (Player.ptAngle.dZ > 0)	Player.ptAngle.dZ -= 5.0 ;
			}
			if (!(fFixedZ + 0.1 > fTempY && fFixedZ - 0.02 < fTempY))
			{
				if (fFixedZ > fTempY)
				{
					Player.ptLocation.dZ += 0.1 ;
				} else 
				{
					Player.ptLocation.dZ -= 0.1 ;
				}
			}
		} else Player.ptAngle.dZ = 0 ;

		if (randp() > 0.98) AddPlanet() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;
		AddStar() ;

		if (/*!bExplode && */iCount % 15 == 0) SpawnEnemy() ;

		if (!bExplode && bAutofire && iCount % 4 == 0) FireShot(&Player, pPlayerShots) ;

		iCount ++ ;

	}
	
	DisplayStars() ;
	DisplayPlanets() ;
	DisplayEnemies() ;

	DisplayShots(pPlayerShots) ;
	DisplayShots(pEnemyShots) ;

	if (bExplode && !bPause)
	{
		if (iCount == 0) 
		{
			printf("Game over\n") ;
			MakeExplosion(Player.ptLocation, 1000) ;
		}
	} else 
	{
		if (iCount % 4)
		{
			Particle *pNew = new Particle ;
			pNew->ptLocation.dX = Player.ptLocation.dX + randp() * 0.5 - 0.25;
			pNew->ptLocation.dY = Player.ptLocation.dY + 0.3 * randp() ;
			pNew->ptLocation.dZ = Player.ptLocation.dZ - 1.5 + 0.2 * randp() ;
			pNew->ptVelocity.dX = 0 ;
			pNew->ptVelocity.dY = 0 ;
			pNew->ptVelocity.dZ = -0.2 ;
			pNew->ptColor.dX = 0.98 ;
			pNew->ptColor.dY = 0.59 + 0.3 * randp() - 0.15 ;
			pNew->ptColor.dZ = 0.01 ;
			pNew->dAlpha = 0.7 ;
			pNew->dMass = 1 ;
			pNew->dLife = 7 * randp() + 3 ;
			pNew->ptAcceleration = 0 ;
			Particles.AddBack(pNew) ;
		}

		Player.Display() ;
	}

	LinkedListNode<Particle> *pTravParticles = Particles.pHead ;
	LinkedListNode<Particle> *pTempParticle ;
	
	while (pTravParticles != 0)
	{
		pTravParticles->pValue->dLife -- ;
		if (pTravParticles->pValue->dLife <= 0)
		{
			pTempParticle = pTravParticles ;
			pTravParticles = pTravParticles->pNext ;
			Particles.Remove(pTempParticle, true) ;
		} else
		{
			pTravParticles->pValue->Apply(0.9) ;
			
			DisplayParticle(pTravParticles->pValue) ;
			
			pTravParticles = pTravParticles->pNext ;
		}
	}
	
		
	glFinish() ;
	glutSwapBuffers() ;
	glutPostRedisplay() ;
}
コード例 #15
0
void SceneManagerDungeon::Generate(int tileWidth, int tileHeight, Enums::GenerationType type, bool loadSaved)
{
    int nrLayers = 5;
    m_minimapColor.resize(MapFillDungeon::TILE_TYPE_END);
    m_minimapColor[MapFillDungeon::Wall] = sf::Color::White;
    m_minimapColor[MapFillDungeon::Space] = sf::Color::Black;
    m_minimapColor[MapFillDungeon::InteractableWall] = sf::Color::White;
    m_minimapColor[MapFillDungeon::BlockingItem] = sf::Color::Black;
    m_minimapColor[MapFillDungeon::WalkthroughItem] = sf::Color::Black;
    m_minimapColor[MapFillDungeon::Stairs] = sf::Color::Red;
    //Define Tile Maps
    SetMemberStats();


    #ifdef DEBUG_FLAG

    m_map.init(nrLayers + 1);

    #else

    m_map.init(nrLayers);

    #endif // DEBUG_FLAG



    //Generate Map

    switch(type)
    {
    case Enums::Cave:
        if(tileHeight > 200 || tileWidth > 200)
            m_generator.FasterCellularAutomata(0.45f);
        else
            m_generator.CellularAutomata(0.45f);
        break;
    case Enums::Dungeon:
        m_generator.ConnectedRooms(10,8, tileHeight * tileWidth / 160);
    }

    m_generator.NumberRooms();


    //Fill Base Layer with walkable Tile
    m_mapFill->FillLayer(MapFill::Ground, 0);
    if(m_wallAbove)
    {
        //Fill Wall
        m_mapFill->FillLayer(MapFill::Wall, 0,3);
        //Fill Wall Topping
        m_mapFill->FillLayer(MapFill::WallTopping, 3);
    }
    else
    {
        //Fill Wall
        m_mapFill->FillLayer(MapFill::WallBelow, 3);
    }


    #ifdef DEBUG_FLAG

    for(int x = 0; x < m_map.GetWidth(); x++)
    {
        for(int y = 0; y < m_map.GetHeight(); y++)
            m_map.SetTileId(x,y,m_map.GetRoomNr(x,y), 5);
    }

    m_map.writeToTileMap(*m_tileMapRoomNumber,nrLayers);

    #endif // DEBUG_FLAG

    m_generator.PlaceStartingAndEndPosition();

    sf::Transform heroTransform;
    //Place Hero at Startposition
    if(m_newHeroPos)
    {
        heroTransform.translate(m_heroX, m_heroY);
    }
    else
    {
        heroTransform.translate(m_map.m_startX * TileMap::GetTileWidth(), m_map.m_startY * TileMap::GetTileWidth() - 14);
    }
    m_hero->setTransform(heroTransform);
    UpdateCamPosition();

    //Add random Items
    m_mapFill->FillLayer(MapFill::AdditionalItems, 1,2,4);


    //Place Stairs
    m_mapFill->PlaceItemAt(1,2,4,MapFillDungeon::TileStairsUp,m_map.m_startX, m_map.m_startY, false);
    m_mapFill->PlaceItemAt(1,2,4,MapFillDungeon::TileStairsDown,m_map.m_endX, m_map.m_endY, false);

    //Place Chests
    PlaceChest(loadSaved);

    if(!loadSaved)
    {
        m_events.push_back(std::unique_ptr<MapEvent>(new MapEventStairs(false, m_map.m_startX, m_map.m_startY)));
        m_events.push_back(std::unique_ptr<MapEvent>(new MapEventStairs(true, m_map.m_endX, m_map.m_endY)));

        //Place additional heroes with a chance of 2%
        if(rand() % 50 == 0)
            PlaceHero();
    }

    m_map.writeToTileMap(*m_tileMap,0);
    m_map.writeToTileMap(*m_tileMapItems,1);
    m_map.writeToTileMap(*m_tileMapAboveHero,2);
    if(m_wallAbove)
    {
        sf::Color halfTransparent(255,255,255,Configuration::GetInstance()->GetWallTransparency() * 255);
        m_map.writeToTileMap(*m_tileMapAboveWall,3, halfTransparent);
        m_map.writeToTileMap(*m_tileMapWallDecoration,4);
    }
    else
    {
        m_map.writeToTileMap(*m_tileMapBelowGround,3);
        m_map.writeToTileMap(*m_tileMapBelowGroundDecoration,4);
    }

    if(!loadSaved)
    {
        //Place Boss at Stairs
        MapEventEnemy* mapEvent = new MapEventEnemy(0.0f, Enums::EnemyBoss);
        SpawnEnemy(mapEvent, Enums::EnemyBoss, m_map.m_endX * TileMap::GetTileWidth(), m_map.m_endY * TileMap::GetTileWidth());
        m_events.push_back(std::unique_ptr<MapEvent>(mapEvent));

        int nrEnemies = m_map.GetWidth() * m_map.GetHeight() / 300;
        for(int i = 0; i < nrEnemies; i++)
        {
            SpawnEnemy();
        }
    }
}
コード例 #16
0
bool ServerApp::Loop()
{
	static float timeSinceStart = 0.f;
	double currentTime = RakNet::GetTime(); // Current time by raknet
	double dt = (currentTime - prevTime) * 0.001f; // dt is the time difference between last frame and this frame
	prevTime = currentTime; // After calculating dt, set current time to previous time for next calculation later on

	timeSinceStart += dt;

	// Enemy spawning
	static const float ENEMY_SPAWN_INTERVAL = 2.f;
	static int enemy_spawn_count = 1;
	static float spawnEnemyTimer = ENEMY_SPAWN_INTERVAL;
	enemy_spawn_count = (timeSinceStart * 0.1f) + 1;
	if (clientList.size() > 0)
	{
		if (spawnEnemyTimer < ENEMY_SPAWN_INTERVAL)
		{
			spawnEnemyTimer += dt;
		}
		else
		{
			for (int i = 0; i < enemy_spawn_count; ++i)
			{
				SpawnEnemy();
			}
			spawnEnemyTimer = 0.f;
		}

		UpdateEnemy(dt);
	}

	static const int SYNCS_PER_SEC = 5;
	static const float TIME_PER_SYNC = 1 / SYNCS_PER_SEC;
	static float enemySyncTimer = TIME_PER_SYNC;
	if (enemySyncTimer < TIME_PER_SYNC)
	{
		enemySyncTimer += dt;
	}
	else
	{
		SendEnemy();
		enemySyncTimer = 0.f;
	}


	if (Packet* packet = rakpeer_->Receive())
	{
		RakNet::BitStream bs(packet->data, packet->length, false);
		
		unsigned char msgid = 0;
		RakNetTime timestamp = 0;

		bs.Read(msgid);

		if (msgid == ID_TIMESTAMP)
		{
			bs.Read(timestamp);
			bs.Read(msgid);
		}

		switch (msgid)
		{
		case ID_SET_SCREEN_TO_SERVER: // Set screen position
			{
				std::cout << "Received screen size" << std::endl;
				bs.Read(s_screen_width);
				bs.Read(s_screen_height);
			}
			break;
		case ID_NEW_INCOMING_CONNECTION:
			{
				if (clientList.size() >= 2)
				{
					RejectPlayer(packet->systemAddress);
				}
				else
				{
					SendWelcomePackage(packet->systemAddress);
				}
			}
			break;

		case ID_DISCONNECTION_NOTIFICATION:
		case ID_CONNECTION_LOST:
			SendDisconnectionNotification(packet->systemAddress);
			break;

		case ID_INITIALPOS:
			{
				float x_, y_;
				int type_;
				std::cout << "ProcessInitialPosition" << std::endl;
				bs.Read( x_ );
				bs.Read( y_ );
				bs.Read( type_ );
				ProcessInitialPosition( packet->systemAddress, x_, y_, type_);
			}
			break;

		case ID_MOVEMENT:
			{
				float x, y;
				unsigned int shipid;
				bs.Read(shipid);
				bs.Read(x);
				bs.Read(y);
				UpdatePosition( packet->systemAddress, x, y );

				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;

		case ID_COLLIDE:
			{
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;

		// Lab 13 Task 14 : new cases on server side to handle missiles
		case ID_NEWMISSILE:
			{
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;
		case ID_UPDATEMISSILE:
			{
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;
		case ID_INJURE_ENEMY:
			{
				int id, hp;
				bs.Read(id);
				ServerEnemy* e = FindEnemyByID(id);
				if (e && e->active)
				{
					bs.Read(hp);
					e->hp = hp;
				}

				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;
		case ID_DESTROY_ENEMY:
			{
				int id;
				bs.Read(id);
				ServerEnemy* e = FindEnemyByID(id);
				if (e->active)
				{
					ResetEnemy(id);
					bs.ResetReadPointer();
					rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
				}
			}
			break;
			// Server does not interfere with shooting
		case ID_SHOOT:
		case ID_UPDATE_PROJECTILE:
			{
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->systemAddress, true);
			}
			break;
		case ID_DESTROY_PROJECTILE:
			{
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;
		case ID_UPDATE_SCORE:
			{
				int score, id;
				bs.Read(id);
				bs.Read(score);
				ClientMap::iterator it = clients_.find(packet->systemAddress);
				if (it == clients_.end())
					break;

				it->second.score = score;
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE, 0, packet->systemAddress, true);
			}
			break;
		case ID_CHAT_SEND:
			{
				char cMsg[256];
				bs.Read(cMsg);
				chatList.push(cMsg);
				bs.ResetReadPointer();
				rakpeer_->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, packet->systemAddress, true);
			}
			break;

		default:
			std::cout << "Unhandled Message Identifier: " << (int)msgid << std::endl;
		}

		rakpeer_->DeallocatePacket(packet);
	}

	if (base_hp <= 0)
	{
		return true;
	}
	return false;
}