Now teleporting the soccer ball at its start position when scoring a point
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/christmas@12314 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
14f7f080c0
commit
cd28f9128a
@ -50,6 +50,8 @@ void SoccerWorld::init()
|
|||||||
WorldWithRank::init();
|
WorldWithRank::init();
|
||||||
m_display_rank = false;
|
m_display_rank = false;
|
||||||
|
|
||||||
|
m_check_goals_enabled = true;
|
||||||
|
|
||||||
// check for possible problems if AI karts were incorrectly added
|
// check for possible problems if AI karts were incorrectly added
|
||||||
if(getNumKarts() > race_manager->getNumPlayers())
|
if(getNumKarts() > race_manager->getNumPlayers())
|
||||||
{
|
{
|
||||||
@ -98,6 +100,32 @@ void SoccerWorld::update(float dt)
|
|||||||
// TODO
|
// TODO
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
|
void SoccerWorld::onCheckGoalTriggered(bool first_goal)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
if(m_check_goals_enabled)
|
||||||
|
printf("*** GOOOOOOOOOAAAAAAALLLLLL!!!! (team: %d) ***\n", first_goal ? 0 : 1);
|
||||||
|
|
||||||
|
//m_check_goals_enabled = false; // TODO: remove?
|
||||||
|
|
||||||
|
// Reset original positions for the soccer balls
|
||||||
|
TrackObjectManager* tom = getTrack()->getTrackObjectManager();
|
||||||
|
assert(tom);
|
||||||
|
|
||||||
|
PtrVector<TrackObject>& objects = tom->getObjects();
|
||||||
|
for(int i=0; i<objects.size(); i++)
|
||||||
|
{
|
||||||
|
TrackObject* obj = objects.get(i);
|
||||||
|
if(!obj->isSoccerBall())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
obj->reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: rescue the karts
|
||||||
|
// TODO: score a point
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Updates the ranking of the karts.
|
/** Updates the ranking of the karts.
|
||||||
*/
|
*/
|
||||||
@ -172,6 +200,7 @@ bool SoccerWorld::isRaceOver()
|
|||||||
*/
|
*/
|
||||||
void SoccerWorld::terminateRace()
|
void SoccerWorld::terminateRace()
|
||||||
{
|
{
|
||||||
|
m_check_goals_enabled = false;
|
||||||
updateKartRanks();
|
updateKartRanks();
|
||||||
WorldWithRank::terminateRace();
|
WorldWithRank::terminateRace();
|
||||||
} // terminateRace
|
} // terminateRace
|
||||||
@ -183,6 +212,8 @@ void SoccerWorld::restartRace()
|
|||||||
{
|
{
|
||||||
WorldWithRank::restartRace();
|
WorldWithRank::restartRace();
|
||||||
|
|
||||||
|
m_check_goals_enabled = true;
|
||||||
|
|
||||||
const unsigned int kart_amount = m_karts.size();
|
const unsigned int kart_amount = m_karts.size();
|
||||||
|
|
||||||
for(unsigned int n=0; n<kart_amount; n++)
|
for(unsigned int n=0; n<kart_amount; n++)
|
||||||
|
@ -46,6 +46,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
std::vector<SoccerInfo> m_kart_info;
|
std::vector<SoccerInfo> m_kart_info;
|
||||||
|
|
||||||
|
/** Whether or not goals can be scored (they are disabled when a point is scored
|
||||||
|
and re-enabled when the next game can be played)*/
|
||||||
|
bool m_check_goals_enabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Used to show a nice graph when battle is over */
|
/** Used to show a nice graph when battle is over */
|
||||||
@ -78,7 +82,7 @@ public:
|
|||||||
|
|
||||||
virtual void update(float dt);
|
virtual void update(float dt);
|
||||||
|
|
||||||
|
void onCheckGoalTriggered(bool first_goal);
|
||||||
void updateKartRanks();
|
void updateKartRanks();
|
||||||
}; // SoccerWorld
|
}; // SoccerWorld
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
#include "tracks/track_object_manager.hpp"
|
#include "tracks/track_object_manager.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/soccer_world.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/** Constructor for a check goal line.
|
/** Constructor for a check goal line.
|
||||||
@ -86,34 +86,14 @@ void CheckGoal::update(float dt) OVERRIDE
|
|||||||
*/
|
*/
|
||||||
void CheckGoal::trigger(unsigned int kart_index)
|
void CheckGoal::trigger(unsigned int kart_index)
|
||||||
{
|
{
|
||||||
printf("*** TODO: GOOOOOOOOOAAAAAAALLLLLL!!!! ***\n");
|
SoccerWorld* world = dynamic_cast<SoccerWorld*>(World::getWorld());
|
||||||
|
if(!world)
|
||||||
/*
|
|
||||||
World *world = World::getWorld();
|
|
||||||
assert(world);
|
|
||||||
Track* track = world->getTrack();
|
|
||||||
assert(track);
|
|
||||||
TrackObjectManager* tom = track->getTrackObjectManager();
|
|
||||||
assert(tom);
|
|
||||||
PtrVector<TrackObject>& objects = tom->getObjects();
|
|
||||||
for(unsigned int i=0; i<objects.size(); i++)
|
|
||||||
{
|
{
|
||||||
TrackObject* obj = objects.get(i);
|
fprintf(stderr, "WARNING: no soccer world found, cannot count the points\n");
|
||||||
if(!obj->isSoccerBall())
|
return;
|
||||||
continue;
|
|
||||||
|
|
||||||
const Vec3 &xyz = obj->getNode()->getPosition();
|
|
||||||
// Only check active goal lines.
|
|
||||||
if(m_is_active[i] && isTriggered(m_previous_position[i], xyz, i))
|
|
||||||
{
|
|
||||||
if(UserConfigParams::m_check_debug)
|
|
||||||
printf("CHECK: Goal check structure %d triggered for object %s.\n",
|
|
||||||
m_index, obj->getDebugName());
|
|
||||||
trigger(i);
|
|
||||||
}
|
|
||||||
m_previous_position[i] = xyz;
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
world->onCheckGoalTriggered(m_first_goal);
|
||||||
} // CheckGoal
|
} // CheckGoal
|
||||||
|
|
||||||
bool CheckGoal::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx)
|
bool CheckGoal::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx)
|
||||||
|
@ -135,11 +135,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_node = node;
|
m_node = node;
|
||||||
if (node->getType() == irr::scene::ESNT_LOD_NODE)
|
|
||||||
|
if (m_node->getType() == irr::scene::ESNT_LOD_NODE)
|
||||||
{
|
{
|
||||||
((LODNode*)node)->setNodesPosition(m_init_xyz);
|
((LODNode*)m_node)->setNodesPosition(m_init_xyz);
|
||||||
((LODNode*)node)->setNodesRotation(m_init_hpr);
|
((LODNode*)m_node)->setNodesRotation(m_init_hpr);
|
||||||
((LODNode*)node)->setNodesScale(m_init_scale);
|
((LODNode*)m_node)->setNodesScale(m_init_scale);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user