Esempio n. 1
0
    // Update GGPS Leaderboards when game is over
    public void GGPS_GameEndManagement(int gameMode, int score, int level)
    {
        // Call GGPS to add the score
        GGPS_Manager.GGPS_AddScore(gameMode, score);

        // Call GGPS to add the best level eached in Unlimited mode
        GGPS_Manager.GGPS_AddBestUnlimitedLevel(gameMode, level);
    }
Esempio n. 2
0
    //////////////////////////////////////////////////////////////////////////////////
    // Update is called once per frame
    //////////////////////////////////////////////////////////////////////////////////
    void Update()
    {
        carafeObject sourceCarafe;
        carafeObject destinationCarafe;
        string       timeStr;

        timeStr = myUniqueController.timeMngt();
        if (timeStr == null)
        {
            // GAME OVER : Timeout !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            SoundManager.gameSoundManager.PlaySound(SoundManager.SOUND_GAME_OVER);

            // Save score in GGPS (and level)
            GGPS_GameEndManagement(myUniqueController.getGameMode(), myUniqueController.getScore(), myUniqueController.getCurrenLevel());

            // Come back to main screen
            SceneManager.LoadScene("StartMenu");
        }
        else
        {
            // Check if bip for last 3 seconds
            BipForLast3Seconds();
        }

        // Update score text
        SetTextValue(timeStr);

        // MOUSE BUTTON DOWN
        if (Input.GetMouseButtonDown(0))
        {
            // Get the position when the mouse button was DOWN
            posDown = getMouseClick();
            // And get echiquier position
            clickPosDown = getEchiquerClick(posDown);
            SoundManager.gameSoundManager.PlaySound(SoundManager.SOUND_CLICK);
        }

        // MOUSE BUTTON UP
        if (Input.GetMouseButtonUp(0))
        {
            // Get the position when the mouse button was UP
            posUp = getMouseClick();
            int n = GetCadran(posDown, posUp);
            clickPosUp = GetPositionFromCadran(clickPosDown, n);

            // We have to load new Recipient and unload current one
            if ((GetPositionBoundaries(clickPosUp) == false) || (GetPositionBoundaries(clickPosDown) == false))
            {
                return;
            }

            sourceCarafe = theCases[clickPosDown.x, clickPosDown.y].getCaseCarafe();
            if (sourceCarafe.getCarafeVolume() == AllGameParameters.VOLUME_0)
            {
                return;
            }

            // Check if loading FinalCarafe
            if (checkFinalCarafeMovement())
            {
                // Yes, we load FinaleCarafe
                SoundManager.gameSoundManager.PlaySound(SoundManager.SOUND_COIN);

                int remainingVolume;
                remainingVolume = theFinalCarafe.loadCarafe(sourceCarafe.getCarafeVolume(), sourceCarafe.getCarafeColor());
                sourceCarafe.unloadCarafe(remainingVolume);

                // Check if carafe is ACID type
                if (sourceCarafe.getCarafeType() == AllGameParameters.LIQUID_TYPE_ACID)
                {
                    sourceCarafe.setCarafeVolume(AllGameParameters.VOLUME_0);
                    sourceCarafe.setCarafeType(AllGameParameters.LIQUID_TYPE_WATER);
                }
                if (theFinalCarafe.getCarafeVolume() >= 0)
                {
                    theFinalCarafe.setCarafeType(AllGameParameters.LIQUID_TYPE_WATER);
                }
                else
                {
                    // If volume is negative, it is an ACID bottle
                    theFinalCarafe.setCarafeType(AllGameParameters.LIQUID_TYPE_ACID);
                }

                // Update the display
                UpdateCarafeInPosition(sourceCarafe, clickPosDown.x, clickPosDown.y);
                UpdateFinalCarafe();

                // CHECK IF PLAYER HAS WIN !
                if ((theFinalCarafe.getCarafeColor() == theFinalCarafeTarget.getCarafeColor()) && (theFinalCarafe.getCarafeVolume() == theFinalCarafeTarget.getCarafeVolume()))
                {
                    // LEVEL FINISHED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    SoundManager.gameSoundManager.PlaySound(SoundManager.SOUND_FINISH);

                    // Give score (depends on remaining time)
                    myUniqueController.setTimeValue();
                    myUniqueController.increaseScore(myUniqueController.giveScoreBonus());

                    // Check if an Achievement (trophe) can be done for the time
                    GGPS_Manager.GGPS_GainTimeAchievement(myUniqueController.getPassedTimeInSecondsWithDecimal());

                    // Increment current Level value
                    myUniqueController.incrementCurrenLevel();

                    // Check if an Achievement (trophe) can be done for the level reached
                    GGPS_Manager.GGPS_GainAchievement(myUniqueController.getGameMode(), myUniqueController.getCurrenLevel());

                    // Save last reached level in Campaign mode
                    if (myUniqueController.getGameMode() == AllGameParameters.GAME_MODE_CAMPAIGN)
                    {
                        int curLevel = myUniqueController.getCurrenLevel();

                        // Debug.Log ("FINISHED !! - cureLevel=" + curLevel + " - currentlyReachedLevel=" + SettingsParameters.currentlyReachedLevel);
                        if (curLevel >= SettingsParameters.currentlyReachedLevel)
                        {
                            // Save new game level
                            SettingsParameters.currentlyReachedLevel = curLevel;
                        }

                        // Save parameters in persistant data
                        SettingsParameters.SaveSettings();

                        // Check if we reached last Screen in Campaign mode
                        if (curLevel == SettingsParameters.LEVEL_NUMBER)
                        {
                            // We reached last level ==> Finished
                            SceneManager.LoadScene("FinishScreen");
                            return;
                        }
                    }

                    // Load WaiScreen scene
                    SceneManager.LoadScene("WaitScreen");
                }

                return;
            }

            // Check if movement is possible (just around current position)
            if (checkMovement())
            {
                // Determine the source & destination carafes
                sourceCarafe      = theCases[clickPosDown.x, clickPosDown.y].getCaseCarafe();
                destinationCarafe = theCases[clickPosUp.x, clickPosUp.y].getCaseCarafe();

                // Check if source of destination is a WALL, in this case nothing happens
                if ((sourceCarafe.getCarafeType() == AllGameParameters.LIQUID_TYPE_WALL) || (destinationCarafe.getCarafeType() == AllGameParameters.LIQUID_TYPE_WALL))
                {
                    return;
                }

                // movement is OK
                SoundManager.gameSoundManager.PlaySound(SoundManager.SOUND_COIN);

                // We have to load new Recipient and unload current one
                int remainingVolume;
                remainingVolume = destinationCarafe.loadCarafe(sourceCarafe.getCarafeVolume(), sourceCarafe.getCarafeColor());
                sourceCarafe.unloadCarafe(remainingVolume);

                // Check if carafe is ACID type
                if (sourceCarafe.getCarafeType() == AllGameParameters.LIQUID_TYPE_ACID)
                {
                    sourceCarafe.setCarafeVolume(AllGameParameters.VOLUME_0);
                    sourceCarafe.setCarafeType(AllGameParameters.LIQUID_TYPE_WATER);
                }
                if (destinationCarafe.getCarafeVolume() >= 0)
                {
                    destinationCarafe.setCarafeType(AllGameParameters.LIQUID_TYPE_WATER);
                }
                else
                {
                    // If volume is negative, it is an ACID bottle
                    destinationCarafe.setCarafeType(AllGameParameters.LIQUID_TYPE_ACID);
                }

                // Update the display
                UpdateCarafeInPosition(sourceCarafe, clickPosDown.x, clickPosDown.y);
                UpdateCarafeInPosition(destinationCarafe, clickPosUp.x, clickPosUp.y);

                myUniqueController.increaseScore(1);
            }
            else
            {
                // Debug.LogWarning ("MOV KO"); // TO REMOVE
                clickPosDown = resetPosition();
                clickPosUp   = resetPosition();
            }
        }
    }