Exemplo n.º 1
0
void SceneManager::listenerSynchronize(Serializer &s) {
	s.validate("SceneManager");

	if (s.isLoading() && !_globals->_sceneManager._scene)
		// Loading a savegame straight from the launcher, so instantiate a blank placeholder scene
		// in order for the savegame loading to work correctly
		_globals->_sceneManager._scene = new Scene();

	_altSceneObjects.synchronize(s);
	s.syncAsSint32LE(_sceneNumber);
	s.syncAsUint16LE(_globals->_sceneManager._scene->_activeScreenNumber);

	if (s.isLoading()) {
		changeScene(_sceneNumber);
		
		if (_nextSceneNumber != -1) {
			sceneChange();
			_nextSceneNumber = -1;
		}
	}

	_globals->_sceneManager._scrollerRect.synchronize(s);
	SYNC_POINTER(_globals->_scrollFollower);
	s.syncAsSint16LE(_loadMode);
}
Exemplo n.º 2
0
void SceneManager::checkScene() {
	if (_nextSceneNumber != -1) {
		sceneChange();
		_nextSceneNumber = -1;
	}

	_globals->dispatchSounds();
}
Exemplo n.º 3
0
void SceneManager::checkScene() {
	if (_nextSceneNumber != -1) {
		sceneChange();
		_nextSceneNumber = -1;
	}

	Common::for_each(_globals->_sceneListeners.begin(), _globals->_sceneListeners.end(), SceneHandler::dispatchObject);
}
Exemplo n.º 4
0
void SceneManager::checkScene() {
	if (_nextSceneNumber != -1) {
		int nextSceneNumber = _nextSceneNumber;

		sceneChange();

		// Unless we've already switched to yet another scene, reset
		if (_nextSceneNumber == nextSceneNumber)
			_nextSceneNumber = -1;
	}

	g_globals->dispatchSounds();
}
Exemplo n.º 5
0
void CSceneMatch::endOfTheMatch()
{
    if(sGlobal->bMultiplayer && sGlobal->bServer)
    {
        sUDPBuffer[0] = MSG_END;
        cServer->sendMessage(sClientAddress, sUDPBuffer, MSG_SIZE);
    }

    // player 1 wins
    if(cGame->getGoalsPlayer1() == sGlobal->iGameMaxGoals)
    {
        sprintf(sMessage, "Player 1 wins!");
        render();
        Sleep(2000);

        playAgain();
    }

    // player 2 wins
    else if(cGame->getGoalsPlayer2() == sGlobal->iGameMaxGoals)
    {
        sprintf(sMessage, "Player 2 wins!");
        render();
        Sleep(2000);

        playAgain();
    }

    // time over
    else if(iTimeMin == 0 && iTimeSec == 0)
    {
        if(cGame->getGoalsPlayer1() > cGame->getGoalsPlayer2())
            sprintf(sMessage, "Player 1 wins!");
        else if(cGame->getGoalsPlayer2() > cGame->getGoalsPlayer1())
            sprintf(sMessage, "Player 2 wins!");
        else
            sprintf(sMessage, "Draw");

        render();
        Sleep(2000);

        playAgain();
    }

    // ESC key
    else
    {
        sceneChange(SCENE_MENU);
    }
}
Exemplo n.º 6
0
void SceneManager::listenerSynchronize(Serializer &s) {
	s.validate("SceneManager");

	if (s.isLoading() && !g_globals->_sceneManager._scene)
		// Loading a savegame straight from the launcher, so instantiate a blank placeholder scene
		// in order for the savegame loading to work correctly
		g_globals->_sceneManager._scene = new Scene();

	// Depreciated: the background scene objects used to be located here
	uint32 unused = 0;
	s.syncAsUint32LE(unused);

	s.syncAsSint32LE(_sceneNumber);
	s.syncAsUint16LE(g_globals->_sceneManager._scene->_activeScreenNumber);

	if (s.isLoading()) {
		changeScene(_sceneNumber);

		if (_nextSceneNumber != -1) {
			sceneChange();
			_nextSceneNumber = -1;
		}
	}

	// Walk regions loading
	if (g_vm->getGameID() == GType_Ringworld2) {
		int walkRegionsId = GLOBALS._walkRegions._resNum;
		s.syncAsSint16LE(walkRegionsId);
		if (s.isLoading())
			GLOBALS._walkRegions.load(walkRegionsId);
	}

	g_globals->_sceneManager._scrollerRect.synchronize(s);
	SYNC_POINTER(g_globals->_scrollFollower);
	s.syncAsSint16LE(_loadMode);
}
Exemplo n.º 7
0
Arquivo: title.cpp Projeto: maro-n/LS
void title::update() {
  sceneChange();
  if (clickStart()) { return; }
  modeSelect();
}
Exemplo n.º 8
0
void CSceneMenu::selectOption(int iOption)
{
    switch(iCurrentMenu)
    {
    // MAIN
    case MENU_MAIN:

        switch(iOption)
        {
        // Play
        case 0:        
            enterMenu(MENU_PLAY);
            break;

        // Settings
        case 1:
            enterMenu(MENU_SETTINGS);
            break;

        // Exit
        case 2:
            sceneChange(0);
            break;
        }

        break;

    // PLAY
    case MENU_PLAY:

        switch(iOption)
        {
        // Player vs CPU
        case 0:        
            sGlobal->iHumanPlayers = 1;
            sGlobal->bMultiplayer = false;
            sGlobal->bKinect = false;
            sceneChange(SCENE_MATCH);
            break;

        // Multiplayer
        case 1:
            enterMenu(MENU_MULTIPLAYER);
            break;

#ifdef _KINECT_
        // Kinect: Player vs CPU
        case 2:
            sGlobal->iHumanPlayers = 1;
            sGlobal->bMultiplayer = false;
            sGlobal->bKinect = true;
            enterMenu(MENU_KINECT_INFO);
            break;

        // Kinect: Player vs Player
        case 3:
            sGlobal->iHumanPlayers = 2;
            sGlobal->bMultiplayer = false;
            sGlobal->bKinect = true;
            sGlobal->bSplit = true;
            enterMenu(MENU_KINECT_INFO);
            break;
#endif
        }

        break;

    // MULTIPLAYER
    case MENU_MULTIPLAYER:

        switch(iOption)
        {
        // create game
        case 0:
            enterMenu(MENU_MULTIPLAYER_SERVER);
            break;

        // join game
        case 1:
            enterMenu(MENU_MULTIPLAYER_CLIENT);
            break;
        }

        break;

    // MULTIPLAYER - CLIENT
    case MENU_MULTIPLAYER_CLIENT:
        
        // join game
        if(iOption == 2)
        {
            sGlobal->iHumanPlayers = 1;
            sGlobal->bMultiplayer = true;
            sGlobal->bServer = false;

            if(sGlobal->bKinect)
                enterMenu(MENU_KINECT_INFO);
            else
                sceneChange(SCENE_MATCH);
        }

        break;

    // MULTIPLAYER - SERVER
    case MENU_MULTIPLAYER_SERVER:

        // create game
        if(iOption == 1)
        {
            sGlobal->iHumanPlayers = 1;
            sGlobal->bMultiplayer = true;
            sGlobal->bServer = true;

            if(sGlobal->bKinect)
                enterMenu(MENU_KINECT_INFO);
            else
                sceneChange(SCENE_MATCH);
        }

        break;

    // SETTINGS
    case MENU_SETTINGS:

        // AI difficulty
        if(iOption == 5)
            enterMenu(MENU_SETTINGS_DIFFICULTY);

        // Kinect calibration
        else if(iOption == 6)
            enterMenu(MENU_SETTINGS_KINECT);

        break;
    }
}
Exemplo n.º 9
0
void CSceneMenu::inputKey(char Key)
{
#ifdef _KINECT_
    if(iCurrentMenu == MENU_KINECT_INFO)
        sceneChange(SCENE_MATCH);
#endif

    switch(Key)
    {
    case KEY_ESC:

        switch(iCurrentMenu)
        {
        case MENU_MAIN:
            sceneChange(0);
            break;

        case MENU_PLAY:
            enterMenu(MENU_MAIN);
            break;

        case MENU_SETTINGS:
            enterMenu(MENU_MAIN);
            iSelectedOption = 1;
            break;

        case MENU_MULTIPLAYER:
            enterMenu(MENU_PLAY);
            iSelectedOption = 1;
            break;

        case MENU_MULTIPLAYER_SERVER:
            enterMenu(MENU_MULTIPLAYER);
            break;

        case MENU_MULTIPLAYER_CLIENT:
            enterMenu(MENU_MULTIPLAYER);
            iSelectedOption = 1;
            break;

        case MENU_SETTINGS_DIFFICULTY:
            enterMenu(MENU_SETTINGS);
            iSelectedOption = 5;
            break;

        case MENU_SETTINGS_KINECT:
            enterMenu(MENU_SETTINGS);
            iSelectedOption = 6;
            break;
        }

        break;
        
    case KEY_ENTER:

        selectOption(iSelectedOption);        

        break;

    case KEY_BACKSPACE:

        // port
        if((iCurrentMenu == MENU_MULTIPLAYER_SERVER && iSelectedOption == 0) ||
           (iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 1))
        {
            if(strlen(sPort) > 0)
                sPort[strlen(sPort) - 1] = '\0';

            sGlobal->iPort = (strlen(sPort) > 0)? atoi(sPort): 0;

            refreshSettings();        
        }

        // server IP
        else if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) > 0)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) - 1] = '\0';
                refreshSettings();
            }
        }

        break;

    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':

        // port
        if((iCurrentMenu == MENU_MULTIPLAYER_SERVER && iSelectedOption == 0) ||
           (iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 1))
        {
            if(strlen(sPort) < 5)
            {
                sPort[strlen(sPort) + 1] = '\0';
                sPort[strlen(sPort)] = Key;
                sGlobal->iPort = atoi(sPort);
                refreshSettings();
            }
        }

        // server IP
        else if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) < 15)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) + 1] = '\0';
                sGlobal->sIPServer[strlen(sGlobal->sIPServer)] = Key;
                refreshSettings();
            }
        }

        break;

    case -66:   // '.'
        
        // server IP
        if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) < 14)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) + 1] = '\0';
                sGlobal->sIPServer[strlen(sGlobal->sIPServer)] = '.';
                refreshSettings();
            }
        }
        
        break;
        
    case KEY_UP:

        iSelectedOption--;

        if(iSelectedOption < 0)
            iSelectedOption = iNumOptions - 1;

        break;
        
    case KEY_DOWN:

        iSelectedOption++;

        if(iSelectedOption == iNumOptions)
            iSelectedOption = 0;

        break;

    case KEY_LEFT:

        switch(iCurrentMenu)
        {
        // settings
        case MENU_SETTINGS:

            switch(iSelectedOption)
            {
            // goals to win
            case 0:
                if(sGlobal->iGameMaxGoals > 1)
                    sGlobal->iGameMaxGoals--;
                break;

            // maximum time
            case 1:
                if(sGlobal->iGameMaxMinutes > 1)
                    sGlobal->iGameMaxMinutes--;
                break;

            // table air
            case 2:
                sGlobal->bTableAir = !sGlobal->bTableAir;
                break;

            // automatic replay
            case 3:
                sGlobal->bAutomaticReplay = !sGlobal->bAutomaticReplay;
                break;

            // split screen
            case 4:
                sGlobal->bSplit = !sGlobal->bSplit;
                break;
            }

            break;

        // multiplayer
        case MENU_MULTIPLAYER:

            // play with kinect
            if(iSelectedOption == 2)
                sGlobal->bKinect = !sGlobal->bKinect;

            break;

        // AI difficulty settings
        case MENU_SETTINGS_DIFFICULTY:

            switch(iSelectedOption)
            {
            // speed for shooting
            case 0:
                if(iPercentShooting > 0)
                    iPercentShooting--;
                break;

            // speed for defending
            case 1:
                if(iPercentDefending > 0)
                    iPercentDefending--;
                break;

            // speed for clearing
            case 2:
                if(iPercentClearing > 0)
                    iPercentClearing--;
                break;

            // attack/defense balance
            case 3:
                if(iPercentAttack > 0)
                    iPercentAttack--;
                break;
            }

            calculateDifficultyValues();

            break;

        // kinect settings
        case MENU_SETTINGS_KINECT:

            switch(iSelectedOption)
            {
            // table width
            case 0:
                if(sGlobal->fKinectWidth > (KINECT_WIDTH_MIN / 2))
                    sGlobal->fKinectWidth -= 5.0f;
                break;

            // minimum distance
            case 1:
                if(sGlobal->fKinectMinimumDistance > KINECT_MINDIST_MIN)
                    sGlobal->fKinectMinimumDistance -= 10.0f;
                break;

            // maximum distance
            case 2:
                if(sGlobal->fKinectMaximumDistance > KINECT_MAXDIST_MIN)
                {
                    sGlobal->fKinectMaximumDistance -= 10.0f;

                    if(sGlobal->fKinectMaximumDistance < sGlobal->fKinectMinimumDistance)
                        sGlobal->fKinectMinimumDistance = sGlobal->fKinectMaximumDistance;
                }
                break;

            // player 1 hand
            case 3:
                sGlobal->bPlayer1RightHanded = !sGlobal->bPlayer1RightHanded;
                break;

            // player 2 hand
            case 4:
                sGlobal->bPlayer2RightHanded = !sGlobal->bPlayer2RightHanded;
                break;
            }

            break;
        }

        refreshSettings();

        break;

    case KEY_RIGHT:

        switch(iCurrentMenu)
        {
        // settings
        case MENU_SETTINGS:

            switch(iSelectedOption)
            {
            // goals to win
            case 0:
                if(sGlobal->iGameMaxGoals < GAME_MAX_GOALS)
                    sGlobal->iGameMaxGoals++;
                break;

            // maximum time
            case 1:
                if(sGlobal->iGameMaxMinutes < GAME_MAX_MINUTES)
                    sGlobal->iGameMaxMinutes++;
                break;

            // table air
            case 2:
                sGlobal->bTableAir = !sGlobal->bTableAir;
                break;

            // automatic replay
            case 3:
                sGlobal->bAutomaticReplay = !sGlobal->bAutomaticReplay;
                break;

            // split screen
            case 4:
                sGlobal->bSplit = !sGlobal->bSplit;
                break;
            }

            break;

        // multiplayer
        case MENU_MULTIPLAYER:

            // play with kinect
            if(iSelectedOption == 2)
                sGlobal->bKinect = !sGlobal->bKinect;

            break;

        // AI difficulty settings
        case MENU_SETTINGS_DIFFICULTY:

            switch(iSelectedOption)
            {
            // speed for shooting
            case 0:
                if(iPercentShooting < 100)
                    iPercentShooting++;
                break;

            // speed for defending
            case 1:
                if(iPercentDefending < 100)
                    iPercentDefending++;
                break;

            // speed for clearing
            case 2:
                if(iPercentClearing < 100)
                    iPercentClearing++;
                break;

            // attack/defense balance
            case 3:
                if(iPercentAttack < 100)
                    iPercentAttack++;
                break;
            }

            calculateDifficultyValues();

            break;

        // kinect settings
        case MENU_SETTINGS_KINECT:

            switch(iSelectedOption)
            {
            // table width
            case 0:
                if(sGlobal->fKinectWidth < (KINECT_WIDTH_MAX / 2))
                    sGlobal->fKinectWidth += 5.0f;
                break;

            // minimum distance
            case 1:
                if(sGlobal->fKinectMinimumDistance < KINECT_MINDIST_MAX)
                {
                    sGlobal->fKinectMinimumDistance += 10.0f;

                    if(sGlobal->fKinectMinimumDistance > sGlobal->fKinectMaximumDistance)
                        sGlobal->fKinectMaximumDistance = sGlobal->fKinectMinimumDistance;
                }
                break;

            // maximum distance
            case 2:
                if(sGlobal->fKinectMaximumDistance < KINECT_MAXDIST_MAX)
                    sGlobal->fKinectMaximumDistance += 10.0f;
                break;

            // player 1 hand
            case 3:
                sGlobal->bPlayer1RightHanded = !sGlobal->bPlayer1RightHanded;
                break;

            // player 2 hand
            case 4:
                sGlobal->bPlayer2RightHanded = !sGlobal->bPlayer2RightHanded;
                break;
            }

            break;
        }

        refreshSettings();

        break;
    }
}
//----------------------------------------------------------------------------
//  Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsInit
//
/// Implementation of JNI function to initilize the simulation and start the
/// first scene.
///
/// @param  env     Pointer to JNI environment
//----------------------------------------------------------------------------
void
Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsInit( JNIEnv*  env )
{
    init();
    sceneChange();
}
//----------------------------------------------------------------------------
//  Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeSceneChange
//
/// Implementation of JNI function to change to the next scene.
///
/// @param  env     Pointer to JNI environment
//----------------------------------------------------------------------------
void
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeSceneChange( JNIEnv*  env )
{
    sceneChange();
}