Example #1
0
void restartMatch(void)
{
    gettimeofday(&Initial_Timer, NULL);

    MatrixCoord startGraphCoord = MatrixCoord(0, 0);
    MatrixCoord goalGraphCoord = MatrixCoord(Graph_Space.size().x-1, Graph_Space.size().y-1);

    for (unsigned int i=0; i<Player_List.size(); ++i) {
        if (Player_List[i]) {
            delete Player_List[i];
        }
    }
    Player_List.clear();
    Player_List = std::vector<PlayerBase*>(Config_Info.playerConfigs.size());

    float runSpeed = 0.2f;

    for (unsigned int i=0; i<Config_Info.playerConfigs.size(); ++i) {
        if (Config_Info.playerConfigs[i].type == HUMAN) {
            human = new Human(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed,
                              startGraphCoord, goalGraphCoord, Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"),
                              glmaze.aabb, Tilesize);
            Player_List[i] = human;
            humanIndex = i;
        }
        else if (Config_Info.playerConfigs[i].type == AI_DFS) {
            Player_List[i] = new AIRobot(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed,
                                         Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"),
                                         randomDFSPath(Graph_Space, startGraphCoord, goalGraphCoord), Tilesize);
        }
        else if (Config_Info.playerConfigs[i].type == AI_SMART) {
            Player_List[i] = new AIRobot(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed,
                                         Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"),
                                         smartEnhancePath(randomDFSPath(Graph_Space, startGraphCoord, goalGraphCoord)), Tilesize);
        }
        else if (Config_Info.playerConfigs[i].type == AI_DUMB) {
            Player_List[i] = new AIRobot(Config_Info.playerConfigs[i].name, Config_Info.playerConfigs[i].color, runSpeed,
                                         Resources_Manager.mesh("robot.obj"), Resources_Manager.texture("comp.tga"),
                                         dumbPath(Graph_Space, startGraphCoord, goalGraphCoord), Tilesize);
        }
    }
    finishedPlayers = std::vector<int>(Config_Info.playerConfigs.size(), 0);

    glm::vec3 startcone = tileSpaceToWorldSpace(MatrixCoord(1,1), Tilesize, Tilesize/2.0f);
    glm::vec3 endcone = tileSpaceToWorldSpace(tileSpace.size()-MatrixCoord(2,2), Tilesize, Tilesize/2.0f);
    cone1 = Cone(Resources_Manager.mesh("cone.obj"), Resources_Manager.texture("startmark.tga"), startcone);
    cone2 = Cone(Resources_Manager.mesh("cone.obj"), Resources_Manager.texture("finishmark.tga"), endcone);

    winners.clear();
    toggleCameraButton->show = false;
    Camera_Mode = humanIndex;

}