aboutsummaryrefslogtreecommitdiff
path: root/src/levels/level3.c
blob: bd1f559c93b5dedf119627391114c886c8216176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "level3.h"
#include "game.h"
#include "world.h"
#include "entityGrouping.h"

void initLevel3(Game * game, Levels * levels) {
	levels->data = KF_MALLOC((sizeof(Level3)));

	if (levels->data == NULL) {
		ALLOCATION_ERROR;
		return;
	}

	Level3 * data = (Level3*)levels->data;
	data->stage = 0;

    WorldEntry entries[] = {
		(WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()},
		(WorldEntry){ENTITY_CAPORALE, (Vector3){0.0, 0.0, 300.0}, QuaternionIdentity()}
	};

    addEntriesToWorld(
		&game->world,
		game,
		entries,
		sizeof(entries) / sizeof(WorldEntry)
	);
}

void closelevel3(Levels * levels) {
	if (levels->data != NULL)
		KF_FREE(levels->data);
}

bool updateLevel3(Game * game, Levels * levels) {
	int i;
	Level3 * data = (Level3*)levels->data;
	bool levelDone = false;

	switch (data->stage) {
		case 0:
			if (game->world.entitiesCount == 1) {
				Vector3 playerPosition = getEntityFromWorld(game->world, 0)->position;
				Vector3 spacing = (Vector3){0.0, 15.0, 15.0};

				addSoldatoGroupWithLeader(game, ENTITY_CAPORALE, 3, Vector3Add((Vector3){0.0, 0.0, 800.0}, playerPosition), spacing);
				spacing = Vector3Negate(spacing);
				addSoldatoGroupWithLeader(game, ENTITY_CAPORALE, 3, Vector3Add((Vector3){0.0, 0.0, -800.0}, playerPosition), spacing);

				data->stage = 1;
			}

			break;
		case 1:
			if (game->world.entitiesCount == 1) {
				levelDone = true;
			}

			break;
		default:
			levelDone = true;
			break;
	}

    return levelDone;
}