-
Notifications
You must be signed in to change notification settings - Fork 0
/
LevelPanGhost.cpp
83 lines (74 loc) · 1.83 KB
/
LevelPanGhost.cpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "StdAfx.h"
#include "LevelPanGhost.h"
#include "GameManager.h"
extern Camera* mainCamInst;
LevelPanGhost::LevelPanGhost(GameManager* gm) : Actor(gm->getDXRef())
{
gameMan = gm;
phase = LEVELPAN_INACTIVE;
startPoint = gm->GetLeftmostCheckpoint();
endPoint = gm->GetFinalCheckpoint();
timeProgression = 0.0f;
}
LevelPanGhost::~LevelPanGhost(void)
{
}
bool LevelPanGhost::Finished()
{
return (phase == LEVELPAN_FINISHED_PHASE);
}
void LevelPanGhost::MakeActive()
{
::mainCamInst->ClearTargets();
::mainCamInst->AddTrackingTarget(this);
phase = LEVELPAN_PREP_PHASE;
}
void LevelPanGhost::Cancel()
{
phase = LEVELPAN_FINISHED_PHASE;
::mainCamInst->ClearTargets();
}
void LevelPanGhost::Update(float timePassed)
{
timeProgression += timePassed;
switch(phase)
{
case LEVELPAN_PREP_PHASE:
timeProgression = 0.0f;
phase = LEVELPAN_PAN_PHASE;
break;
case LEVELPAN_PAN_PHASE:
if (timeProgression < TOTAL_PANNING_TIME)
{
float interpAmt = timeProgression / (float) TOTAL_PANNING_TIME;
float newX = (endPoint->x - startPoint->x) * interpAmt + startPoint->x;
float newY = (endPoint->y - startPoint->y) * interpAmt + startPoint->y;
SetPosition(newX, newY);
}
else
{
timeProgression = 0.0f;
phase = LEVELPAN_PAUSE_PHASE;
}
break;
case LEVELPAN_PAUSE_PHASE:
if (timeProgression >= TOTAL_POSTPAN_PAUSE)
{
// move on to overview phase
::mainCamInst->ClearTargets();
::mainCamInst->AddTrackingTarget(startPoint);
::mainCamInst->AddTrackingTarget(endPoint);
timeProgression = 0.0f;
phase = LEVELPAN_OVERVIEW_PHASE;
}
break;
case LEVELPAN_OVERVIEW_PHASE:
if (timeProgression >= TOTAL_ZOOMOUT_TIME)
{
::mainCamInst->ClearTargets();
timeProgression = 0.0f;
phase = LEVELPAN_FINISHED_PHASE;
}
break;
}
}