void moveMinions(void)
{
  int i,j,k;
  
  //  for (k=0;k<waveNumber;k++) {
  for(k=waveNumber-1;k==waveNumber-1;k++) {
    
    for (i=0;i<Length(waves[k].m);i++) {
      int speed = waves[k].m[i].speed;
      int damage = waves[k].m[i].damage;
      
      
      for (j=0;j<(DEF_PATH_LEN*DEF_FULL_PATH_LEN);j += speed) {
	
	if (waves[k].m[i].inPlay == 1 && 
	    waves[k].m[i].translation.x <= -15 &&
	    waves[k].m[i].translation.z == 11) {
	
	  modifyLives(1, damage);
	  waves[k].m[i].inPlay = 0;
	  break;
	}

	
	if (i == 0) {
	
	  if (waves[k].m[i].translation.x > 25) {
	    moveMinion(k,i,0);
	    break;
	  }
	 
	  else if(waves[k].m[i].translation.x == fullPath[j-speed].p.x &&
		  waves[k].m[i].translation.z == fullPath[j-speed].p.z) {
	    moveMinion(k,i,j);
	    break;
	  }
	}
	
	else {
	
	  if (fabs(waves[k].m[i-1].translation.x - waves[k].m[i].translation.x) > 
	      ((waves[k].m[i].scale.x)*20) || 
	      fabs(waves[k].m[i-1].translation.z - waves[k].m[i].translation.z) > 0) {
	    if (waves[k].m[i].translation.x > 25){
	      moveMinion(k,i,0);
	      break;
	    }
	   
	    else if(waves[k].m[i].translation.x == fullPath[j-speed].p.x &&
		    waves[k].m[i].translation.z == fullPath[j-speed].p.z) {
	      moveMinion(k,i,j);
	      break;
	    }
	  } 
	} 
      } 
    } 
  } 
}
示例#2
0
/*
 *  moveMinions
 *  ------
 *  moves every minion into its specific position
 *  This is horribly inefficient code
 */
void moveMinions(void)
{
  int i,j,k;
  /* for each wave (that is in play) 
     this allows for multiple waves at once moving along.
     I'm currently not using this, so we're going to just check against the current waveNumber,
     with a poor man's for loop so I don't have to re-write code 
  */
  //  for (k=0;k<waveNumber;k++) {
  for(k=waveNumber-1;k==waveNumber-1;k++) {
    
    /* for each minion in the wave */
    for (i=0;i<Length(waves[k].m);i++) {
      int speed = waves[k].m[i].speed;
      int damage = waves[k].m[i].damage;
      
      /* Length(fullPath) = 2200... error about sizeof with structs */
      for (j=0;j<(DEF_PATH_LEN*DEF_FULL_PATH_LEN);j += speed) {
	/* if the minion is in play and in front of the keep, take damage and remove from play */
	if (waves[k].m[i].inPlay == 1 && 
	    waves[k].m[i].translation.x <= -15 &&
	    waves[k].m[i].translation.z == 11) {
	  /* minion hurts you for X damage and gets removed from play */
	  modifyLives(1, damage);
	  waves[k].m[i].inPlay = 0;
	  break;
	}

	/* first minion */
	if (i == 0) {
	  /* first time through */
	  if (waves[k].m[i].translation.x > 25) {
	    moveMinion(k,i,0);
	    break;
	  }
	  /* if we're at the previous position, increment by one */
	  else if(waves[k].m[i].translation.x == fullPath[j-speed].p.x &&
		  waves[k].m[i].translation.z == fullPath[j-speed].p.z) {
	    moveMinion(k,i,j);
	    break;
	  }
	}
	/* every other minion */
	else {
	  /* stagger the planes - this technique won't work with different speeds of planes */
	  /* first time through */
	  if (fabs(waves[k].m[i-1].translation.x - waves[k].m[i].translation.x) > 
	      ((waves[k].m[i].scale.x)*20) || 
	      fabs(waves[k].m[i-1].translation.z - waves[k].m[i].translation.z) > 0) {
	    if (waves[k].m[i].translation.x > 25){
	      moveMinion(k,i,0);
	      break;
	    }
	    /* if we're at the previous position, increment by one */
	    else if(waves[k].m[i].translation.x == fullPath[j-speed].p.x &&
		    waves[k].m[i].translation.z == fullPath[j-speed].p.z) {
	      moveMinion(k,i,j);
	      break;
	    }
	  } /* end if for plane staggering */
	} /* end else for every other minion (not the first) */
      } /* end for each point in the fullPath */
    } /* end for each minion in wave */
  } /* end for each wave */
}