src/collisions.cpp
// enemyUnitHit *******
// This method is called every time an enemy unit is hit by anything.
// Then, it's responsible of making all the necessary changes in the
// touched enemy unit.

enemyUnitHit
This method is called every time an enemy unit is hit by anything.
Then, it's responsible of making all the necessary changes in the
touched enemy unit.
enemyUnitHit This method is called every time an enemy unit is hit by anything . Then it ' s responsible of making all the necessary changes in the touched enemy unit .
bool enemyUnitHit(
	vectorListNodeStruct<enemyUnitStruct>& eUnit,
	gameObjectPointerStruct& toucher)
{
	vectorListNodeStruct<playerUnitStruct>* player;
	vectorListNodeStruct<bulletUnitStruct>* bullet;
	if (eUnit.data.untouchableTimeLeft>0 || eUnit.data.energyLeft<=0)
		return true;
	eUnit.data.untouchableTimeLeft=eUnit.data.untouchableTimeMax;
	eUnit.data.canBeHitByBullets=false;
	eUnit.data.canBeHitByPlayers=false;
	switch (toucher.objectType) {
	case FILE_GAMEDATA_GAMEOBJECT_PLAYER:
		player=playerList.getNode(toucher.listIndex);
		playerIncrementScoreForHit(toucher, eUnit.data.scoreToGivePerHit);
		if (eUnit.data.decrementableEnergy)
			eUnit.data.energyLeft-=player->data.energyToDrop;
		if (eUnit.data.energyLeft<0) eUnit.data.energyLeft=0;
		break;
	case FILE_GAMEDATA_GAMEOBJECT_BULLET:
		bullet=bulletList.getNode(toucher.listIndex);
		if (bullet->data.owner.objectType==
			FILE_GAMEDATA_GAMEOBJECT_PLAYER) {
			if (!playerIncrementScoreForHit(
				bullet->data.owner,
				eUnit.data.scoreToGivePerHit)) return false;
		}
		if (eUnit.data.decrementableEnergy)
			eUnit.data.energyLeft-=bullet->data.energyToDrop;
		if (eUnit.data.energyLeft<0) eUnit.data.energyLeft=0;
		break;
	}
	if (eUnit.data.untouchableTimeLeft>0) {
		switch(eUnit.data.unitType) {
		case FILE_GAMEDATA_ENEMY_HEADCARRIER:
		case FILE_GAMEDATA_ENEMY_SHEEPCARRIER:
			switch (eUnit.data.unitType) {
			case FILE_GAMEDATA_ENEMY_HEADCARRIER:
				eUnit.data.currentFrame=
					getFrameIndexAndListByName("headCarrierTouched");
				break;
			case FILE_GAMEDATA_ENEMY_SHEEPCARRIER:
				eUnit.data.currentFrame=
					getFrameIndexAndListByName("sheepCarrierTouched");
				break;
			}
			eUnit.data.trembling=true;
			eUnit.data.vFramesPassed=0;
			if (eUnit.data.slaveUnit.objectType!=
				FILE_GAMEDATA_GAMEOBJECT_EMPTY) {
				vectorListNodeStruct<enemyUnitStruct> *cunit;
				if (eUnit.data.slaveUnit.objectType!=
					FILE_GAMEDATA_GAMEOBJECT_ENEMY) return false;
				cunit=enemyList.getNode(
					eUnit.data.slaveUnit.listIndex);
				if (cunit==NULL ||
					cunit->data.id!=eUnit.data.slaveUnit.id)
					return false;
				if (!freeSlavesOf(&eUnit.data)) return false;
				if (!unitStartFalling(cunit->data)) return false;
			}
			eUnit.data.goingToPointX=eUnit.data.x-50;
			eUnit.data.goingToPointY=0-
					(constructContainerFrame(&eUnit.data).h
					-constructContainerFrame(&eUnit.data).handlerY);
			eUnit.data.goingToPoint=true;
			if (eUnit.data.isPosRelative) {
				eUnit.data.goingToPointX-=gameWorld.xCamera;
				eUnit.data.goingToPointY-=gameWorld.yCamera;
			}
			setSpeedForLinealMove(&eUnit.data,
				eUnit.data.goingToPointX, eUnit.data.goingToPointY,
				eUnit.data.linearSpeed*1.5);
			break;
		}
	}
	return true;
}
bool enemyUnitHit ( vectorListNodeStruct < enemyUnitStruct > & eUnit , gameObjectPointerStruct & toucher ) { vectorListNodeStruct < playerUnitStruct > * player ; vectorListNodeStruct < bulletUnitStruct > * bullet ; if ( eUnit . data . untouchableTimeLeft > 0 || eUnit . data . energyLeft <= 0 ) return true ; eUnit . data . untouchableTimeLeft = eUnit . data . untouchableTimeMax ; eUnit . data . canBeHitByBullets = false ; eUnit . data . canBeHitByPlayers = false ; switch ( toucher . objectType ) { case FILE_GAMEDATA_GAMEOBJECT_PLAYER : player = playerList . getNode ( toucher . listIndex ) ; playerIncrementScoreForHit ( toucher , eUnit . data . scoreToGivePerHit ) ; if ( eUnit . data . decrementableEnergy ) eUnit . data . energyLeft -= player -> data . energyToDrop ; if ( eUnit . data . energyLeft < 0 ) eUnit . data . energyLeft = 0 ; break ; case FILE_GAMEDATA_GAMEOBJECT_BULLET : bullet = bulletList . getNode ( toucher . listIndex ) ; if ( bullet -> data . owner . objectType == FILE_GAMEDATA_GAMEOBJECT_PLAYER ) { if ( ! playerIncrementScoreForHit ( bullet -> data . owner , eUnit . data . scoreToGivePerHit ) ) return false ; } if ( eUnit . data . decrementableEnergy ) eUnit . data . energyLeft -= bullet -> data . energyToDrop ; if ( eUnit . data . energyLeft < 0 ) eUnit . data . energyLeft = 0 ; break ; } if ( eUnit . data . untouchableTimeLeft > 0 ) { switch ( eUnit . data . unitType ) { case FILE_GAMEDATA_ENEMY_HEADCARRIER : case FILE_GAMEDATA_ENEMY_SHEEPCARRIER : switch ( eUnit . data . unitType ) { case FILE_GAMEDATA_ENEMY_HEADCARRIER : eUnit . data . currentFrame = getFrameIndexAndListByName ( " " ) ; break ; case FILE_GAMEDATA_ENEMY_SHEEPCARRIER : eUnit . data . currentFrame = getFrameIndexAndListByName ( " " ) ; break ; } eUnit . data . trembling = true ; eUnit . data . vFramesPassed = 0 ; if ( eUnit . data . slaveUnit . objectType != FILE_GAMEDATA_GAMEOBJECT_EMPTY ) { vectorListNodeStruct < enemyUnitStruct > * cunit ; if ( eUnit . data . slaveUnit . objectType != FILE_GAMEDATA_GAMEOBJECT_ENEMY ) return false ; cunit = enemyList . getNode ( eUnit . data . slaveUnit . listIndex ) ; if ( cunit == NULL || cunit -> data . id != eUnit . data . slaveUnit . id ) return false ; if ( ! freeSlavesOf ( & eUnit . data ) ) return false ; if ( ! unitStartFalling ( cunit -> data ) ) return false ; } eUnit . data . goingToPointX = eUnit . data . x - 50 ; eUnit . data . goingToPointY = 0 - ( constructContainerFrame ( & eUnit . data ) . h - constructContainerFrame ( & eUnit . data ) . handlerY ) ; eUnit . data . goingToPoint = true ; if ( eUnit . data . isPosRelative ) { eUnit . data . goingToPointX -= gameWorld . xCamera ; eUnit . data . goingToPointY -= gameWorld . yCamera ; } setSpeedForLinealMove ( & eUnit . data , eUnit . data . goingToPointX , eUnit . data . goingToPointY , eUnit . data . linearSpeed * 1.5 ) ; break ; } } return true ; }
enemyUnitHit 
This method is called every time an enemy unit is hit by anything.
enemyUnitHit This method is called every time an enemy unit is hit by anything .
// enemy unit which was hit
 // the one who touched the enemy unit
 // if this unit is in untouchable or dead state,
 // nothing can affect it now...
 // first change the unit to untouchable state.
 // COLLISION REVISE LATER BEGIN
 // don't let it collide anymore
 // COLLISION REVISE LATER END
 // it's a player unit
 // SCORING
 // increment the player score
 // ENERGY
 // Hurt the enemy unit
 // it's a bullet unit
 // SCORING
 // Increment the toucher player score
 // increment the score of the player
 // who dropped the bullet
 // ENERGY
 // Hurt the enemy unit
 // we aren't dead, but have been touched
 // frame of touched
 // and go tremble
 // continue auto framing
 // FREE SHEEPS (or heads)!
 // and it's time to let sheeps / heads go away
 // carried unit
 // we only know how to let enemies go away
 // obtain the unit and check that's the one we need
 // free that unit
 // let the sheep fall
 // also, the touched unit now wants to escape fast!
 // correct the coordinates to be relative
 // set the speed for going to such point
 // all ok
