Ejemplo n.º 1
0
    /// <summary>
    /// Muestra la informacion asociada a una equipacion
    /// </summary>
    /// <param name="_equipacion"></param>
    /// <param name="_onCloseCallback">Accion a realizar cuando se cierre el dialogo</param>
    public void ShowEquipacionDesbloqueada(Equipacion _equipacion, btnButton.guiAction _onCloseCallback = null)
    {
        // obtener las referencias a los elementos de esta interfaz
        GetReferencias();

        // textura de la equipacion
        if (EquipacionManager.instance.EsEquipacionDeLanzador(_equipacion.assetName))
        {
            m_imgAvatar.texture = AvataresManager.instance.GetTexturaAvatarEquipacionesLanzador(_equipacion.idTextura);
        }
        else
        {
            m_imgAvatar.texture = AvataresManager.instance.GetTexturaAvatarEquipacionesPortero(_equipacion.idTextura);
        }
        ShowImagen(m_imgAvatar);

        // textos
        m_txtTitulo.text       = LocalizacionManager.instance.GetTexto(254).ToUpper();
        m_txtTituloSombra.text = m_txtTitulo.text;
        m_txtTexto.text        = string.Format(LocalizacionManager.instance.GetTexto(255), "<color=#ddf108>" + LocalizacionManager.instance.GetTexto(256) + "</color>");

        // boton cancelar => ocultarlo
        m_btnCancelar.gameObject.SetActive(false);

        // mostrar este dialogo
        transform.gameObject.SetActive(true);
        MostrarDialogoConSuperTweener(_onCloseCallback);
    }
    /// <summary>
    /// Muestra la informacion de la EQUIPACION en funcion de su estado
    /// </summary>
    /// <param name="_equipacion"></param>
    public void Show(Equipacion _equipacion)
    {
        if (_equipacion == null)
        {
            transform.gameObject.SetActive(false);
        }
        else
        {
            switch (_equipacion.estado)
            {
            case Equipacion.Estado.BLOQUEADA:
                ShowInfo(
                    LocalizacionManager.instance.GetTexto(26), string.Format(LocalizacionManager.instance.GetTexto(27), "<color=#ddf108> " + _equipacion.faseDesbloqueo + "</color>"), true, LocalizacionManager.instance.GetTexto(22), m_texturaFondoBloqueado,
                    (_name) => {
                    ifcDialogBox.instance.ShowOneButtonDialog(
                        ifcDialogBox.OneButtonType.BITOONS,
                        LocalizacionManager.instance.GetTexto(88).ToUpper(),
                        LocalizacionManager.instance.GetTexto(87),
                        _equipacion.precioEarlyBuy.ToString(),
                        // callback para realizar la compra
                        (_name1) => { Interfaz.instance.comprarEquipacion(_equipacion, Interfaz.TipoPago.PRECOMPRA); },
                        true);
                });
                break;

            case Equipacion.Estado.DISPONIBLE:
                ShowInfo(LocalizacionManager.instance.GetTexto(28), LocalizacionManager.instance.GetTexto(29), true, LocalizacionManager.instance.GetTexto(30), m_texturaFondoDisponible,
                         (_name) => {
                    ifcDialogBox.instance.ShowTwoButtonDialog(
                        ifcDialogBox.TwoButtonType.COINS_BITOONS,
                        LocalizacionManager.instance.GetTexto(88).ToUpper(),
                        LocalizacionManager.instance.GetTexto(89),
                        _equipacion.precioSoft.ToString(),
                        _equipacion.precioHard.ToString(),
                        // callback si el usuario acepta comprar la equipacion con dinero SOFT
                        (_name1) => { Interfaz.instance.comprarEquipacion(_equipacion, Interfaz.TipoPago.SOFT); },
                        // callback si el usuario acepta comprar la equipacion con dinero HARD
                        (_name1) => { Interfaz.instance.comprarEquipacion(_equipacion, Interfaz.TipoPago.HARD); },
                        true);
                });
                break;

            case Equipacion.Estado.ADQUIRIDA:
                // oculto el control
                transform.gameObject.SetActive(false);
                break;
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Modifica la equipacion del MODELO portero de la interfaz
    /// </summary>
    /// <param name="_offsetEquipacion"></param>
    /// <returns>Devuelve la informacion de la equipacion seleccionada</returns>
    public Equipacion CambiarEquipacionPortero(int _offsetEquipacion = 0)
    {
        if (m_equipacionesPortero == null || m_equipacionesPortero.Count == 0)
        {
            Debug.LogWarning("Atención. No se han definido equipaciones de portero");
            return(null);
        }

        // calcular el numero de la nueva equipacion
        int nuevoNumEquipacion = (idEquipacionPorteroSeleccionada + _offsetEquipacion) % m_equipacionesPortero.Count;

        if (nuevoNumEquipacion < 0)
        {
            nuevoNumEquipacion += m_equipacionesPortero.Count;
        }

        idEquipacionPorteroSeleccionada = nuevoNumEquipacion;

        // actualizar la textura del jugador
        if (Interfaz.instance.goalkeeperModel != null)
        {
            int idTextura = m_equipacionesPortero[idEquipacionPorteroSeleccionada].idTextura;

            GameObject bodyModeloJugador = Interfaz.instance.goalkeeperModel.transform.FindChild("Body").gameObject;
            bodyModeloJugador.GetComponent <Renderer>().materials[0].SetTexture("_MainTex", m_texturasPortero[idTextura]);
            bodyModeloJugador.GetComponent <Renderer>().materials[0].color = Color.grey;


            // colorear el dorsal del jugador en funcion de la equipacion que lleve
            Color      colorDorsal = Color.white; // <= por defecto blanco
            Equipacion equipacion  = EquipacionManager.instance.GetEquipacionPorteroSeleccionada();
            if (equipacion != null)
            {
                colorDorsal = equipacion.colorDorsal;
            }
            Numbers numbersComponent = bodyModeloJugador.GetComponent <Numbers>();
            if (numbersComponent != null)
            {
                numbersComponent.color = colorDorsal;
            }
        }

        PlayerPrefs.SetInt("goalKeeperEquipationInd", m_idEquipacionPorteroEquipada);
        return(m_equipacionesPortero[idEquipacionPorteroSeleccionada]);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Almacena las equipaciones adquiridas actualmente en las preferencias
    /// </summary>
    public void SaveEquipacionesCompradas()
    {
        Debug.Log(">>> GUARDAR EQUIPACIONES");

        // almacenar las equipaciones de lanzador compradas
        string strEquipacionesLanzadorCompradas = "";

        for (int i = 0; i < EquipacionManager.instance.numEquipacionesLanzador; ++i)
        {
            Equipacion equipacion = EquipacionManager.instance.GetEquipacionLanzador(i);
            if (equipacion != null && equipacion.estado == Equipacion.Estado.ADQUIRIDA)
            {
                // añadir el separador antes del id de la equipacion
                if (strEquipacionesLanzadorCompradas != "")
                {
                    strEquipacionesLanzadorCompradas += separadores[0];
                }

                strEquipacionesLanzadorCompradas += equipacion.assetName;
            }
        }
        EncryptedPlayerPrefs.SetString("shooterEquipaciones", strEquipacionesLanzadorCompradas);

        // almacenar las equipaciones de portero compradas
        string strEquipacionesPorteroCompradas = "";

        for (int i = 0; i < EquipacionManager.instance.numEquipacionesPortero; ++i)
        {
            Equipacion equipacion = EquipacionManager.instance.GetEquipacionPortero(i);
            if (equipacion != null && equipacion.estado == Equipacion.Estado.ADQUIRIDA)
            {
                // añadir el separador antes del id de la equipacion
                if (strEquipacionesPorteroCompradas != "")
                {
                    strEquipacionesPorteroCompradas += separadores[0];
                }

                strEquipacionesPorteroCompradas += equipacion.assetName;
            }
        }
        EncryptedPlayerPrefs.SetString("goalkeeperEquipaciones", strEquipacionesPorteroCompradas);

        PlayerPrefs.Save();
    }
Ejemplo n.º 5
0
    ///<summary>
    /// Actualiza o refresca el jugador seleccionado
    /// </summary>
    /// <param name="_desplazamiento">Offset respecto al id del jugador actual del jugador que se quiere mostrar (si es 0, sirve para refrescar el jugador actual)</param>
    /// <param name="_mostrarTooltip">Indica si hay que mostrar el tooltip asociado al jugador (si procede)</param>
    public void CambiarJugadorSeleccionado(int _desplazamiento, bool _mostrarTooltip = false)
    {
        Jugador jugador;

        if (m_tipoVestuario == TipoVestuario.LANZADOR)
        {
            // comprobar si la equipacion de LANZADOR seleccionada ha sido ADQUIRIDA
            Equipacion equipacionLanzador = EquipacionManager.instance.GetEquipacionLanzadorSeleccionada();
            if (equipacionLanzador.estado != Equipacion.Estado.ADQUIRIDA)
            {
                EquipacionManager.instance.CambiarASiguienteEquipacionLanzadorAdquirida();
            }

            Interfaz.instance.Thrower += _desplazamiento;
            jugador = InfoJugadores.instance.GetTirador(Interfaz.instance.Thrower);
            m_tooltipItemDisponible.Show(jugador);
        }
        else
        {
            // comprobar si la equipacion de PORTERO seleccionada ha sido ADQUIRIDA
            Equipacion equipacionPortero = EquipacionManager.instance.GetEquipacionPorteroSeleccionada();
            if (equipacionPortero.estado != Equipacion.Estado.ADQUIRIDA)
            {
                EquipacionManager.instance.CambiarASiguienteEquipacionPorteroAdquirida();
            }

            Interfaz.instance.Goalkeeper += _desplazamiento;
            jugador = InfoJugadores.instance.GetPortero(Interfaz.instance.Goalkeeper);
            m_tooltipItemDisponible.Show(jugador);
        }

        //mostrar el tooltip si procede
        if (_mostrarTooltip)
        {
            m_tooltipItemDisponible.Show(jugador);
        }
    }
Ejemplo n.º 6
0
    // ------------------------------------------------------------------------------
    // ---  METODOS  ----------------------------------------------------------------
    // ------------------------------------------------------------------------------


    /// <summary>
    /// Carga la informacion almacenada en la preferencias del juego (si no se ha cargado ya antes)
    /// </summary>
    /// <param name="_forzarCarga">Fuerza la carga de las preferencias aunque ya se haya realizado antes</param>
    public void LoadAllData(bool _forzarCarga = false)
    {
        if (_forzarCarga || !m_cargaDatosRealizada)
        {
            Debug.LogWarning(">>> Recupero informacion de las preferencias");

            // comprobar si existen las claves asociadas a los logros (es caso de que no crearlas)
            if (!EncryptedPlayerPrefs.HasKey("logrosLanzador"))
            {
                CreateListaLogrosPlayerPrefs(LogrosManager.logrosLanzador, "logrosLanzador");
                PlayerPrefs.Save();
            }
            if (!EncryptedPlayerPrefs.HasKey("logrosPortero"))
            {
                CreateListaLogrosPlayerPrefs(LogrosManager.logrosPortero, "logrosPortero");
                PlayerPrefs.Save();
            }
            if (!EncryptedPlayerPrefs.HasKey("logrosDuelo"))
            {
                CreateListaLogrosPlayerPrefs(LogrosManager.logrosDuelo, "logrosDuelo");
                PlayerPrefs.Save();
            }

            // obtener el dinero del juego y actualizar el dinero en la barra superior
            Interfaz.SetMonedaSoft_SinPersistencia(EncryptedPlayerPrefs.HasKey("softCurrency") ? EncryptedPlayerPrefs.GetInt("softCurrency") : 0);
            Interfaz.SetMonedaHard_SinPersistencia(EncryptedPlayerPrefs.GetInt("hardCurrency", 0));
            cntBarraSuperior.instance.ActualizarDinero();

            // obtener las mejores puntuaciones
            //Player.record_keeper = (PlayerPrefs.HasKey("goalkeeperRecord")) ? PlayerPrefs.GetInt("goalkeeperRecord") : 0;
            //Player.record_thrower = (PlayerPrefs.HasKey("shooterRecord")) ? PlayerPrefs.GetInt("shooterRecord") : 0;
            Interfaz.m_uname = EncryptedPlayerPrefs.GetString("alias", "");

            // obtener el tiempo de juego
            Interfaz.m_nextTryTime = (EncryptedPlayerPrefs.HasKey("nextTryTime")) ? EncryptedPlayerPrefs.GetInt("nextTryTime") : 0;

            // obtener el avance como portero
            Interfaz.m_asKeeper.record       = EncryptedPlayerPrefs.GetInt("goalkeeperRecord", 0);
            Interfaz.m_asKeeper.targets      = EncryptedPlayerPrefs.GetInt("goalkeeperTargets", 0);
            Interfaz.m_asKeeper.goals        = EncryptedPlayerPrefs.GetInt("goalkeeperGoals", 0);
            Interfaz.m_asKeeper.goalsStopped = EncryptedPlayerPrefs.GetInt("goalkeeperGoalsStopped", 0);
            Interfaz.m_asKeeper.throwOut     = EncryptedPlayerPrefs.GetInt("goalkeeperThrowOut", 0);
            Interfaz.m_asKeeper.totalPoints  = EncryptedPlayerPrefs.GetInt("goalkeeperTotalPoints", 0);
            Interfaz.m_asKeeper.deflected    = EncryptedPlayerPrefs.GetInt("goalkeeperDeflected", 0);
            Interfaz.m_asKeeper.perfects     = EncryptedPlayerPrefs.GetInt("goalkeeperPerfects", 0);

            // obtener el avance como lanzador
            Interfaz.m_asThrower.record       = EncryptedPlayerPrefs.GetInt("shooterRecord", 0);
            Interfaz.m_asThrower.targets      = EncryptedPlayerPrefs.GetInt("shooterTargets", 0);
            Interfaz.m_asThrower.goals        = EncryptedPlayerPrefs.GetInt("shooterGoals", 0);
            Interfaz.m_asThrower.goalsStopped = EncryptedPlayerPrefs.GetInt("shooterGoalsStopped", 0);
            Interfaz.m_asThrower.throwOut     = EncryptedPlayerPrefs.GetInt("shooterThrowOut", 0);
            Interfaz.m_asThrower.totalPoints  = EncryptedPlayerPrefs.GetInt("shooterTotalPoints", 0);
            Interfaz.m_asThrower.deflected    = EncryptedPlayerPrefs.GetInt("shooterDeflected", 0);
            Interfaz.m_asThrower.perfects     = EncryptedPlayerPrefs.GetInt("shooterPerfects", 0);

            // obtener el avance en duelos
            Interfaz.m_duelsPlayed  = EncryptedPlayerPrefs.GetInt("duelsPlayed", 0);
            Interfaz.m_duelsWon     = EncryptedPlayerPrefs.GetInt("duelsWon", 0);
            Interfaz.m_perfectDuels = EncryptedPlayerPrefs.GetInt("perfectDuels", 0);

            // obtener la ultima mision desbloqueada
            Interfaz.ultimaMisionDesbloqueada = EncryptedPlayerPrefs.GetInt("ultimaMisionDesbloqueada", 0);

            // actualizar el estado de desbloqueo de los escudos en funcion de la ultima fase desbloqueada
            EscudosManager.instance.ActualizarEstadoDesbloqueoEscudos(Interfaz.ultimaMisionDesbloqueada);

            // obtener los lanzadores comprados
            if (PlayerPrefs.HasKey("shootersComprados"))
            {
                string strShootersComprados = EncryptedPlayerPrefs.GetString("shootersComprados");
                if (strShootersComprados != null)
                {
                    string[] shootersComprados = strShootersComprados.Split(separadores);
                    if (shootersComprados != null)
                    {
                        for (int i = 0; i < shootersComprados.Length; ++i)
                        {
                            Jugador jugador = InfoJugadores.instance.GetJugador(shootersComprados[i]);
                            if (jugador != null)
                            {
                                jugador.estado = Jugador.Estado.ADQUIRIDO;
                            }
                        }
                    }
                }
            }

            // obtener los porteros comprados
            if (PlayerPrefs.HasKey("goalkeepersComprados"))
            {
                string strGoalkeepersComprados = EncryptedPlayerPrefs.GetString("goalkeepersComprados");
                if (strGoalkeepersComprados != null)
                {
                    string[] goalkeepersComprados = strGoalkeepersComprados.Split(separadores);
                    if (goalkeepersComprados != null)
                    {
                        for (int i = 0; i < goalkeepersComprados.Length; ++i)
                        {
                            Jugador jugador = InfoJugadores.instance.GetJugador(goalkeepersComprados[i]);
                            if (jugador != null)
                            {
                                jugador.estado = Jugador.Estado.ADQUIRIDO;
                                Debug.LogWarning(">>> El jugador " + jugador.nombre + " pasa a estar ADQUIRIDO");
                            }
                        }
                    }
                }
            }

            // obtener equipaciones de lanzador compradas
            if (PlayerPrefs.HasKey("shooterEquipaciones"))
            {
                string strEquipacionesLanzador = EncryptedPlayerPrefs.GetString("shooterEquipaciones");
                if (strEquipacionesLanzador != null)
                {
                    string[] equipacionesLanzador = strEquipacionesLanzador.Split(separadores);
                    if (equipacionesLanzador != null)
                    {
                        for (int i = 0; i < equipacionesLanzador.Length; ++i)
                        {
                            Equipacion equipacion = EquipacionManager.instance.GetEquipacion(equipacionesLanzador[i]);
                            if (equipacion != null)
                            {
                                equipacion.estado = Equipacion.Estado.ADQUIRIDA;
                            }
                        }
                    }
                }
            }

            // obtener equipaciones de portero compradas
            if (PlayerPrefs.HasKey("goalkeeperEquipaciones"))
            {
                string strEquipacionesPortero = EncryptedPlayerPrefs.GetString("goalkeeperEquipaciones");
                if (strEquipacionesPortero != null)
                {
                    string[] equipacionesPortero = strEquipacionesPortero.Split(separadores);
                    if (equipacionesPortero != null)
                    {
                        for (int i = 0; i < equipacionesPortero.Length; ++i)
                        {
                            Equipacion equipacion = EquipacionManager.instance.GetEquipacion(equipacionesPortero[i]);
                            if (equipacion != null)
                            {
                                equipacion.estado = Equipacion.Estado.ADQUIRIDA;
                            }
                        }
                    }
                }
            }

            // obtener los powerups de lanzador comprados
            if (PlayerPrefs.HasKey("pwrUpsLanzador"))
            {
                string strPowerUpsLanzador = EncryptedPlayerPrefs.GetString("pwrUpsLanzador");
                if (strPowerUpsLanzador != null)
                {
                    string[] powerUps = strPowerUpsLanzador.Split(separadores);
                    if (powerUps != null)
                    {
                        for (int i = 0; i < powerUps.Length; ++i)
                        {
                            string[] infoPowerUp = powerUps[i].Split(separadoresIgual);
                            if (infoPowerUp != null && infoPowerUp.Length == 2)
                            {
                                PowerupService.ownInventory.SetCantidadPowerUp(infoPowerUp[0], int.Parse(infoPowerUp[1]));
                            }
                        }
                    }
                }
            }

            // obtener los powerups de portero comprados
            if (PlayerPrefs.HasKey("pwrUpsPortero"))
            {
                string strPowerUpsPortero = EncryptedPlayerPrefs.GetString("pwrUpsPortero");
                if (strPowerUpsPortero != null)
                {
                    string[] powerUps = strPowerUpsPortero.Split(separadores);
                    if (powerUps != null)
                    {
                        for (int i = 0; i < powerUps.Length; ++i)
                        {
                            string[] infoPowerUp = powerUps[i].Split(separadoresIgual);
                            if (infoPowerUp != null && infoPowerUp.Length == 2)
                            {
                                PowerupService.ownInventory.SetCantidadPowerUp(infoPowerUp[0], int.Parse(infoPowerUp[1]));
                            }
                        }
                    }
                }
            }

            // obtener los escudos comprados
            if (PlayerPrefs.HasKey("escudos"))
            {
                string strEscudos = EncryptedPlayerPrefs.GetString("escudos");
                if (strEscudos != null)
                {
                    string[] escudos = strEscudos.Split(separadores);
                    if (escudos != null)
                    {
                        for (int i = 0; i < escudos.Length; ++i)
                        {
                            string[] infoEscudo = escudos[i].Split(separadoresIgual);
                            if (infoEscudo != null && infoEscudo.Length == 2)
                            {
                                Escudo escudo = EscudosManager.instance.GetEscudo(infoEscudo[0]);
                                if (escudo != null)
                                {
                                    escudo.numUnidades = int.Parse(infoEscudo[1]);
                                }
                            }
                        }
                    }
                }
            }

            // fuerza a que si los jugadores y equipaciones seleccionadas actualmente no estan ADQUIRIDOS, sean substidos por unos que si
            ifcVestuario.instance.ComprobarJugadoresYEquipacionesAdquiridos(true);

            // cargar el avance del jugador
            CargarObjetivosMision();



            // actualizar el estado de los jugadores
            InfoJugadores.instance.RefreshJugadoresDesbloqueados(Interfaz.ultimaMisionDesbloqueada);
            EquipacionManager.instance.RefreshEquipacionesDesbloqueadas(Interfaz.ultimaMisionDesbloqueada);

            // indicar que la carga de datos ya se ha realizado una vez
            m_cargaDatosRealizada = true;
        }
        // comprobar si existen logros que aun no han sido registrados
        int           recompensaPendiente = 0;
        List <string> idsLogros           = new List <string>();

        if (PersistenciaManager.instance.CheckHayLogrosSinRecompensar(ref recompensaPendiente, ref idsLogros))
        {
            // mostrar en la barra de opciones una "exclamacion"
            if (cntBarraSuperior.instance != null)
            {
                cntBarraSuperior.instance.MostrarQueHayNuevosLogros();
            }

            // actualizar el dinero
            Interfaz.MonedasHard += recompensaPendiente;

            // actualizar el progreso de los logros para que esta alerta no se dispare mas
            SaveLogros();

            // crear los dialogos para mostrar cada uno de los logros desbloqueados
            for (int i = 0; i < idsLogros.Count; ++i)
            {
                DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.LOGRO_DESBLOQUEADO, idsLogros[i]));
            }
        }
    }
Ejemplo n.º 7
0
    public void PintarEquipacionesIngame(bool _portero, GameObject _modelo)
    {
        int idTextura = 0;

        if (!GameplayService.networked)
        {
            if (_portero)
            {
                idTextura = m_equipacionesPortero[idEquipacionPorteroSeleccionada].idTextura;
            }
            else
            {
                idTextura = m_equipacionesLanzador[idEquipacionLanzadorSeleccionada].idTextura;
            }
        }
        else
        {
            if (_portero)
            {
                idTextura = GameplayService.IsGoalkeeper() ? m_equipacionesPortero[idEquipacionPorteroSeleccionada].idTextura : ifcDuelo.m_rival.equipacionGoalkeeper.idTextura;
            }
            else
            {
                idTextura = !GameplayService.IsGoalkeeper() ? m_equipacionesLanzador[idEquipacionLanzadorSeleccionada].idTextura : ifcDuelo.m_rival.equipacionShooter.idTextura;
            }
        }

        if (_portero)
        {
            GameObject bodyModeloJugador = _modelo.transform.FindChild("Body").gameObject;
            bodyModeloJugador.GetComponent <Renderer>().materials[0].SetTexture("_MainTex", m_texturasPortero[idTextura]);
            bodyModeloJugador.GetComponent <Renderer>().materials[0].color = Color.grey;

            // colorear el dorsal del jugador en funcion de la equipacion que lleve
            Color      colorDorsal = Color.white; // <= por defecto blanco
            Equipacion equipacion  = EquipacionManager.instance.GetEquipacionPorteroSeleccionada();
            if (equipacion != null)
            {
                colorDorsal = equipacion.colorDorsal;
            }
            Numbers numbersComponent = bodyModeloJugador.GetComponent <Numbers>();
            if (numbersComponent != null)
            {
                numbersComponent.color  = colorDorsal;
                numbersComponent.number = FieldControl.localGoalkeeper.numDorsal;
            }
        }
        else
        {
            GameObject bodyModeloJugador = _modelo.transform.FindChild("Body").gameObject;
            bodyModeloJugador.GetComponent <Renderer>().materials[0].SetTexture("_MainTex", m_texturasLanzador[idTextura]);
            bodyModeloJugador.GetComponent <Renderer>().materials[0].color = Color.grey;

            // colorear el dorsal del jugador en funcion de la equipacion que lleve
            Color      colorDorsal = Color.white; // <= por defecto blanco
            Equipacion equipacion  = EquipacionManager.instance.GetEquipacionLanzadorSeleccionada();
            if (equipacion != null)
            {
                colorDorsal = equipacion.colorDorsal;
            }
            Numbers numbersComponent = bodyModeloJugador.GetComponent <Numbers>();
            if (numbersComponent != null)
            {
                numbersComponent.color = colorDorsal;
            }
            numbersComponent.number = FieldControl.localThrower.numDorsal;
        }
    }
Ejemplo n.º 8
0
    public void TryShotResult(ShotResult shotResult)
    {
        bool playingGoalkeeper = GameplayService.IsGoalkeeper();

        if (playingGoalkeeper)
        {
            Habilidades.EndRound(shotResult.Result == Result.Goal);
        }

        if (!GameplayService.networked)
        {
            if (!playingGoalkeeper)
            {
                if (shotResult.Result == Result.Goal || shotResult.Result == Result.Target)
                {
                    if (shotResult.Perfect && attempts < maxAttempts)
                    {
                        GeneralSounds.instance.vidaExtra();
                        kickEffects.instance.ExtraLife(shotResult.Point);
                        this.attempts++;
                        if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts))
                        {
                            this.attempts++;
                            kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -1f));
                        }
                    }

                    /*if (this.attempts >= maxAttempts && shotResult.Perfect)
                     * {
                     * if (perfects > 1 || Habilidades.IsActiveSkill(Habilidades.Skills.VIP))
                     * {
                     *    if (this.attempts != 3)
                     *    {
                     *      GeneralSounds.instance.vidaExtra();
                     *      kickEffects.instance.ExtraLife(shotResult.Point);
                     *      this.attempts = 3;
                     *    }
                     * }
                     * }
                     * if(this.attempts < maxAttempts) this.attempts = maxAttempts;*/
                }
                else
                {
                    ShotFailed();
                }
            }
            else
            {
                if (shotResult.Result == Result.Goal)
                {
                    ShotFailed();
                }
                else
                {
                    if (shotResult.Perfect && attempts < maxAttempts)
                    {
                        GeneralSounds.instance.vidaExtra();
                        kickEffects.instance.ExtraLife(shotResult.Point);
                        this.attempts++;
                        if (Habilidades.IsActiveSkill(Habilidades.Skills.VIP) && (attempts < maxAttempts))
                        {
                            this.attempts++;
                            kickEffects.instance.ExtraLife(shotResult.Point + (Vector3.up * -0.5f));
                        }
                    }
                    //else if (this.attempts < maxAttempts && shotResult.Result != Result.OutOfBounds) this.attempts = maxAttempts;
                }
            }

            SumarDineroPorPrimas();
        }
        else if (GameplayService.networked)
        {
            bool isPlayer1 = GameplayService.initialGameMode != GameMode.Shooter;

            if (playingGoalkeeper)
            {
                cntPastillaMultiplayer.marcadorRemoto.Lanzamientos++;
            }
            else
            {
                cntPastillaMultiplayer.marcadorLocal.Lanzamientos++;
            }

            if (newState)
            {
                Debug.Log("APPLYING");
                cntPastillaMultiplayer.marcadorLocal.SetEstado(GetSimpleState(serverState, isPlayer1));
                cntPastillaMultiplayer.marcadorRemoto.SetEstado(GetSimpleState(serverState, !isPlayer1));
                newState = false;
            }
            else
            {
                Debug.Log("CALCULATING");
                MatchState tempstate = serverState;
                if ((isPlayer1 == playingGoalkeeper))
                {
                    tempstate.rounds++;
                }
                if (playingGoalkeeper)
                {
                    MatchStateSimple state = cntPastillaMultiplayer.marcadorRemoto.AddResult(shotResult.Result == Result.Goal);
                    if (isPlayer1)
                    {
                        tempstate.marker_2 = state.marker;
                        tempstate.score_2  = state.score;
                    }
                    else
                    {
                        tempstate.marker_1 = state.marker;
                        tempstate.score_1  = state.score;
                    }
                }
                else
                {
                    MatchStateSimple stateF = cntPastillaMultiplayer.marcadorLocal.AddResult(shotResult.Result == Result.Goal);
                    if (isPlayer1)
                    {
                        tempstate.marker_1 = stateF.marker;
                        tempstate.score_1  = stateF.score;
                    }
                    else
                    {
                        tempstate.marker_2 = stateF.marker;
                        tempstate.score_2  = stateF.score;
                    }
                }
                serverState = tempstate;

                if (!playingGoalkeeper)
                {
                    Debug.Log("SENDING");
                    MsgSendState msg = Shark.instance.mensaje <MsgSendState>();
                    msg.state   = tempstate;
                    msg.defense = MsgDefend.ToDefenseInfoNet(Vector3.zero, shotResult.DefenseResult);
                    msg.send();
                }
                newState = false;
            }

            if (isPlayer1 == playingGoalkeeper)                                           //fin de ronda
            {
                if (serverState.rounds > 4 && serverState.score_1 != serverState.score_2) //fin de partida
                {
                    gameOver = true;

                    bool winner  = isPlayer1 ? (serverState.score_1 > serverState.score_2) : (serverState.score_2 > serverState.score_1);
                    bool perfect = isPlayer1 ? (serverState.score_2 == 0) : (serverState.score_1 == 0);
                    perfect = perfect && (isPlayer1 ? (serverState.score_1 >= 5) : (serverState.score_2 >= 5));

                    if (winner)
                    {
                        Interfaz.MonedasSoft += recompensaMultijugadorWin;
                    }
                    else
                    {
                        Interfaz.MonedasSoft += recompensaMultijugadorFail;
                    }

                    PersistenciaManager.instance.GuardarPartidaMultiPlayer(winner, perfect);
                }
            }
        }

        int points = shotResult.ScorePoints + shotResult.EffectBonusPoints;

        // actualizar la informacion de cada ronda
        RoundInfoManager.instance.AcumularRonda(shotResult.Result, points, shotResult.Perfect);//, GameplayService.IsGoalkeeper() ? (shotResult.DefenseResult == GKResult.Perfect) : (shotResult.Perfect));

        // acumular la recompensa
        // DINERO! MONEDAS!
        int monedas = Mathf.FloorToInt((float)points * DifficultyService.GetRatioRecompensa());

        Interfaz.recompensaAcumulada += monedas;
        Interfaz.MonedasSoft         += monedas;


        if (gameOver && !GameplayService.networked)
        {
            //ifcGameOver.instance.resultTime = FieldControl.instance.seconds;
            Mission mission = MissionManager.instance.GetMission();
            if (attempts > 0)
            {
                // persistir la mision que se acaba de superar
                PersistenciaManager.instance.ActualizarUltimoNivelDesbloqueado(mission.indexMision + 1);


                // comprobar si la en mision que se acaba de superar desbloquea algun jugador
                Jugador jugadorDesbloqueado = InfoJugadores.instance.GetJugadorDesbloqueableEnFase(mission.indexMision);
                if (jugadorDesbloqueado != null)
                {
                    // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo jugador y actualizar su estado
                    jugadorDesbloqueado.estado = Jugador.Estado.DISPONIBLE;
                    DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.JUGADOR_DESBLOQUEADO, jugadorDesbloqueado));
                }

                // comprobar si en la mision que se acaba de superar se desbloquea alguna equipacion
                Equipacion equipacionDesbloqueada = EquipacionManager.instance.GetEquipacionDesbloqueableEnFase(mission.indexMision);
                if (equipacionDesbloqueada != null)
                {
                    // registrar el dialogo para mostrar el aviso de que se ha obtenido una nueva equipacion y actualizar su estado
                    equipacionDesbloqueada.estado = Equipacion.Estado.DISPONIBLE;
                    DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.EQUIPACION_DESBLOQUEADA, equipacionDesbloqueada));
                }

                // comprobar si en la mision que se acaba de superar se ha desbloqueado algun escudo
                Debug.Log(">>> Compruebo escudo => fase ");
                Escudo escudoDesbloqueado = EscudosManager.instance.GetEscudoDesbloqueableEnFase(mission.indexMision);
                if (escudoDesbloqueado != null)
                {
                    // registrar el dialogo para mostrar el aviso de que se ha obtenido un nuevo escudo y desbloquearlo
                    escudoDesbloqueado.bloqueado = false;
                    DialogManager.instance.RegistrarDialogo(new DialogDefinition(DialogDefinition.TipoDialogo.ESCUDO_DESBLOQUEADO, escudoDesbloqueado));
                }
            }
        }

        if (firstShot)
        {
            firstShot = false;
        }
        UpdateEvent();
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Mostrar la pantalla de duelo en modo "VS"
    /// </summary>
    /// <param name="_usuarioRival"></param>
    /// <param name="_habilitarBtnAddFavoritoRival"></param>
    public void ShowVs(Usuario _usuarioRival, bool _habilitarBtnAddFavoritoRival)
    {
        //para ocultar el pop up de "esperando"
        ifcDialogBox.instance.Hide();

        //desactivar el paginado
        getComponentByName("flecha_dcha").SetActive(false);
        getComponentByName("flecha_izq").SetActive(false);

        // ocultar la informacion de los jugadores (salvo la del primero y el ultimo)
        for (int i = 1; i < m_cntInfoJugadoresDuelo.Length - 1; ++i)
        {
            m_cntInfoJugadoresDuelo[i].SetVisible(false);
        }

        // mostrar la info del jugador local y del rival
        Usuario me = new Usuario(Interfaz.m_uname, 0, 0, "");

        //me.alias += " (TU)";

        me.initMode             = !m_rival.initMode;
        me.charGoalkeeper       = Interfaz.instance.m_goalKeeper;
        me.charThrower          = Interfaz.instance.m_thrower;
        me.equipacionShooter    = EquipacionManager.instance.GetEquipacionLanzadorSeleccionada();
        me.equipacionGoalkeeper = EquipacionManager.instance.GetEquipacionPorteroSeleccionada();

        m_cntInfoJugadoresDuelo[0].AsignarValores(me, false, true);
        m_cntInfoJugadoresDuelo[m_cntInfoJugadoresDuelo.Length - 1].AsignarValores(_usuarioRival, false);

        // mostrar la imagen de vs
        m_imagenVs.SetActive(true);

        // ocultar el boton de atras
        m_btnAtras.SetActive(false);

        // indicar que la pantalla esta en modo VS
        m_modoVs = true;
        m_tiempoTranscurridoEnPantallaVs = 0.0f;

        // mostrar el jugador secundario del usuario local
        if (m_jugadorSecundarioLocal != null)
        {
            GameObject.Destroy(m_jugadorSecundarioLocal);
        }

        Vector3 posicionJugadorSecundarioLocal = m_cntInfoJugadoresDuelo[0].transform.position;

        posicionJugadorSecundarioLocal.x += 0.14f;
        posicionJugadorSecundarioLocal.y += 0.065f;
        Equipacion equipacionJugadorLocal = ((me.initMode)? (EquipacionManager.instance.GetEquipacionLanzadorSeleccionada()) : (EquipacionManager.instance.GetEquipacionPorteroSeleccionada()));

        m_jugadorSecundarioLocal = Interfaz.instance.InstantiatePlayerAtScreenRelative(posicionJugadorSecundarioLocal, !me.initMode, me.secondaryCharacter.idModelo, equipacionJugadorLocal);

        // mostrar el jugador secundario del usuario remoto
        if (m_jugadorSecundarioRemoto != null)
        {
            GameObject.Destroy(m_jugadorSecundarioRemoto);
        }

        Vector3 posicionJugadorSecundarioRemoto = m_cntInfoJugadoresDuelo[m_cntInfoJugadoresDuelo.Length - 1].transform.position;

        posicionJugadorSecundarioRemoto.x -= 0.14f;
        posicionJugadorSecundarioRemoto.y += 0.065f;
        m_jugadorSecundarioRemoto          = Interfaz.instance.InstantiatePlayerAtScreenRelative(posicionJugadorSecundarioRemoto, !_usuarioRival.initMode, _usuarioRival.secondaryCharacter.idModelo, (_usuarioRival.initMode)?_usuarioRival.equipacionShooter:_usuarioRival.equipacionGoalkeeper);
    }
Ejemplo n.º 10
0
    /// <summary>
    /// comprueba si los jugadores seleccionados han sido adquiridos y si no, selecciona otros que si que lo esten
    /// </summary>
    /// <param name="_forzarRefresco">fuerza el refresco de los elementos de esta interfaz</param>
    public void ComprobarJugadoresYEquipacionesAdquiridos(bool _forzarRefresco = false)
    {
        bool actualizarLanzador            = false;
        bool actualizadaEquipacionLanzador = false;
        bool actualizarPortero             = false;
        bool actualizadaEquipacionPortero  = false;

        // comprobar si el jugador TIRADOR seleccionado no ha sido ADQUIRIDO => buscar el siguiente jugador ADQUIRIDO
        Jugador tirador = InfoJugadores.instance.GetTirador(Interfaz.instance.Thrower);

        if (tirador.estado != Jugador.Estado.ADQUIRIDO)
        {
            actualizarLanzador = true;
        }

        // comprobar si el jugador PORTERO seleccionado no ha sido ADQUIRIDO => buscar el siguiente jugador ADQUIRIDO
        Jugador portero = InfoJugadores.instance.GetPortero(Interfaz.instance.Goalkeeper);

        if (portero.estado != Jugador.Estado.ADQUIRIDO)
        {
            actualizarPortero = true;
        }

        // comprobar si la equipacion de lanzador seleccionada ha sido ADQUIRIDA
        Equipacion equipacionLanzador = EquipacionManager.instance.GetEquipacionLanzadorSeleccionada();

        if (equipacionLanzador.estado != Equipacion.Estado.ADQUIRIDA)
        {
            //EquipacionManager.instance.CambiarASiguienteEquipacionLanzadorAdquirida(); //esto podria ya no ser necesario
            actualizadaEquipacionLanzador = true;
        }

        // comprobar si la equipacion de lanzador seleccionada ha sido ADQUIRIDA
        Equipacion equipacionPortero = EquipacionManager.instance.GetEquipacionPorteroSeleccionada();

        if (equipacionPortero.estado != Equipacion.Estado.ADQUIRIDA)
        {
            //EquipacionManager.instance.CambiarEquipacionPortero(); //esto podria ya no ser necesario
            actualizadaEquipacionPortero = true;
        }

        // actualizar el modelo de lanzador
        if (actualizarLanzador)
        {
            Interfaz.instance.Thrower = InfoJugadores.instance.GetPosicionSiguienteTiradorAdquirido();
        }
        else if (actualizadaEquipacionLanzador)
        {
            Interfaz.instance.Thrower = Interfaz.instance.Thrower;
        }

        // actualizar el modelo de portero
        if (actualizarPortero)
        {
            Interfaz.instance.Goalkeeper = InfoJugadores.instance.GetPosicionSiguientePorteroAdquirido();
        }
        else if (actualizadaEquipacionPortero)
        {
            Interfaz.instance.Goalkeeper = Interfaz.instance.Goalkeeper;
        }

        // comprobar si hay que actualizar la info de la interfaz
        if (_forzarRefresco || actualizarLanzador || actualizarPortero || actualizadaEquipacionLanzador || actualizadaEquipacionPortero)
        {
            RefreshInfo();
        }
    }