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();
|
||||
m_display_rank = false;
|
||||
|
||||
m_check_goals_enabled = true;
|
||||
|
||||
// check for possible problems if AI karts were incorrectly added
|
||||
if(getNumKarts() > race_manager->getNumPlayers())
|
||||
{
|
||||
@ -98,6 +100,32 @@ void SoccerWorld::update(float dt)
|
||||
// TODO
|
||||
} // 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.
|
||||
*/
|
||||
@ -172,6 +200,7 @@ bool SoccerWorld::isRaceOver()
|
||||
*/
|
||||
void SoccerWorld::terminateRace()
|
||||
{
|
||||
m_check_goals_enabled = false;
|
||||
updateKartRanks();
|
||||
WorldWithRank::terminateRace();
|
||||
} // terminateRace
|
||||
@ -183,6 +212,8 @@ void SoccerWorld::restartRace()
|
||||
{
|
||||
WorldWithRank::restartRace();
|
||||
|
||||
m_check_goals_enabled = true;
|
||||
|
||||
const unsigned int kart_amount = m_karts.size();
|
||||
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
|
@ -46,6 +46,10 @@ private:
|
||||
*/
|
||||
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:
|
||||
|
||||
/** Used to show a nice graph when battle is over */
|
||||
@ -78,7 +82,7 @@ public:
|
||||
|
||||
virtual void update(float dt);
|
||||
|
||||
|
||||
void onCheckGoalTriggered(bool first_goal);
|
||||
void updateKartRanks();
|
||||
}; // SoccerWorld
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "io/xml_node.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_object_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "modes/soccer_world.hpp"
|
||||
#include <stdio.h>
|
||||
|
||||
/** Constructor for a check goal line.
|
||||
@ -86,34 +86,14 @@ void CheckGoal::update(float dt) OVERRIDE
|
||||
*/
|
||||
void CheckGoal::trigger(unsigned int kart_index)
|
||||
{
|
||||
printf("*** TODO: GOOOOOOOOOAAAAAAALLLLLL!!!! ***\n");
|
||||
|
||||
/*
|
||||
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++)
|
||||
SoccerWorld* world = dynamic_cast<SoccerWorld*>(World::getWorld());
|
||||
if(!world)
|
||||
{
|
||||
TrackObject* obj = objects.get(i);
|
||||
if(!obj->isSoccerBall())
|
||||
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;
|
||||
fprintf(stderr, "WARNING: no soccer world found, cannot count the points\n");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
world->onCheckGoalTriggered(m_first_goal);
|
||||
} // CheckGoal
|
||||
|
||||
bool CheckGoal::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos, int indx)
|
||||
|
@ -135,11 +135,12 @@ public:
|
||||
}
|
||||
|
||||
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*)node)->setNodesRotation(m_init_hpr);
|
||||
((LODNode*)node)->setNodesScale(m_init_scale);
|
||||
((LODNode*)m_node)->setNodesPosition(m_init_xyz);
|
||||
((LODNode*)m_node)->setNodesRotation(m_init_hpr);
|
||||
((LODNode*)m_node)->setNodesScale(m_init_scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user