Commit 2dc2ee77 authored by Gerhard Stein's avatar Gerhard Stein

Flags and Signs now use action format also. This was missing for a long time

parent 2469531b
......@@ -10,7 +10,32 @@
#include "common/CBehaviorEngine.h"
namespace galaxy {
/*
$15EEW #Keen K flag waving 1
$160CW #Keen K flag waving 2
$162AW #Keen K flag waving 3
$1648W #Keen K flag waving 4
$1666W #Keen flag flips into holder 1
$1684W #Keen flag flips into holder 2
$16A2W #Keen flag flips into holder 3
$16C0W #Keen flag flips into holder 4
$16DEW #Keen flag flips into holder 5
$16FCW #Keen flag flips into holder 6
$171AW #Keen flag flips into holder 7
*/
namespace galaxy {
enum FLAGACTIONS
{
A_FLAG_WAVE = 0,
A_FLAG_FLIP = 4
};
const Uint16 FLYING_BASEFRAME_EP4 = 174;
const Uint16 FLYING_BASEFRAME_EP5 = 173;
......@@ -23,59 +48,71 @@ CFlag::CFlag(CMap *pmap, const VectorD2<Uint32> &Location,
CGalaxySpriteObject(pmap, FOE_ID, Location.x, Location.y),
m_location(Location),
m_destination(Destination),
m_baseframe(FLYING_BASEFRAME_EP4),
processState(&CFlag::processFlying)
m_baseframe(0)
{
solid = false;
honorPriority = false;
sprite = WAVING_BASEFRAME;
mActionMap[A_FLAG_WAVE] = &CFlag::processWaving;
mActionMap[A_FLAG_FLIP] = &CFlag::processFlipping;
alignToTile();
if(g_pBehaviorEngine->getEpisode() == 5)
const auto episode = g_pBehaviorEngine->getEpisode();
if(episode == 6)
{
setupGalaxyObjectOnMap(0x13F4, A_FLAG_FLIP);
}
else if(episode == 5)
{
// In Episode 5 the sign is not thrown! It just appears in the holder
//m_location = m_destination;
// In Episode 5 the sign is not thrown! It just appears in the holder. Move it there!
moveTo(m_destination);
processState = &CFlag::processRotation;
m_baseframe = FLYING_BASEFRAME_EP5;
sprite = m_baseframe;
setupGalaxyObjectOnMap(0x148A, A_FLAG_WAVE);
}
else
{
setupGalaxyObjectOnMap(0x15EE, A_FLAG_FLIP);
}
alignToTile();
}
void CFlag::getTouchedBy(CSpriteObject &theObject)
{
if(m_baseframe != WAVING_BASEFRAME)
if( getActionNumber(A_FLAG_FLIP) )
return;
// In case another flag is sitting in the pole, make that one non existent
if( CFlag *flag = dynamic_cast<CFlag*>(&theObject) )
{
flag->exists = false;
}
}
void CFlag::setActionForce(const size_t ActionNumber)
{
CGalaxySpriteObject::setActionForce(ActionNumber);
if( mActionMap.find(ActionNumber) != mActionMap.end() )
processState = mActionMap[ActionNumber];
else
CGalaxySpriteObject::setActionForce(0); // This might happen, when the action-map is incomplete
}
/**
* Main process cycle
*/
void CFlag::process()
{
(this->*processState)();
processActionRoutine();
(this->*processState)();
}
/**
* Called when Flag is flying to the pole
*/
void CFlag::processFlying()
void CFlag::processFlipping()
{
if(mp_Map->getAnimtiletimer()%ANIMATION_TIME == 0)
{
if(sprite-m_baseframe >= 4)
sprite = m_baseframe;
else
sprite++;
}
if(m_destination != m_location)
{
VectorD2<int> dir = m_destination - m_location;
......@@ -94,9 +131,8 @@ void CFlag::processFlying()
}
else
{
processState = &CFlag::processWaving;
m_baseframe = WAVING_BASEFRAME;
g_pSound->playSound( SOUND_FLAG_LAND );
setAction(A_FLAG_WAVE);
g_pSound->playSound( SOUND_FLAG_LAND );
}
}
......@@ -104,15 +140,7 @@ void CFlag::processFlying()
* Called when flag is in the pole. Keen 4 or 6
*/
void CFlag::processWaving()
{
if(mp_Map->getAnimtiletimer()%ANIMATION_TIME == 0)
{
if(sprite-m_baseframe >= 3)
sprite = m_baseframe;
else
sprite++;
}
}
{}
/*
* Called when sign is in the holder. Keen 5 normally
......
......@@ -31,16 +31,19 @@ public:
// The flag is flying when player throws it.
// It's waving all the time being stuck on the pole.
void process();
void processFlying();
void processFlipping();
void processWaving();
void processRotation();
void setActionForce(const size_t ActionNumber);
private:
// Where the flag/sign will pop in
VectorD2<Uint32> m_location;
VectorD2<Uint32> m_destination;
Uint16 m_baseframe;
void (CFlag::*processState)();
void (CFlag::*processState)();
std::map< size_t, void (CFlag::*)() > mActionMap;
};
......
......@@ -802,7 +802,7 @@ void CPlayerWM::startLevel(Uint16 object)
* makes the player finish the level
*/
void CPlayerWM::finishLevel(Uint16 object)
{
{
// if a door or other blocker was found remove it
int x, y;
Uint16 door = object + 0xD000;
......@@ -818,6 +818,7 @@ void CPlayerWM::finishLevel(Uint16 object)
if(mp_Map->findTile(flag_dest, &x, &y, 2))
{
// spawn the flag
const auto episode = g_pBehaviorEngine->getEpisode();
VectorD2<Uint32> src(getXPosition(), getYPosition());
// Here we move the coordinates in order get it positioned correctly in the pole
......@@ -827,13 +828,17 @@ void CPlayerWM::finishLevel(Uint16 object)
unsigned int csfY = (y<<CSF);
csfX += (6<<STC);
csfY -= FlagSprite.m_bboxY2;
if(episode != 5)
csfY -= FlagSprite.m_bboxY2;
csfY += (2<<STC);
if(g_pBehaviorEngine->getEpisode() == 5)
{
csfX -= (14<<STC);
csfY -= (1<<CSF);
if(episode != 5)
csfY -= (1<<CSF);
}
else
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment