private void AudioDesplegado()
 {
     //cerrar el menu si se le da a escape
     if (InputManager.instance.cancelButton || InputManager.instance.cancelButton2)
     {
         goingTo      = OptionsState.CERRAR;
         currentState = OptionsState.REPLEGANDO_AUDIO;
         foreach (GameObject go in menuElements)
         {
             go.SetActive(false);
         }
     }
     MenuNav();
 }
 private void DesplegandoAudio()
 {
     if (transformBG.localPosition.y > originalBgPos.y)
     {
         transformBG.localPosition -= new Vector3(0, scrollSpeed, 0);
     }
     else
     {
         transformBG.localPosition = originalBgPos;
         currentState = OptionsState.AUDIO_DESPLEGADO;
         menuElements[0].SetActive(true);
         menuElements[2].SetActive(true);
         menuElements[3].SetActive(true);
     }
 }
    public void ClickAceptar()
    {
        if (currentState == OptionsState.AUDIO_DESPLEGADO)
        {
            currentState = OptionsState.REPLEGANDO_AUDIO;
            goingTo      = OptionsState.CERRAR;
            foreach (GameObject g in menuElements)
            {
                g.SetActive(false);
            }
        }
        else if (currentState == OptionsState.VIDEO_DESPLEGADO)
        {
            currentState = OptionsState.REPLEGANDO_VIDEO;
            goingTo      = OptionsState.CERRAR;
            foreach (GameObject g in menuElements)
            {
                g.SetActive(false);
            }
        }

        //se le pasan los valores de configuración al gamelogic y se actualizan los valores previos
        GameLogic.instance.musicVolume   = prevMusic = musica.value;
        GameLogic.instance.sfxVolume     = prevSfx = sfx.value;
        GameLogic.instance.muteVolume    = prevMute = mute.isOn;
        GameLogic.instance.mostrarTiempo = prevMostrarTiempo = mostrarTiempo.isOn;
        GameLogic.instance.fullscreen    = pantallaCompleta.isOn;
        prevResolution = resolutionSel;
        GameLogic.instance.resolutionSelected = resolutions[resolutionSel];
        prevFps = fpsSel;
        GameLogic.instance.maxFrameRate = fpsList[fpsSel];
        GameLogic.instance.graficos     = prevQuality = qualitySel;

        GameLogic.instance.ChangeGameSettings();

        Debug.Log("SetFloat " + musica.value);
        PlayerPrefs.SetFloat("musicVolume", musica.value);
        PlayerPrefs.SetFloat("sfxVolume", sfx.value);

        Debug.Log("Setting mostratTiempo as" + mostrarTiempo.isOn);
        PlayerPrefs.SetInt("mostrarTiempo", BoolToInt(mostrarTiempo.isOn));
        PlayerPrefs.SetFloat("resolutionSelectedX", resolutions[resolutionSel].x);
        PlayerPrefs.SetFloat("resolutionSelectedY", resolutions[resolutionSel].y);
        PlayerPrefs.SetInt("maxFrameRate", fpsList[fpsSel]);
        PlayerPrefs.SetInt("graficos", qualitySel);
        PlayerPrefs.SetInt("Language", (int)GameLogic.instance.currentLanguage);
    }
 public void ClickVideo()
 {
     if (currentState == OptionsState.AUDIO_DESPLEGADO)
     {
         currentState = OptionsState.REPLEGANDO_AUDIO;
         goingTo      = OptionsState.VIDEO_DESPLEGADO;
         foreach (GameObject g in menuElements)
         {
             g.SetActive(false);
         }
         transformSetaAudio.localPosition  = originalSetaAudioPos;
         transformSetaVideo.localPosition += new Vector3(0, setaOffset, 0);
         currentItem.highlight.SetActive(false);
         currentItem = firstVideo;
         currentItem.highlight.SetActive(true);
     }
 }
 private void ReplegandoAudio()
 {
     if (transformBG.localPosition.y < originalBgPos.y + bgOffset)
     {
         transformBG.localPosition += new Vector3(0, scrollSpeed, 0);
     }
     else
     {
         if (goingTo == OptionsState.CERRAR)
         {
             gameObject.SetActive(false);
         }
         else
         {
             currentState = OptionsState.DESPLEGANDO_VIDEO;
         }
     }
 }
    void Start()
    {
        currentState = OptionsState.DESPLEGANDO_AUDIO;
        goingTo      = OptionsState.VIDEO_DESPLEGADO;
        foreach (GameObject g in menuElements)
        {
            g.SetActive(false);
        }

        //se activa el highlight del primer elemento de navegacion con mando/teclado
        currentItem = firstAudio;
        currentItem.highlight.SetActive(true);

        SoundManager.Instance.ChangeMusicVolume(musica.value);

        musica.onValueChanged.AddListener(delegate {
            if (!mute.isOn)
            {
                SoundManager.Instance.ChangeMusicVolume(musica.value);
            }
        });
        sfx.onValueChanged.AddListener(delegate {
            if (!mute.isOn)
            {
                SoundManager.Instance.ChangeFXVolume(sfx.value);
            }
        });
        mute.onValueChanged.AddListener(delegate {
            if (mute.isOn)
            {
                SoundManager.Instance.ChangeMusicVolume(0);
                SoundManager.Instance.ChangeFXVolume(0);
            }
            else
            {
                SoundManager.Instance.ChangeMusicVolume(musica.value);
                SoundManager.Instance.ChangeFXVolume(sfx.value);
            }
        });

        //fix del bug por el que los sliders se movian sin tenerlos seleccionados.
        FindObjectOfType <EventSystem>().sendNavigationEvents = false;
    }
        public void Update(GameTime gameTime)
        {
            currentPosition = (OptionsState)controls.MoveOptionPositionVertically((int)currentPosition);

            switch (currentPosition)
            {
            case OptionsState.StartServer:
                controls.ContinueButton(GameManager.GameState.MultiplayerStartServer);
                break;

            case OptionsState.StartClient:
                controls.ContinueButton(GameManager.GameState.MultiplayerConnectServer);
                break;

            case OptionsState.Back:
                controls.ContinueButton(GameManager.GameState.MainMenu);
                break;
            }
            //controls.GoBackButton();
        }
Beispiel #8
0
        // Updates. When the players clicks continue we go to
        // the next state that is specified in the switch case,
        // depending on which option we currently are at.
        public void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.M))
            {
                AudioManager.Instance.PlaySound("disaster");
            }
            if (!AudioManager.Instance.IsPlaying)
            {
                AudioManager.Instance.PlayNextInQueue(gameTime);
            }

            currentPosition = (OptionsState)controls.MoveOptionPositionVertically((int)currentPosition);

            switch (currentPosition)
            {
            case OptionsState.Exit:
                controls.ContinueButton(GameManager.GameState.Quit);
                break;
            }
        }
 public void ClickCancelar()
 {
     if (currentState == OptionsState.AUDIO_DESPLEGADO)
     {
         currentState = OptionsState.REPLEGANDO_AUDIO;
         goingTo      = OptionsState.CERRAR;
         foreach (GameObject g in menuElements)
         {
             g.SetActive(false);
         }
     }
     else if (currentState == OptionsState.VIDEO_DESPLEGADO)
     {
         currentState = OptionsState.REPLEGANDO_VIDEO;
         goingTo      = OptionsState.CERRAR;
         foreach (GameObject g in menuElements)
         {
             g.SetActive(false);
         }
     }
 }
Beispiel #10
0
        public void Update(GameTime gameTime)
        {
            CheckServerName();
            currentPosition = (OptionsState)controls.MoveOptionPositionVertically((int)currentPosition);

            switch (currentPosition)
            {
            case OptionsState.FindServer:
                controls.SearchForServerButton(networkConnectionManager);
                break;

            case OptionsState.ConnectedTo:

            case OptionsState.Play:
                controls.ContinueButton(GameManager.GameState.MultiplayerPlaying);
                break;

            case OptionsState.Back:
                controls.ContinueButton(GameManager.GameState.MainMenu);
                break;
            }
        }
Beispiel #11
0
        public void Update(GameTime gameTime)
        {
            CheckServerName();
            currentPosition = (OptionsState)controls.MoveOptionPositionVertically((int)currentPosition);

            switch (currentPosition)
            {
            case OptionsState.StartServer:
                controls.StartServerButton(networkConnectionManager);
                break;

            case OptionsState.ServerName:

            case OptionsState.StartMatch:
                controls.ContinueButton(GameManager.GameState.MultiplayerPlaying);
                break;

            case OptionsState.Back:
                controls.GoBackButton(peer: networkConnectionManager.GetPeer());
                break;
            }
        }
Beispiel #12
0
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            this.RegisterGlobalComponent(new AudioManager(this.Game, @"Content\Audio\RpgAudio.xgs", @"Content\Audio\Wave Bank.xwb", @"Content\Audio\Sound Bank.xsb"));
            _SceneManager  = new SceneManager();
            _MainMenuState = new MainMenuState();
            _PausedState   = new PausedState();
            _OptionsState  = new OptionsState();
//#if DEBUG
//            AudioManager.Instance.MusicEnabled = false;
//#endif
            // Start off in game.
            //_SceneManager.ChangeScene("BasicLevel", false);
            //StateManager.PushState(_SceneManager);
            StateManager.PushState(_MainMenuState);
            AudioManager.PlayMusic("Title1");
            AudioManager.SetMusicVolume(0.5f);
            CreateNewPlayer();
            GraphicsManager.ApplyChanges();

//#if DEBUG
            _SceneManager.AddComponent(new DebugComponent(_SceneManager));
//#endif
        }
Beispiel #13
0
 public OptionsScreen(GameScreen before)
 {
     screenBefore = before;
     OptionsState = TDA3Game.OptionsState.Normal;
 }
Beispiel #14
0
        void sound_LeftClickEvent(object sender, EventArgs e)
        {
            if (OptionsState == TDA3Game.OptionsState.Normal)
            {
                Button b = sender as Button;
                b.Texture = activeButtonTexture;
                Vector2 pos = new Vector2((int)(soundBlock.Dimensions.Left + b.Texture.Width), (int)(soundBlock.Dimensions.Top + b.Texture.Height));
                b.Position = pos;
                b.ButtonText.Position = new Vector2(pos.X - (b.Texture.Width / 2) + 10, pos.Y - (b.Texture.Height / 2));
                b.SetColor(Selected);

                soundBlock.GetText("SoundInstructions").Value = "Press the Up or Down arrow keys to change the value.\nClick the button again to deselect.";
                soundBlock.GetText("SoundInstructions").Position = new Vector2(b.Rectangle.Right + 10, b.ButtonText.Position.Y);

                OptionsState = TDA3Game.OptionsState.Sound;
            }
            else if (OptionsState == TDA3Game.OptionsState.Sound)
            {
                Button b = sender as Button;
                b.Texture = inactiveButtonTexture;
                Vector2 pos = new Vector2((int)(soundBlock.Dimensions.Left + b.Texture.Width), (int)(soundBlock.Dimensions.Top + b.Texture.Height));
                b.Position = pos;
                b.ButtonText.Position = new Vector2(pos.X - (b.Texture.Width / 2) + 10, pos.Y - (b.Texture.Height / 2));
                b.SetColor(Normal);

                soundBlock.GetText("SoundInstructions").Value = "Select the Sound button to change settings";
                soundBlock.GetText("SoundInstructions").Position = new Vector2(b.Position.X + (b.Texture.Width / 2) + 10, b.ButtonText.Position.Y);

                OptionsState = TDA3Game.OptionsState.Normal;
            }
        }
Beispiel #15
0
 public OptionsScreen(GameScreen before)
 {
     screenBefore = before;
     OptionsState = TowerDefense.OptionsState.Normal;
 }
Beispiel #16
0
 public KeyBindOption(Game.Game game, OptionsState menu, Bind binding)
 {
     m_game    = game;
     m_menu    = menu;
     m_binding = binding;
 }
 public void SetOptionState(string option, OptionsState state)
 {
     _Options[option] = state;
 }
    private IEnumerator ChangeUsernameCoroutine(string usernameStr)
    {
        string cachedUsername = ParseUser.CurrentUser.Username;
        ParseUser.CurrentUser.Username = usernameStr;
        Task changeTask = ParseUser.CurrentUser.SaveAsync ();

        DateTime startTime = DateTime.UtcNow;
        TimeSpan waitDuration = TimeSpan.FromSeconds(TimeUtils.TIMEOUT_DURATION);
        while (!changeTask.IsCompleted)
        {
            if(DateTime.UtcNow - startTime >= waitDuration)
                break;

            yield return null;
        }

        if(!changeTask.IsCompleted)
        {
            errorInfo = new ErrorInfo(ErrorType.Timeout);
            optionsState = OptionsState.Error;
        }
        else if (changeTask.IsFaulted)
        {
            using (IEnumerator<System.Exception> enumerator = changeTask.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    ParseException exception = (ParseException) enumerator.Current;
                    errorInfo = new ErrorInfo(ErrorType.ParseException, exception.Code);
                }
                else
                {
                    errorInfo = new ErrorInfo(ErrorType.ParseInternal);
                }
            }

            optionsState = OptionsState.Error;
        }

        if (optionsState != OptionsState.Error)
        {
            AsyncWriter.StopWriting();
            selectionHandler = new SelectionHandler (new List<string> () {"Change Username", "Change Password", "Logout: " + ParseUser.CurrentUser.Username, "Menu"});
            PromptOptions();
        }
        else
        {
            ParseUser.CurrentUser.Username = cachedUsername;

            AsyncWriter.WriteTextInstant (errorInfo.GetErrorStr() + "\n" +
                "[Tap] to return\n");
        }
    }
    private void PromptChangeUsername()
    {
        SelectionWriter.ClearWriting ();
        AsyncWriter.ClearWriting();

        optionsState = OptionsState.ChangeUsername;

        HeaderWriter.WriteTextInstant ("[Tap] to change\n" +
                                       "[Hold] to cancel\n" +
                                 "Enter username");

        PasswordCanvasGroup.alpha = 0;
        PasswordCanvasGroup.blocksRaycasts = false;
        PasswordCanvasGroup.interactable = false;
        UsernameCanvasGroup.alpha = 1;
        UsernameCanvasGroup.blocksRaycasts = true;
        UsernameCanvasGroup.interactable = true;

        UsernameField.text = "";
        UsernameField.ActivateInputField();
        UsernameField.Select();
    }
    private IEnumerator ChangePasswordCoroutine(string passwordStr)
    {
        // TODO: MAY BE BUGGY SINCE INSTANCE PARSEUSER WILL RETAIN CHANGED PASSWORD REGARDLESS OF WHETHER SAVE WAS SUCCESSFUL
        ParseUser.CurrentUser.Password = passwordStr;
        Task changeTask = ParseUser.CurrentUser.SaveAsync ();

        DateTime startTime = DateTime.UtcNow;
        TimeSpan waitDuration = TimeSpan.FromSeconds(TimeUtils.TIMEOUT_DURATION);
        while (!changeTask.IsCompleted)
        {
            if(DateTime.UtcNow - startTime >= waitDuration)
                break;

            yield return null;
        }

        if(!changeTask.IsCompleted)
        {
            errorInfo = new ErrorInfo(ErrorType.Timeout);
            optionsState = OptionsState.Error;
        }
        else if (changeTask.IsFaulted)
        {
            using (IEnumerator<System.Exception> enumerator = changeTask.Exception.InnerExceptions.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    ParseException exception = (ParseException) enumerator.Current;
                    errorInfo = new ErrorInfo(ErrorType.ParseException, exception.Code);
                }
                else
                {
                    errorInfo = new ErrorInfo(ErrorType.ParseInternal);
                }
            }

            optionsState = OptionsState.Error;
        }

        if (optionsState != OptionsState.Error)
        {
            AsyncWriter.StopWriting();
            selectionHandler = new SelectionHandler (new List<string> () {"Change Username", "Change Password", "Logout: " + ParseUser.CurrentUser.Username, "Menu"});
            PromptOptions();
        }
        else
        {
            AsyncWriter.WriteTextInstant (errorInfo.GetErrorStr() + "\n" +
                "[Tap] to return\n");
        }
    }
    private void PromptOptions()
    {
        optionsState = OptionsState.ChoiceSelection;

        AsyncWriter.ClearWriting();

        string choiceMessage = "[Tap] to cycle \n[Hold] to select\n-----------------\n" + selectionHandler.GetOptionListString();

        SelectionWriter.WriteTextInstant (choiceMessage);
    }
    private void SubmitChangePassword(string passwordStr)
    {
        if (passwordStr.Length == 0)
        {
            PromptChangePassword();
            return;
        }

        optionsState = OptionsState.Syncing;

        PasswordCanvasGroup.alpha = 0;
        PasswordCanvasGroup.blocksRaycasts = false;
        PasswordCanvasGroup.interactable = false;

        HeaderWriter.ClearWriting ();
        AsyncWriter.RepeatText ("...");

        StartCoroutine (ChangePasswordCoroutine (passwordStr));
    }
    private void SubmitChangeUsername(string usernameStr)
    {
        if (usernameStr.Length == 0)
        {
            PromptChangeUsername();
            return;
        }

        optionsState = OptionsState.Syncing;

        UsernameCanvasGroup.alpha = 0;
        UsernameCanvasGroup.blocksRaycasts = false;
        UsernameCanvasGroup.interactable = false;

        HeaderWriter.ClearWriting ();
        AsyncWriter.RepeatText ("...");

        StartCoroutine (ChangeUsernameCoroutine (usernameStr));
    }