bool Mine::isTriggered(Spiders *spiders){
	bool result = false;
	float tmpSize = 0;
	MyVector tmpPos = MyVectorBuilder::createMyVectorBuilder()
		.withX(this->x)
		.withY(this->y)
		.withZ(this->z)
		.build();
	for (int i =0; i<(int) spiders->getSpiderList().size(); i++){
		tmpSize = spiders->getSpiderList().at(i).getSize();
		if (abs(this->x - spiders->getSpiderList().at(i).getPosition().getX()) > tmpSize + this->radian){
			continue;
		}
		if (abs(this->z - spiders->getSpiderList().at(i).getPosition().getZ()) > tmpSize + this->radian){
			continue;
		}
		if (tmpPos.distance(spiders->getSpiderList().at(i).getPosition()) < tmpSize + this->radian){
			spiders->die(i, 0);
			if (!this->explodingFlag){
				this->explodeFrame = 1;
			}
			this->explodingFlag = true;
			result = true;
		}
	}

	return result;
}
void DrawMissiles(vector<missile*> missiles, myVertex* terrainVertex, Spiders* spiders){
	vector<missile*>::iterator it;
	vector<int> needToExit;
	int i = 0, j = 0;
	float tmpSize;
	for (it = missiles.begin(); it != missiles.end(); it++){
		if ((*it)->needToExit()){
			continue;
		}
		float terrainY = getYFromXZ ((*it)->getX(), (*it)->getZ(), terrainVertex);		
		if ((*it)->isColliding(terrainY)){
			//Utilize "explode XX.tga"	
			if (explodeModeFlag){				
				if (!(*it)->tgaNeedToExit()){
					(*it)->tgaExplode();
				}
				else{						
					needToExit.push_back(i);
				}
			}
			//Utilize "fire1.bmp"
			else{								
				if (!(*it)->needToExit()){						
					(*it)->explode();
				}
				else{						
					needToExit.push_back(i);
				}
			}
			tmpSize = 0;
			MyVector tmpPos = MyVectorBuilder::createMyVectorBuilder()
				.withX((*it)->getX())
				.withY(0)
				.withZ((*it)->getZ())
				.build();
			if ((*it)->getExplodeFrame() == 2){
				for (j = 0; j<(int)spiders->getSpiderList().size();j++){
					tmpSize = spiders->getSpiderList().at(i).getSize();
					if (abs((*it)->getX() - spiders->getSpiderList().at(j).getPosition().getX()) > tmpSize + 20){
						continue;
					}
					if (abs((*it)->getZ() - spiders->getSpiderList().at(j).getPosition().getZ()) > tmpSize + 20){
						continue;
					}
					if (tmpPos.distance(spiders->getSpiderList().at(j).getPosition()) < tmpSize + 20){
						spiders->die(j, 1);
					}
				}
			}
		}
		else{
			(*it)->drawMissile();
			(*it)->forward();
		}	
		i++;
	}
	//clear missiles that already exit
	//sort (needToExit.begin(), needToExit.end(), myfunction);
	//for (i = 0; i < needToExit.size(); i++){
	//	missiles.erase(missiles.begin()+needToExit.at(i)-i);
	//}
	//needToExit.clear();
}