Ejemplo n.º 1
0
    public override void OnShow()
    {
        base.OnShow();
        this.HighlightOption(this.FindFirstSelectable());

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }

        if (buttonNetwork != null)
        {
            buttonNetwork.interactable = UFE.isNetworkAddonInstalled;
        }

        if (buttonBluetooth != null)
        {
            buttonBluetooth.interactable = UFE.isNetworkAddonInstalled && Application.isMobilePlatform;
        }
    }
Ejemplo n.º 2
0
    protected override void OnGamePaused(bool isPaused)
    {
        base.OnGamePaused(isPaused);

        if (this.pauseScreen != null)
        {
            if (isPaused)
            {
                this.pause = (UFEScreen)GameObject.Instantiate(this.pauseScreen);
                this.pause.transform.SetParent(UFE.canvas != null ? UFE.canvas.transform : null, false);
                this.pause.OnShow();
            }
            else if (this.pause != null)
            {
                if (!this.hiding)
                {
                    AudioClip clip = this.GetStageMusic(UFE.config.selectedStage);
                    if (clip != null)
                    {
                        UFE.PlayMusic(clip);
                    }
                }

                this.pause.OnHide();
                GameObject.Destroy(this.pause.gameObject);
            }
        }
    }
Ejemplo n.º 3
0
    protected virtual void OnGameBegin(CharacterInfo player1, CharacterInfo player2, StageOptions stage)
    {
        this.player1.character = player1;
        UFE.updatedLifePoints  = UFE.config.player1Character.currentLifePoints;
//
//		if (UFE.lifepointsCheck == true) {
//			this.player1.targetLife = UFE.updatedLifePoints;
//			this.player1.totalLife = 500.0f;
//		} else {
        this.player1.targetLife = PlayerPrefs.GetFloat("HEALTH");
        this.player1.totalLife  = 500.0f;
//		}
        this.player1.wonRounds = 0;

        this.player2.character  = player2;
        this.player2.targetLife = player2.lifePoints;
        this.player2.totalLife  = player2.lifePoints;
        this.player2.wonRounds  = 0;

        UFE.PlayMusic(stage.music);
        this.isRunning = true;

// making application pause to show popups for buying weapons

        if (IntroScreen.characterValue == 2 || IntroScreen.characterValue == 3 || IntroScreen.characterValue == 4 || IntroScreen.characterValue == 5 || IntroScreen.characterValue <= 13 || IntroScreen.characterValue == 18 || IntroScreen.characterValue == 19 || IntroScreen.characterValue == 20 || IntroScreen.characterValue == 21)
        {
            Invoke("pauseFn", 5f);
        }
        else
        {
        }
    }
Ejemplo n.º 4
0
    public override void OnShow()
    {
        base.OnShow();
        this.HighlightOption(this.FindFirstSelectable());

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }
    }
Ejemplo n.º 5
0
    protected virtual void OnGameBegin(UFE3D.CharacterInfo player1, UFE3D.CharacterInfo player2, StageOptions stage)
    {
        this.player1.character  = player1;
        this.player1.targetLife = player1.lifePoints;
        this.player1.totalLife  = player1.lifePoints;
        this.player1.wonRounds  = 0;

        this.player2.character  = player2;
        this.player2.targetLife = player2.lifePoints;
        this.player2.totalLife  = player2.lifePoints;
        this.player2.wonRounds  = 0;

        UFE.PlayMusic(stage.music);
        this.isRunning = true;
    }
    public override void OnShow()
    {
        base.OnShow();

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.sound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.sound); }, this.delayBeforePlayingMusic);
        }

        UFE.DelaySynchronizedAction(this.GoToNextScreen, this.delayBeforeLoadingNextScreen);
    }
    public override void OnShow()
    {
        base.OnShow();

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }
    }
Ejemplo n.º 8
0
    public override void OnShow()
    {
        base.OnShow();
        this.HighlightOption(this.FindFirstSelectable());

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }

        if (myInfoText != null)
        {
            myInfoText.text = "IP: " + GetIp() + "\nPort: " + UFE.config.networkOptions.port;
        }
    }
Ejemplo n.º 9
0
    protected virtual void OnGameBegin(CharacterInfo player1, CharacterInfo player2, StageOptions stage)
    {
        this.player1.character  = player1;
        this.player1.targetLife = player1.lifePoints;
        this.player1.totalLife  = player1.lifePoints;
        this.player1.wonRounds  = 0;

        this.player2.character  = player2;
        this.player2.targetLife = player2.lifePoints;
        this.player2.totalLife  = player2.lifePoints;
        this.player2.wonRounds  = 0;

        AudioClip clip = this.GetStageMusic(stage);

        if (clip != null)
        {
            UFE.PlayMusic(clip);
        }

        this.isRunning = true;
    }
    public override void OnShow()
    {
        base.OnShow();
        this.visible = true;

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }

        if (this.musicToggle != null)
        {
            this.musicToggle.isOn = UFE.config.music;
        }

        if (this.musicSlider != null)
        {
            this.musicSlider.value = UFE.config.musicVolume;
        }

        if (this.soundToggle != null)
        {
            this.soundToggle.isOn = UFE.config.soundfx;
        }

        if (this.soundSlider != null)
        {
            this.soundSlider.value = UFE.config.soundfxVolume;
        }

        int difficultySettingsLength    = UFE.config.aiOptions.difficultySettings.Length;
        AIDifficultySettings difficulty = UFE.GetAIDifficulty();

        if (this.difficultySlider != null)
        {
            this.difficultySlider.minValue     = 0;
            this.difficultySlider.maxValue     = difficultySettingsLength - 1;
            this.difficultySlider.wholeNumbers = true;
            this.difficultySlider.value        = this.GetDifficultyIndex(difficulty);
        }

        if (this.difficultyName != null)
        {
            this.difficultyName.text = difficulty.difficultyLevel.ToString();
        }

        if (this.aiEngineName != null)
        {
            AIEngine aiEngine = UFE.GetAIEngine();

            if (aiEngine == AIEngine.RandomAI)
            {
                this.aiEngineName.text = "Random";
            }
            else
            {
                this.aiEngineName.text = "Fuzzy";
            }
        }

        if (this.debugModeToggle != null)
        {
            this.debugModeToggle.isOn = UFE.config.debugOptions.debugMode;
        }

        if (this.diagnosticModeToggle != null)
        {
            GameObject nameObj = GameObject.Find("Name");
            if (nameObj != null)
            {
                NameHolder name = nameObj.GetComponent <NameHolder>();
                if (name != null)
                {
                    this.diagnosticModeToggle.isOn = name.diagnosticMode;
                }
                else
                {
                    Debug.Log("Could not find nameholder script");
                }
            }
            else
            {
                Debug.Log("Could not find name object");
            }
        }
        if (this.changeControlsButton != null)
        {
            this.changeControlsButton.gameObject.SetActive(
                UFE.isCInputInstalled && UFE.config.inputOptions.inputManagerType == InputManagerType.cInput
                );
        }

        this.HighlightOption(this.FindFirstSelectable());
    }
Ejemplo n.º 11
0
    protected override void OnRoundEnd(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser)
    {
        base.OnRoundEnd(winner, loser);

        // Find out who is the winner and who is the loser...
        int            winnerPlayer         = winner == this.player1.character ? 1 : 2;
        int            loserPlayer          = loser == this.player1.character ? 1 : 2;
        PlayerGUI      winnerGUI            = winnerPlayer == 1 ? this.player1GUI : this.player2GUI;
        PlayerGUI      loserGUI             = loserPlayer == 1 ? this.player1GUI : this.player2GUI;
        ControlsScript winnerControlsScript = UFE.GetControlsScript(winnerPlayer);

        // Then update the "Won Rounds" sprites...
        if (this.wonRounds.NotFinishedRounds == null)
        {
            Debug.LogError("\"Not Finished Rounds\" Sprite not found! Make sure you have set the sprite correctly in the Editor");
        }
        else if (this.wonRounds.WonRounds == null)
        {
            Debug.LogError("\"Won Rounds\" Sprite not found! Make sure you have set the sprite correctly in the Editor");
        }
        else if (this.wonRounds.LostRounds == null && this.wonRounds.VisibleImages == DefaultBattleGUI.VisibleImages.AllRounds)
        {
            Debug.LogError("\"Lost Rounds\" Sprite not found! If you want to display Lost Rounds, make sure you have set the sprite correctly in the Editor");
        }
        else
        {
            // To calculate the target number of images, check if the "Lost Rounds" Sprite is defined or not
            int targetNumberOfImages = this.wonRounds.GetNumberOfRoundsImages();

            if (this.wonRounds.VisibleImages == DefaultBattleGUI.VisibleImages.AllRounds)
            {
                // If the "Lost Rounds" sprite is defined, that means that we must display all won and lost rounds...
                if (
                    winnerGUI != null &&
                    winnerGUI.wonRoundsImages != null &&
                    winnerGUI.wonRoundsImages.Length >= targetNumberOfImages
                    )
                {
                    winnerGUI.wonRoundsImages[UFE.config.currentRound - 1].sprite = this.wonRounds.WonRounds;
                }
                else
                {
                    Debug.LogError(
                        "Player " + winnerPlayer + ": not enough \"Won Rounds\" Images not found! " +
                        "Expected:" + targetNumberOfImages + " / Found: " + winnerGUI.wonRoundsImages.Length +
                        "\nMake sure you have set the images correctly in the Editor"
                        );
                }

                if (
                    loserGUI != null &&
                    loserGUI.wonRoundsImages != null &&
                    loserGUI.wonRoundsImages.Length >= targetNumberOfImages
                    )
                {
                    loserGUI.wonRoundsImages[UFE.config.currentRound - 1].sprite = this.wonRounds.LostRounds;
                }
                else
                {
                    Debug.LogError(
                        "Player " + winnerPlayer + ": not enough \"Won Rounds\" Images not found! " +
                        "Expected:" + targetNumberOfImages + " / Found: " + winnerGUI.wonRoundsImages.Length +
                        "\nMake sure you have set the images correctly in the Editor"
                        );
                }
            }
            else
            {
                // If the "Lost Rounds" sprite is not defined, that means that we must only display won rounds...
                if (
                    winnerGUI != null &&
                    winnerGUI.wonRoundsImages != null &&
                    winnerGUI.wonRoundsImages.Length >= winnerControlsScript.roundsWon
                    )
                {
                    winnerGUI.wonRoundsImages[winnerControlsScript.roundsWon - 1].sprite = this.wonRounds.WonRounds;
                }
                else if (UFE.gameMode != GameMode.ChallengeMode)
                {
                    Debug.LogError(
                        "Player " + winnerPlayer + ": not enough \"Won Rounds\" Images not found! " +
                        "Expected:" + targetNumberOfImages + " / Found: " + winnerGUI.wonRoundsImages.Length +
                        "\nMake sure you have set the images correctly in the Editor"
                        );
                }
            }
        }

        if (this.announcer != null && !this.muteAnnouncer)
        {
            // Check if it was the last round
            if (winnerControlsScript.roundsWon > Mathf.Ceil(UFE.config.roundOptions.totalRounds / 2))
            {
                if (winnerPlayer == 1)
                {
                    UFE.PlaySound(this.announcer.player1Wins);
                }
                else
                {
                    UFE.PlaySound(this.announcer.player2Wins);
                }
            }

            // Finally, check if we should play any AudioClip
            if (winnerControlsScript.myInfo.currentLifePoints == winnerControlsScript.myInfo.lifePoints)
            {
                UFE.PlaySound(this.announcer.perfect);
            }
        }

        if (winnerControlsScript.myInfo.currentLifePoints == winnerControlsScript.myInfo.lifePoints)
        {
            this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.perfect, winnerControlsScript), null);
        }

        if (UFE.gameMode != GameMode.ChallengeMode &&
            winnerControlsScript.roundsWon > Mathf.Ceil(UFE.config.roundOptions.totalRounds / 2))
        {
            this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.victory, winnerControlsScript), null);
            UFE.PlayMusic(UFE.config.roundOptions.victoryMusic);
        }
        else if (UFE.gameMode == GameMode.ChallengeMode)
        {
            this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.challengeEnds, winnerControlsScript), null);
            UFE.PlayMusic(UFE.config.roundOptions.victoryMusic);
        }
    }
    public override void OnShow()
    {
        base.OnShow();

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }

        if (UFE.config.player1Character != null)
        {
            if (this.portraitPlayer1 != null)
            {
                this.portraitPlayer1.sprite = Sprite.Create(
                    UFE.config.player1Character.profilePictureBig,
                    new Rect(0f, 0f, UFE.config.player1Character.profilePictureBig.width, UFE.config.player1Character.profilePictureBig.height),
                    new Vector2(0.5f * UFE.config.player1Character.profilePictureBig.width, 0.5f * UFE.config.player1Character.profilePictureBig.height)
                    );
            }

            if (this.namePlayer1 != null)
            {
                this.namePlayer1.text = UFE.config.player1Character.characterName;
            }
        }

        if (UFE.config.player2Character != null)
        {
            if (this.portraitPlayer2 != null)
            {
                this.portraitPlayer2.sprite = Sprite.Create(
                    UFE.config.player2Character.profilePictureBig,
                    new Rect(0f, 0f, UFE.config.player2Character.profilePictureBig.width, UFE.config.player2Character.profilePictureBig.height),
                    new Vector2(0.5f * UFE.config.player2Character.profilePictureBig.width, 0.5f * UFE.config.player2Character.profilePictureBig.height)
                    );
            }

            if (this.namePlayer2 != null)
            {
                this.namePlayer2.text = UFE.config.player2Character.characterName;
            }
        }

        this.stageHoverIndex = 0;
        StageOptions stage = UFE.config.stages[this.stageHoverIndex];

        if (stage != null)
        {
            if (this.screenshotStage != null)
            {
                this.screenshotStage.sprite = Sprite.Create(
                    stage.screenshot,
                    new Rect(0f, 0f, stage.screenshot.width, stage.screenshot.height),
                    new Vector2(0.5f * stage.screenshot.width, 0.5f * stage.screenshot.height)
                    );
            }

            if (this.nameStage != null)
            {
                this.nameStage.text = stage.stageName;
            }
        }
    }
    public override void OnShow()
    {
        base.OnShow();

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforeMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforeMusic);
        }

        if (UFE.config.player1Character != null)
        {
            if (this.portraitPlayer1 != null)
            {
                this.portraitPlayer1.sprite = Sprite.Create(
                    UFE.config.player1Character.profilePictureBig,
                    new Rect(0f, 0f, UFE.config.player1Character.profilePictureBig.width, UFE.config.player1Character.profilePictureBig.height),
                    new Vector2(0.5f * UFE.config.player1Character.profilePictureBig.width, 0.5f * UFE.config.player1Character.profilePictureBig.height)
                    );
            }

            if (this.namePlayer1 != null)
            {
                this.namePlayer1.text = UFE.config.player1Character.characterName;
            }
        }

        if (UFE.config.player2Character != null)
        {
            if (this.portraitPlayer2 != null)
            {
                this.portraitPlayer2.sprite = Sprite.Create(
                    UFE.config.player2Character.profilePictureBig,
                    new Rect(0f, 0f, UFE.config.player2Character.profilePictureBig.width, UFE.config.player2Character.profilePictureBig.height),
                    new Vector2(0.5f * UFE.config.player2Character.profilePictureBig.width, 0.5f * UFE.config.player2Character.profilePictureBig.height)
                    );
            }

            if (this.namePlayer2 != null)
            {
                this.namePlayer2.text = UFE.config.player2Character.characterName;
            }
        }

        if (UFE.config.selectedStage != null)
        {
            if (this.screenshotStage != null)
            {
                this.screenshotStage.sprite = Sprite.Create(
                    UFE.config.selectedStage.screenshot,
                    new Rect(0f, 0f, UFE.config.selectedStage.screenshot.width, UFE.config.selectedStage.screenshot.height),
                    new Vector2(0.5f * UFE.config.selectedStage.screenshot.width, 0.5f * UFE.config.selectedStage.screenshot.height)
                    );

                Animator anim = this.screenshotStage.GetComponent <Animator>();
                if (anim != null)
                {
                    anim.enabled = UFE.gameMode != GameMode.StoryMode;
                }
            }

            /*if (this.nameStage != null){
             *      this.nameStage.text = UFE.config.selectedStage.stageName;
             * }*/
        }

        UFE.DelaySynchronizedAction(UFE.PreloadBattle, this.delayBeforePreload);

        UFE.DelaySynchronizedAction(this.StartBattle, this.delayBeforePreload + UFE.config.preloadingTime + this.delayAfterPreload);
    }
Ejemplo n.º 14
0
    public override void OnShow()
    {
        // We add these lines before base.OnShow() because they will affect how will the engine display
        // characters selected by default
        Camera.main.transform.position    = UFE.config.cameraOptions.initialDistance;
        Camera.main.transform.eulerAngles = UFE.config.cameraOptions.initialRotation;
        Camera.main.fieldOfView           = UFE.config.cameraOptions.initialFieldOfView;
        if (this.displayMode == DisplayMode.CharacterGameObject)
        {
            if (background3dPrefab != null)
            {
                this.background = GameObject.Instantiate(background3dPrefab);
            }

            UFE.canvas.planeDistance = 0.1f;
            UFE.canvas.worldCamera   = Camera.main;
            UFE.canvas.renderMode    = RenderMode.ScreenSpaceCamera;
        }

        base.OnShow();
        this.characterButtonsWhiteList.Clear();

        // Set the portraits of the characters
        if (this.characters != null)
        {
            // First, update the portraits of the characters until we run out of characters or portrait slots....
            for (int i = 0; i < this.selectableCharacters.Length && i < this.characters.Length; ++i)
            {
                Image         character           = this.characters[i];
                CharacterInfo selectableCharacter = this.selectableCharacters[i];

                if (character != null)
                {
                    character.gameObject.SetActive(true);
                    character.sprite = Sprite.Create(
                        selectableCharacter.profilePictureSmall,
                        new Rect(0f, 0f, selectableCharacter.profilePictureSmall.width, selectableCharacter.profilePictureSmall.height),
                        new Vector2(0.5f * selectableCharacter.profilePictureSmall.width, 0.5f * selectableCharacter.profilePictureSmall.height)
                        );

                    Button button = character.GetComponent <Button>();
                    if (button == null)
                    {
                        button = character.gameObject.AddComponent <Button>();
                    }

                    int index = i;
                    button.onClick.AddListener(() => { this.TrySelectCharacter(index); });
                    button.targetGraphic = character;
                    this.characterButtonsWhiteList.Add(button);
                }
            }

            // If there are more slots than characters, fill the remaining slots with the "No Character" sprite...
            // If the "No Character" sprite is undefined, hide the image instead.
            for (int i = this.selectableCharacters.Length; i < this.characters.Length; ++i)
            {
                Image character = this.characters[i];
                if (character != null)
                {
                    if (this.noCharacterSprite != null)
                    {
                        this.characters[i].gameObject.SetActive(true);
                        this.characters[i].sprite = this.noCharacterSprite;
                    }
                    else
                    {
                        this.characters[i].gameObject.SetActive(false);
                    }
                }
            }
        }

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }

        this.SetHoverIndex(1, Mathf.Clamp(this.defaultCharacterPlayer1, 0, this.selectableCharacters.Length - 1));
        if (UFE.gameMode == GameMode.StoryMode)
        {
            if (this.namePlayer2 != null)
            {
                this.namePlayer2.text = "???";
            }

            if (this.portraitPlayer2 != null)
            {
                this.portraitPlayer2.gameObject.SetActive(false);
            }

            this.UpdateHud();
        }
        else
        {
            this.SetHoverIndex(2, Mathf.Clamp(this.defaultCharacterPlayer2, 0, this.selectableCharacters.Length - 1));

            if (this.portraitPlayer2 != null)
            {
                this.portraitPlayer2.gameObject.SetActive(true);
            }
        }
    }
Ejemplo n.º 15
0
    public override void OnShow()
    {
        // Set the portraits of the characters
        if (this.characters != null)
        {
            // First, update the portraits of the characters until we run out of characters or portrait slots....
            CharacterInfo[] selectableCharacters = this.GetSelectableCharacters();
            for (int i = 0; i < selectableCharacters.Length && i < this.characters.Length; ++i)
            {
                this.characters[i].gameObject.SetActive(true);
                this.characters[i].sprite = Sprite.Create(
                    selectableCharacters[i].profilePictureSmall,
                    new Rect(0f, 0f, selectableCharacters[i].profilePictureSmall.width, selectableCharacters[i].profilePictureSmall.height),
                    new Vector2(0.5f * selectableCharacters[i].profilePictureSmall.width, 0.5f * selectableCharacters[i].profilePictureSmall.height)
                    );
            }

            // If there are more slots than characters, fill the remaining slots with the "No Character" sprite...
            // If the "No Character" sprite is undefined, hide the image instead.
            for (int i = selectableCharacters.Length; i < this.characters.Length; ++i)
            {
                if (this.noCharacterSprite != null)
                {
                    this.characters[i].gameObject.SetActive(true);
                    this.characters[i].sprite = this.noCharacterSprite;
                }
                else
                {
                    this.characters[i].gameObject.SetActive(false);
                }
            }
        }

        base.OnShow();

        if (this.music != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic);
        }

        if (this.stopPreviousSoundEffectsOnLoad)
        {
            UFE.StopSounds();
        }

        if (this.onLoadSound != null)
        {
            UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic);
        }

        if (UFE.gameMode == GameMode.StoryMode)
        {
            if (this.namePlayer2 != null)
            {
                this.namePlayer2.text = "???";
            }

            if (this.portraitPlayer2 != null)
            {
                this.portraitPlayer2.gameObject.SetActive(false);
            }

            this.UpdateHud();
        }
        else
        {
            this.SetHoverIndex(2, Mathf.Min(this.GetHoverIndex(2), this.charactersPerRow - 1));

            if (this.portraitPlayer2 != null)
            {
                this.portraitPlayer2.gameObject.SetActive(true);
            }
        }
    }
Ejemplo n.º 16
0
    protected virtual IEnumerator LoadMovie()
    {
        // Start loading movie from disk...
        string url =
            this.otherPlatformsPath
            .Replace(VideoIntroScreen.Data, Application.dataPath)
            .Replace(VideoIntroScreen.Persistent, Application.persistentDataPath)
            .Replace(VideoIntroScreen.StreamingAssets, Application.streamingAssetsPath)
            .Replace(VideoIntroScreen.Temp, Application.temporaryCachePath);


        WWW          www   = new WWW(url);
        MovieTexture movie = www.movie;

        // Assign the movie to a GUITexture...
        GUITexture guiTexture = this.GetComponent <GUITexture>();

        if (guiTexture == null)
        {
            guiTexture = this.gameObject.AddComponent <GUITexture>();
        }

        AudioClip audio = movie.audioClip;

        guiTexture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
        guiTexture.texture    = movie;

        // Wait the min delay before starting playing the video
        if (this.delayBeforePlayingVideo > 0)
        {
            guiTexture.color = Color.black;
            yield return(new WaitForSeconds(this.delayBeforePlayingVideo));
        }
        guiTexture.color = Color.white;

        // Wait until we have enough information to start playing the movie...
        while (!movie.isReadyToPlay)
        {
            yield return(null);
        }

        // When we're ready to start playing the image, resize the texture
        guiTexture.pixelInset = new Rect(0.5f * Screen.width, 0.5f * Screen.height, 0f, 0f);

        // Start playing the movie
        movie.Play();

        //-------------------------------------------------------------------------------------------------------------
        // We need to enable the sound during the duration of the movie because it doesn't matter the user settings,
        // we want him to hear the AudioClip. However, we need to play this sound as music because Unity won't allow
        // us to play streamed audio as SoundFX (Unity doesn't throw an error, but the AudioClip isn't played).
        //-------------------------------------------------------------------------------------------------------------
        bool      musicEnabled = UFE.GetMusic();
        bool      musicLooped  = UFE.IsMusicLooped();
        float     musicVolume  = UFE.GetMusicVolume();
        AudioClip clip         = UFE.GetMusicClip();

        UFE.SetMusic(true);
        UFE.LoopMusic(false);
        UFE.SetMusicVolume(1f);

        UFE.PlayMusic(audio);

        //-------------------------------------------------------------------------------------------------------------
        // After the video finish, restore the original audio settings.
        //-------------------------------------------------------------------------------------------------------------
        while (movie.isPlaying && !(skippable && Input.anyKeyDown))
        {
            yield return(null);
        }

        //-------------------------------------------------------------------------------------------------------------
        // Check if the video has been skipped. In that case, wait for the "delay after skipping video" time.
        //-------------------------------------------------------------------------------------------------------------
        if (movie.isPlaying && this.delayAfterSkippingVideo > 0f)
        {
            if (this.stopMusicImmediatelyAfterSkippingVideo)
            {
                UFE.StopMusic();
            }

            if (this.stopVideoImmediatelyAfterSkippingVideo)
            {
                movie.Stop();
                guiTexture.color = Color.black;
            }

            yield return(new WaitForSeconds(this.delayAfterSkippingVideo));
        }

        //-------------------------------------------------------------------------------------------------------------
        // If we haven't done it yet, stop the video, the audio and free the used memory
        //-------------------------------------------------------------------------------------------------------------
        UFE.StopMusic();
        movie.Stop();
        GameObject.DestroyObject(clip);
        GameObject.DestroyObject(movie);

        //-------------------------------------------------------------------------------------------------------------
        // Finally, restore the original audio settings...
        //-------------------------------------------------------------------------------------------------------------
        UFE.SetMusic(musicEnabled);
        UFE.LoopMusic(musicLooped);
        UFE.SetMusicVolume(musicVolume);
        UFE.PlayMusic(clip);

        //-------------------------------------------------------------------------------------------------------------
        // And go to the next screen
        //-------------------------------------------------------------------------------------------------------------
        this.GoToNextScreen();
    }