예제 #1
0
    void EndGame(bool win)
    {
        // unlocks the cursor before leaving the scene, to be able to click buttons
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        // Remember that we need to load the appropriate end scene after a delay
        gameIsEnding = true;
        endGameFadeCanvasGroup.gameObject.SetActive(true);
        if (win)
        {
            m_SceneToLoad          = winSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // play a sound on win
            var audioSource = gameObject.AddComponent <AudioSource>();
            audioSource.clip                  = victorySound;
            audioSource.playOnAwake           = false;
            audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
            audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);

            // create a game message
            var message = Instantiate(WinGameMessagePrefab).GetComponent <DisplayMessage>();
            if (message)
            {
                message.delayBeforeShowing = delayBeforeWinMessage;
                message.GetComponent <Transform>().SetAsLastSibling();
            }
        }
        else
        {
            m_SceneToLoad          = loseSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay;
        }
    }
예제 #2
0
        void Awake()
        {
            var emissionModule = SteamVfx.emission;

            emissionModule.rateOverTimeMultiplier = 0f;

            m_OverheatingRenderersData = new List <RendererIndexData>();
            foreach (var renderer in GetComponentsInChildren <Renderer>(true))
            {
                for (int i = 0; i < renderer.sharedMaterials.Length; i++)
                {
                    if (renderer.sharedMaterials[i] == OverheatingMaterial)
                    {
                        m_OverheatingRenderersData.Add(new RendererIndexData(renderer, i));
                    }
                }
            }

            m_OverheatMaterialPropertyBlock = new MaterialPropertyBlock();
            m_SteamVfxEmissionModule        = SteamVfx.emission;

            m_Weapon = GetComponent <WeaponController>();
            DebugUtility.HandleErrorIfNullGetComponent <WeaponController, OverheatBehavior>(m_Weapon, this, gameObject);

            m_AudioSource      = gameObject.AddComponent <AudioSource>();
            m_AudioSource.clip = CoolingCellsSound;
            m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.WeaponOverheat);
        }
예제 #3
0
    void EndGame(bool win)
    {
        // unlocks the cursor before leaving the scene, to be able to click buttons
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        m_TimeManager.StopRace();

        // Remember that we need to load the appropriate end scene after a delay
        gameState = win ? GameState.Won : GameState.Lost;

        //endGameFadeCanvasGroup.gameObject.SetActive(true);  // desactivo el fade, no hay que cambiar de escena

        //SE GANA
        if (win)
        {
            m_SceneToLoad          = winSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // play a sound on win
            var audioSource = gameObject.AddComponent <AudioSource>();
            audioSource.clip                  = victorySound;
            audioSource.playOnAwake           = false;
            audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
            audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);

            // create a game message
            winDisplayMessage.delayBeforeShowing = delayBeforeWinMessage;
            winDisplayMessage.gameObject.SetActive(true);

            // best time of the current Session
            bestTime = timeDisplay.GetSessionBestLapTime();

            // Si has superado el tiempo previo o no hay tiempo previo registrado
            if (bestTime < previousBestTime || previousBestTime < 0)
            {
                //Se guarda el tiempo como MEJOR tiempo
                PlayerPrefs.SetFloat("BestTime", bestTime);
            }

            //Actualizo y registro las monedas
            totalCoins += karts[0].temporalCoins;
            print(totalCoins);
            PlayerPrefs.SetInt("Coins", totalCoins);
        }

        //SE PIERDE
        else
        {
            m_SceneToLoad          = loseSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // create a game message
            loseDisplayMessage.delayBeforeShowing = delayBeforeWinMessage;
            loseDisplayMessage.gameObject.SetActive(true);
        }
    }
예제 #4
0
    void EndGame(bool win)
    {
        // unlocks the cursor before leaving the scene, to be able to click buttons
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        // Remember that we need to load the appropriate end scene after a delay
        gameIsEnding = true;
        endGameFadeCanvasGroup.gameObject.SetActive(true);
        if (win)
        {
            // Set next scene to play next in build settings. Set to main menu if all levels finished.
            // If Replay Level is checked, level won't advance. Used for testing.
            if (!ReplayScene)
            {
                nextSceneIndex = SceneManager.GetActiveScene().buildIndex + 1;
                if (nextSceneIndex > SceneManager.sceneCountInBuildSettings - 1)
                {
                    Debug.Log("Index " + nextSceneIndex + " is out of bounds. Returning to Main Menu.");
                    nextSceneIndex = 0;
                }
            }
            else
            {
                nextSceneIndex = SceneManager.GetActiveScene().buildIndex;
            }

            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // play a sound on win
            var audioSource = gameObject.AddComponent <AudioSource>();
            audioSource.clip                  = victorySound;
            audioSource.playOnAwake           = false;
            audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
            audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);

            // create a game message
            var message = Instantiate(WinGameMessagePrefab).GetComponent <DisplayMessage>();
            if (message)
            {
                message.delayBeforeShowing = delayBeforeWinMessage;
                message.GetComponent <Transform>().SetAsLastSibling();
            }
        }
        else
        {
            // Set next scene to load to replay active scene
            nextSceneIndex = SceneManager.GetActiveScene().buildIndex;

            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay;
        }
    }
    void Start()
    {
        m_WeaponController = GetComponent <WeaponController>();
        DebugUtility.HandleErrorIfNullGetComponent <WeaponController, RailgunEffectsHandler>(m_WeaponController, this, gameObject);

        // The charge effect needs it's own AudioSources, since it will play on top of the other gun sounds
        m_AudioSource                       = gameObject.AddComponent <AudioSource>();
        m_AudioSource.clip                  = chargeSound;
        m_AudioSource.playOnAwake           = false;
        m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.BossAttack_Railgun);

        m_WasWeaponCharging = false;
    }
예제 #6
0
    void PlaySound(AudioClip sound)
    {
        if (!sound)
        {
            return;
        }

        if (!m_AudioSource)
        {
            m_AudioSource = gameObject.AddComponent <AudioSource>();
            m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDObjective);
        }

        m_AudioSource.PlayOneShot(sound);
    }
    void Awake()
    {
        //チャージエフェクトは他の銃の音の上で再生されるため、独自のAudioSourceが必要です
        m_AudioSource                       = gameObject.AddComponent <AudioSource>();
        m_AudioSource.clip                  = chargeSound;
        m_AudioSource.playOnAwake           = false;
        m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.WeaponChargeBuildup);

        // 2番目のオーディオソースを作成し、遅延してサウンドを再生します
        m_AudioSourceLoop                       = gameObject.AddComponent <AudioSource>();
        m_AudioSourceLoop.clip                  = loopChargeWeaponSFX;
        m_AudioSourceLoop.playOnAwake           = false;
        m_AudioSourceLoop.loop                  = true;
        m_AudioSourceLoop.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.WeaponChargeLoop);
    }
    void Awake()
    {
        // The charge effect needs it's own AudioSources, since it will play on top of the other gun sounds
        m_AudioSource                       = gameObject.AddComponent <AudioSource>();
        m_AudioSource.clip                  = chargeSound;
        m_AudioSource.playOnAwake           = false;
        m_AudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.WeaponChargeBuildup);

        // create a second audio source, to play the sound with a delay
        m_AudioSourceLoop                       = gameObject.AddComponent <AudioSource>();
        m_AudioSourceLoop.clip                  = loopChargeWeaponSFX;
        m_AudioSourceLoop.playOnAwake           = false;
        m_AudioSourceLoop.loop                  = true;
        m_AudioSourceLoop.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.WeaponChargeLoop);
    }
예제 #9
0
    void Awake()
    {
        m_CurrentAmmo        = maxAmmo;
        m_LastMuzzlePosition = weaponMuzzle.position;

        m_ShootAudioSource = GetComponent <AudioSource>();
        DebugUtility.HandleErrorIfNullGetComponent <AudioSource, WeaponController>(m_ShootAudioSource, this, gameObject);

        if (useContinuousShootSound)
        {
            m_continuousShootAudioSource                       = gameObject.AddComponent <AudioSource>();
            m_continuousShootAudioSource.playOnAwake           = false;
            m_continuousShootAudioSource.clip                  = continuousShootLoopSFX;
            m_continuousShootAudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.WeaponShoot);
            m_continuousShootAudioSource.loop                  = true;
        }
    }
예제 #10
0
    void EndGame(bool win)
    {
        // unlocks the cursor before leaving the scene, to be able to click buttons
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;

        m_TimeManager.StopRace();

        // Remember that we need to load the appropriate end scene after a delay
        gameState = win ? GameState.Won : GameState.Lost;
        endGameFadeCanvasGroup.gameObject.SetActive(true);
        if (win)//!!!
        {
            if (WC.winningPlayer == 1)
            {
                m_SceneToLoad = winP1SceneName;
            }
            else
            {
                m_SceneToLoad = winP2SceneName;
            }
            //m_SceneToLoad = winSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // play a sound on win
            var audioSource = gameObject.AddComponent <AudioSource>();
            audioSource.clip                  = victorySound;
            audioSource.playOnAwake           = false;
            audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
            audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);

            // create a game message
            winDisplayMessage.delayBeforeShowing = delayBeforeWinMessage;
            winDisplayMessage.gameObject.SetActive(true);
        }
        else
        {
            m_SceneToLoad          = loseSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // create a game message
            loseDisplayMessage.delayBeforeShowing = delayBeforeWinMessage;
            loseDisplayMessage.gameObject.SetActive(true);
        }
    }
 void EndGame(bool win)
 {
     mainAudio.Stop();
     Debug.Log("EndGame");
     Cursor.lockState = CursorLockMode.None;
     Cursor.visible   = true;
     m_TimeManager.StopRace();
     //Remember that we need to load the appropriate end scene after a delay
     gameState = win ? GameState.Won : GameState.Lost;
     endGameFadeCanvasGroup.gameObject.SetActive(true);
     if (win) //이겼을 때
     {
         m_SceneToLoad          = winSceneName;
         m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack; //씬 딜레이 시간
         // play a sound on win                                                                                 // play a sound on win
         var audioSource = gameObject.AddComponent <AudioSource>();
         audioSource.clip                  = victorySound;
         audioSource.playOnAwake           = false;
         audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
         audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);
         // create a game message
         winDisplayMessage.delayBeforeShowing = delayBeforeWinMessage;
         winDisplayMessage.gameObject.SetActive(true); //이겼다는 메세지 true
     }
     else
     {
         m_SceneToLoad          = loseSceneName;
         m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;
         var deFeataudioSource = gameObject.AddComponent <AudioSource>();
         deFeataudioSource.clip                  = defeatSound;
         deFeataudioSource.playOnAwake           = false;
         deFeataudioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
         deFeataudioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);
         // create a game message
         loseDisplayMessage.delayBeforeShowing = delayBeforeWinMessage;
         loseDisplayMessage.gameObject.SetActive(true);
     }
 }
예제 #12
0
    private void HandleWin(Hashtable arg0)
    {
        Timer.timerIsRunning = false;

        // unlocks the cursor before leaving the scene, to be able to click buttons
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;
        // Remember that we need to load the appropriate end scene after a delay
        gameIsEnding = true;
        endGameFadeCanvasGroup.gameObject.SetActive(true);

        Debug.Log("WIN GAME");

        m_SceneToLoad          = winSceneName;
        m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

        // play a sound on win
        var audioSource = gameObject.AddComponent <AudioSource>();

        audioSource.clip                  = victorySound;
        audioSource.playOnAwake           = false;
        audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
        audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);
    }