예제 #1
0
/*teLevel
 *Initializes all data structures required for level
 */
void initLevel(int level)    {
    createKeywordQueue();
	switch(level)	{
		case 0:
			readLevelSettingsFile(TUTORIAL_LEVEL);
			break;
		case 1:
			readLevelSettingsFile(HARD_LEVEL);
			break;
		case 2:
			readLevelSettingsFile(EASY_LEVEL);
			break;
		default:
			break;
	}
    createLevelPaths();
    createTowerGroup();
    createActionQueue();
	createGame();
	createLevelClocks();
    createEnemyGroup();
	createTowerPos();
	initialQueueReader();
	createProjectileList();
  	createExplosionList();
	initialiseParser();
	init_abilities();
    destroyCommandList();
}
예제 #2
0
void testReadLevelSettingsFile()	{
	iprint(countKeywords());
	sput_fail_unless(countKeywords() == 9,"9 Keywords Should Exist in the level settings queue");
	initialQueueReader();	//! Removing set up commands
	sput_fail_unless(countKeywords() == 3,"Valid: 3 Keywords Should Exist in the level settings queue");
	sput_fail_unless(getNumberOfPaths() == 1,"Valid: Number of paths that have been set is 1");
	sput_fail_unless(getNumOfTowerPositions() == 4,"Valid: Number of tower positions that have been created is 4");
	sput_fail_unless(getTowerPositionX(1) == scaleTowerPos(10,SCREEN_WIDTH_GLOBAL,MAX_TOWER_X),"Valid: Tower position 1 x value is as expected after scaling");
	sput_fail_unless(getTowerPositionY(1) == scaleTowerPos(500,SCREEN_HEIGHT_GLOBAL,MAX_TOWER_Y),"Valid: Tower position 1 y value is as expected after scaling");
	sput_fail_unless(getTotalWaveNo() == 3,"Valid: Total Waves set to three");
	setCurrWaveNum(1);
	sput_fail_unless(returnPropertyValueFromQueue(1,waveID) == 1,"Valid: First keyword has waveID 1");
	sput_fail_unless(returnPropertyValueFromQueue(2,waveID) == 2,"Valid: Second keyword has waveID 2");
	sput_fail_unless(returnPropertyValueFromQueue(3,waveID) == 3,"Valid: Third keyword has waveID 3");
	sput_fail_unless(waveCreatorCommand(getKeywordFromQueue(1)) ==3,"Valid: Three enemy commands should be placed in the queue");
	sput_fail_unless(getKeywordTypeFromQueue(3) == wave,"Valid: Third command is queue should be wave");
	sput_fail_unless(getKeywordTypeFromQueue(4) == makeEnemy,"Valid: Fourth command is queue should be makeEnemy");
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 0,"Invalid:Cooldown for single enemy creation not yet ready");
	delayGame(10);
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 1,"Valid: Cooldown for single enemy creation is ready");
	sput_fail_unless(getKeywordTypeFromQueue(7) == delay,"Valid: Seventh Keyword in queue is delay");
	sput_fail_unless(setCreateEnemyGroupDelay(returnPropertyValue(getKeywordFromQueue(7),dTime)) == 30, "group delay is 30");
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 0,"Invalid: Cooldown for enemy group creation is not ready");
	delayGame(30);
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(4)) == 1,"Valid: Cooldown for enemy group creation is ready");
	sput_fail_unless(waveCreatorCommand(getKeywordFromQueue(2)) ==10,"Valid: Ten enemy commands should be placed in the queue");
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(9)) == 0,"Invalid: Enemy has wave ID for next wave");
	setCurrWaveNum(2);
	delayGame(ENEMYSPAWNCOOLDOWN);
	sput_fail_unless(createEnemyCommand(getKeywordFromQueue(9)) == 1,"Valid: Enemy has wave ID for current wave");
	//levelQueueReader();
}
/*
 *Initializes all data structures required for level
 */
void initLevel(int level)    {
    createKeywordQueue();
	switch(level)	{
		case 0:
			readLevelSettingsFile("../data/tutorial.txt");
			break;
		case 1:
			createLevel();
			break;
		default:
			break;
	}
    createLevelPaths();
    createTowerGroup();
    createActionQueue();
	createGame();
	createLevelClocks();
    createEnemyGroup();
	createTowerPos();
	initialQueueReader();
	createProjectileList();
	initialiseParser();
	init_abilities();
}