Exemplo n.º 1
0
    void Chrono(PowerupUsage _info)
    {
        if (_info.Value != Powerup.Concentracion || GameplayService.IsGoalkeeper())
        {
            return;
        }
        GameObject aux = Instantiate(chronoPrefab) as GameObject;

        aux.transform.parent        = Camera.main.transform;
        aux.transform.localPosition = new Vector3(0, 0, 1.5f);
        aux.transform.localRotation = Quaternion.identity;
    }
Exemplo n.º 2
0
 void StopGKTuto(DefenseInfo _info)
 {
     if (!GameplayService.IsGoalkeeper())
     {
         return;
     }
     hide = true;
     step++;
     if (step > 1)
     {
         isActive = false;
         PopUpVisible(false);
         line.SetVertexCount(0);
     }
 }
    /// <summary>
    /// Muestra la pastilla de power ups en el modo recibido como parametro
    /// </summary>
    public void Show()
    {
        if (m_estaVisible)
        {
            return;
        }
        // indicar que la pastilla esta visible
        m_estaVisible = true;

        ObtenerReferencias();

        // comprobar si hay que mostrar la pastilla de lanzador o de portero
        bool modoLanzador = !GameplayService.IsGoalkeeper();

        // mostrar / ocultar los botones de lanzador
        m_goGrupoPowerupsLanzador.SetActive(modoLanzador);
        m_goGrupoPowerupsPortero.SetActive(!modoLanzador);

        // mostrar las cantidades de cada tipo de powerup
        int      numPowerups = modoLanzador ? NUM_POWERUPS_LANZADOR : NUM_POWER_UPS_PORTERO;
        GameMode gameMode    = modoLanzador ? GameMode.Shooter : GameMode.GoalKeeper;

        for (int i = 0; i < numPowerups; ++i)
        {
            int cantidadPowerup = PowerupService.ownInventory.GetCantidadPowerUp(gameMode, i);
            m_txtCantidadesPowerUp[i].text       = cantidadPowerup.ToString();
            m_txtCantidadesPowerUpSombra[i].text = m_txtCantidadesPowerUp[i].text;
            m_txtCantidadesPowerUp[i].gameObject.SetActive(true);

            // comprobar si el boton debe estar habilitado o no
            if (gameMode == GameMode.Shooter)
            {
                m_btnPowerupLanzador[i].SetEnabled(cantidadPowerup > 0);
            }
            else
            {
                m_btnPowerupPortero[i].SetEnabled(cantidadPowerup > 0);
            }
        }
        for (int i = numPowerups; i < m_txtCantidadesPowerUp.Length; ++i)
        {
            m_txtCantidadesPowerUp[i].gameObject.SetActive(false);
        }

        // mostrar la pastilla de power ups
        new SuperTweener.move(gameObject, 0.25f, new Vector3(1.0f, (GameplayService.networked ? Y_PASTILLA_MODO_MULTI : Y_PASTILLA_MODO_SINGLE), 0.0f));
        GeneralSounds.instance.powerupBarOn();
    }
Exemplo n.º 4
0
    public static Skills[] GetAllHabilidades()
    {
        List <Skills> skills = new List <Skills>();

        int i = GameplayService.IsGoalkeeper() ? NUM_HABILIDADES_LANZADOR : 0;

        for ( ; i < (GameplayService.IsGoalkeeper() ? (NUM_HABILIDADES_LANZADOR + NUM_HABILIDADES_PORTERO) : NUM_HABILIDADES_LANZADOR); i++)
        {
            Skills skill = (Skills)i;
            if (IsActiveSkill(skill))
            {
                skills.Add(skill);
            }
        }
        return(skills.ToArray());
    }
Exemplo n.º 5
0
    public static void EndRound(bool _fail)
    {
        if (GameplayService.networked && GameplayService.IsGoalkeeper())
        {
            delayAlpha = _fail;
        }
        else if (GameplayService.networked)
        {
            delayAlphaRival = _fail;
        }

        if (!GameplayService.networked)
        {
            delayAlpha = _fail;
        }
    }
Exemplo n.º 6
0
    void EndPan(bool _ok = true)
    {
        bool playingGoalKeeper = GameplayService.IsGoalkeeper();

        //m_initializedGesture = false;
        if (playingGoalKeeper)
        {
            return;
        }

        if (m_finishedGesture)
        {
            Debug.Log("<TIRO NO>");

            m_panPoints.Clear();
            m_initializedGesture = false;
            return;
        }

        m_finishedGesture = true;
        m_gestureTime     = 0f;
        if (LengthCurva() < 100f * ifcBase.scaleFactor)
        {
            //Camera.main.fieldOfView =45;
            m_initializedGesture = false;
            m_panPoints.Clear();
            return;
        }

        if (!playingGoalKeeper && !_ok && m_panPoints.Count < 3)
        {
            m_initializedGesture = false;
            m_panPoints.Clear();
            return;
        }

        Blocked = true;
        sendShoot();

        if (GameplayService.networked && GoalCamera.instance.stateMachine.current == ThrowerCameraStates.Sharpshooter.instance)
        {
            GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.Init.instance;
        }
    }
Exemplo n.º 7
0
    void InitGesture()
    {
        if (PowerupService.instance.IsPowerActive(Powerup.Concentracion) && !GameplayService.IsGoalkeeper())
        {
            InputChrono.instance.GetComponent <GUIText>().enabled = true;
            InputChrono.instance.time = throwerGestureTime;
        }

        /*if(PowerupService.instance.IsPowerActive(Powerup.Manoplas))
         * {
         *  kickEffects.instance.Focus(true);
         * }*/


        m_initializedGesture = false;
        m_finishedGesture    = false;
        m_gestureTime        = (ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.Shooter) ? throwerGestureTime : goalkeeperGestureTime;
        m_panPoints.Clear();
    }
Exemplo n.º 8
0
    void addPoint(PanInfo _panInfo)
    {
        if (m_panPoints.Count == 0 && !GameplayService.IsGoalkeeper())
        {
            PanInfo info = new PanInfo(Camera.main.WorldToScreenPoint(BallPhysics.instance.transform.position), Time.time);
            m_panPoints.Add(info);
        }
        else
        {
            m_panPoints.Add(_panInfo);
        }

        /*float d = m_panPoints[0].Position.x - _panInfo.Position.x;
         * float ad = Mathf.Abs(d);
         *
         * if (ad > m_maxAbsEffect) {
         * m_maxAbsEffect = ad;
         * m_maxEffect = d;
         * }*/
    }
Exemplo n.º 9
0
    public void DoThrow()
    {
        // si estamos en modo time_attack y se ha agotado el tiempo => no realizar tiros fuera de tiempo
        if (GameplayService.modoJuego.tipoModo == ModoJuego.TipoModo.TIME_ATTACK && cntCronoTimeAttack.instance.tiempoRestante <= 0.0f)
        {
            return;
        }
        GetComponent <Animation>().CrossFade(m_tipoTiro); // Lanza animacion de tiro.
        if (ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.GoalKeeper)
        {
            kickEffects.instance.ballEffect(BallPhysics.instance.transform.position);
        }

        // en modo multijugador, si estoy manejando al tirador => forzar a que se aplique la camara de tiro
        if (GameplayService.networked && !GameplayService.IsGoalkeeper())
        {
            GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.OnRun.instance;
        }

        m_animationState = GetComponent <Animation>()[m_tipoTiro];
    }
Exemplo n.º 10
0
    public static bool IsActiveSkill(Skills _skill)
    {
        bool result = false;

        if ((int)_skill > NUM_HABILIDADES_LANZADOR - 1)
        {
            if (Goalkeeper.instance)
            {
                result = FieldControl.instance.GoalkeeperObject.TieneHabilidad(_skill);
            }
        }
        else
        {
            result = FieldControl.instance.ThrowerObject.TieneHabilidad(_skill);
        }

        if (_skill == Skills.Premonicion)
        {
            bool active = false;
            if (GameplayService.networked && GameplayService.IsGoalkeeper())
            {
                active = delayAlpha;
            }
            else if (GameplayService.networked)
            {
                active = delayAlphaRival;
            }

            if (!GameplayService.networked)
            {
                active = delayAlpha;
            }

            if (!active)
            {
                result = false;
            }
        }
        return(result);
    }
Exemplo n.º 11
0
 public bool ReboundBall()
 {
     if (PowerupService.instance.IsPowerActive(Powerup.Resbaladiza) && noCatch)
     {
         return(false);
     }
     if (Goalkeeper.instance && Goalkeeper.instance.ClearBall && !Goalkeeper.instance.GrabBall)
     {
         GeneralSounds.instance.rebound();
         GetComponent <Rigidbody>().velocity = m_reboundVector;
         if (GameplayService.IsGoalkeeper())
         {
             GeneralSounds.instance.cheer();
         }
         Goalkeeper.instance.MakeResult(false);
         FieldControl.instance.setRoundCooldown(1.5f);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 12
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();
    }
Exemplo n.º 13
0
    public void resultAnimations(ShotResult _info)
    {
        if (this == null)
        {
            return;
        }

        bool isPlayer1 = GameplayService.initialGameMode != GameMode.Shooter;
        int  score1    = isPlayer1 ? Player.serverState.score_1 : Player.serverState.score_2;
        int  score2    = isPlayer1 ? Player.serverState.score_2 : Player.serverState.score_1;

        bool victory  = (_info.Result == Result.Goal || _info.Result == Result.Target);
        bool gameOver = ServiceLocator.Request <IPlayerService>().IsGameOver();

        if (gameOver)
        {
            if (GameplayService.networked)
            {
                victory = (score1 > score2) && !GameplayService.IsGoalkeeper() || (score1 < score2) && GameplayService.IsGoalkeeper();
            }
            else
            {
                victory = ServiceLocator.Request <IPlayerService>().GetPlayerInfo().Attempts > 0;
                if (MissionManager.instance.GetMission().PlayerType == GameMode.GoalKeeper)
                {
                    victory = !victory;
                }
            }
        }

        if (victory)
        {
            if (!gameOver)
            {
                GetComponent <Animation>().Play("Celebracion_01");
            }
            else
            {
                m_animationState = GetComponent <Animation>()["Celebracion_02"];
                GetComponent <Animation>().Play("Celebracion_02");
                m_idleAnim = "IdleCelebracionFinal";
            }
        }
        else
        {
            if (!gameOver)
            {
                if (Random.Range(0, 1f) > 0.5f)
                {
                    GetComponent <Animation>().Play("Fallo_01");
                }
            }
            else
            {
                Vector3 pos = m_bip01.transform.position;
                pos.y = m_feet.position.y;
                transform.position = pos;
                m_animationState   = GetComponent <Animation>()["FalloFinal"];
                GetComponent <Animation>().Play("FalloFinal");
                m_idleAnim = "IdleFalloFinal";
            }
        }
    }
Exemplo n.º 14
0
    void StartPlay()
    {
        InputManager.instance.Blocked = false;

        if (GameplayService.networked)
        {
            gpService.SwitchGameMode();
        }

        var config = ServiceLocator.Request <IDifficultyService>().GetNextShotConfig();

        if (playingGoalKeeper)
        {
            GoalCamera.instance.stateMachine.changeState = GoalKeeperCameraStates.Init.instance;
        }
        else
        {
            GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.Init.instance;
        }
        kickEffects.instance.ShowRect();
        Vector3 pos = config.Position;

        playOnCourse = true;

        if (MissionManager.instance.HasCurrentMission())
        {
            MissionRound mr = MissionManager.instance.GetMission().GetRoundInfo();
            if (mr.HasPopUp())
            {
                Debug.Log("PopUp: " + mr.GetPopUp().MessageID);
                Tutorial.instance.ThrowTuto(mr.GetPopUp().MessageID);
            }
            else
            {
                Tutorial.instance.DeactivateTutorial();
            }
        }

        // en modo duelo => ocultar la pastilla del tutorial
        if (GameplayService.networked)
        {
            Tutorial.instance.DeactivateTutorial();
        }

        BallPhysics.instance.Prepare(pos + new Vector3(0, .1f, 0));

        Destroy(Thrower.instance.gameObject);
        SpawnThrower();

        if (Goalkeeper.instance)
        {
            Goalkeeper.instance.Reset();
        }

        Porteria.instance.SetKeeperMaterial(playingGoalKeeper);

        if (gpService.GetAuto())
        {
            Auto_Thrower.instance.Ready();
        }
        if (!GameplayService.IsGoalkeeper() && GameplayService.networked)
        {
            Debug.Log(">>> DESDE AQUI SE LANZA EL CRONOMETRO");
            cntCuentaAtras.instance.Activar(
                // accion a realizar si se termina el tiempo
                (_name) => {
                InputManager.instance.Blocked = true;
                InputManager.instance.SendShotInfo(Auto_Thrower.GetRandomFail());
            });
        }

        Thrower.instance.SetPositionFor(ball.transform.position);

        Tutorial.instance.EnableTutorial();

        ifcThrower.instance.UpdateHabilidades();
    }
Exemplo n.º 15
0
 public GameplayManager()
 {
     gameService = new GameplayService();
     uManager = new UserManager();
     ugsManager = new UserGameStorageManager();
 }
Exemplo n.º 16
0
    public void Celebrate(ShotResult _info)
    {
        bool celebrate = m_lastFase != ServiceLocator.Request <IDifficultyService>().GetFase();

        // en modo TIME_ATTACK
        if (GameplayService.modoJuego.tipoModo == ModoJuego.TipoModo.TIME_ATTACK)
        {
            // si se ha agotado el tiempo del cronometro => mostrar la animacion de derrota
            if (cntCronoTimeAttack.instance.tiempoRestante <= 0.0f)
            {
                if (m_animName != "P_FalloFinal") // <= si no se esta reproduciendo ya una animacion de derrota
                {
                    m_animName = "P_FalloFinal";
                    m_animIdle = "P_IdleFalloFinal";
                    GetComponent <Animation>().Play(m_animName);
                }
            }

            return;
        }

        if (celebrate && !ServiceLocator.Request <IPlayerService>().IsGameOver())
        {
            m_lastFase = ServiceLocator.Request <IDifficultyService>().GetFase();
            switch (_info.Result)
            {
            case Result.Stopped:
                if (_info.Point.x > 0)
                {
                    m_animIdle = "P_Celebracion_01";
                }
                else
                {
                    m_animIdle = "P_Celebracion_02";
                }
                FieldControl.instance.setRoundCooldown(4.5f);
                break;

            case Result.Saved:
                m_animIdle = "P_Celebracion_04";
                FieldControl.instance.setRoundCooldown(4.5f);
                break;

            case Result.OutOfBounds:
                break;

            case Result.Goal:
                break;
            }
        }
        else //estas se reprducen siempre
        {
            if (ServiceLocator.Request <IPlayerService>().IsGameOver())
            {
                doGOAnim = true;
            }
            else if (_info.Result == Result.Goal)
            {
                m_animIdle = "P_Fallo_01";
                if (GameplayService.IsGoalkeeper() && !m_gestureReady)
                {
                    GetComponent <Animation>().CrossFade(m_animIdle);
                }
                FieldControl.instance.setRoundCooldown(2f);
            }
        }
    }
Exemplo n.º 17
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;
        }
    }
Exemplo n.º 18
0
    public void UsePowerup(Powerup _powerup)
    {
        int          id      = (int)_powerup;
        bool         success = false;
        PowerupUsage info    = new PowerupUsage();

        info.AbsId = id;
        info.Id    = id; //si es de portero, se cambia mas tarde
        info.Own   = false;
        info.Value = _powerup;
        bool isGoalkeeperPowerup = id >= MAXPOWERUPSTIRADOR;

        //proteccion para no usar 2 powerups al mismo tiempo
        if ((!isGoalkeeperPowerup && PowerupService.instance.usedShooterPowerup) || (isGoalkeeperPowerup && PowerupService.instance.usedGoalkeeperPowerup))
        {
            return;
        }

        if (GameplayService.IsGoalkeeper())
        {
            if (id >= MAXPOWERUPSTIRADOR)
            {
                success  = m_ownInventory.UsePowerup(id - MAXPOWERUPSTIRADOR, GameMode.GoalKeeper);
                info.Own = true;
            }
            else
            {
                success = rivalInventory.UsePowerup(id, GameMode.Shooter);
            }
        }
        else
        {
            if (id >= MAXPOWERUPSTIRADOR)
            {
                success = rivalInventory.UsePowerup(id - MAXPOWERUPSTIRADOR, GameMode.GoalKeeper);
            }
            else
            {
                success  = m_ownInventory.UsePowerup(id, GameMode.Shooter);
                info.Own = true;
            }
        }

        if (success)
        {
            if (id >= MAXPOWERUPSTIRADOR)
            {
                GoalkeeperPowerup = _powerup;
                info.Mode         = GameMode.GoalKeeper;
                info.Id           = id - MAXPOWERUPSTIRADOR;
            }
            else
            {
                ShooterPowerup = _powerup;
                info.Mode      = GameMode.Shooter;
            }
            //lanzar evento
            OnPowerUpUsed(info);
            PersistenciaManager.instance.SavePowerUps();
        }
    }
Exemplo n.º 19
0
    private void EventOnPan(object sender, TouchScript.Events.GestureStateChangeEventArgs e)
    {
        if (Blocked)
        {
            return;
        }
        bool playingGoalkeeper = GameplayService.IsGoalkeeper();

        if (playingGoalkeeper && BallPhysics.instance.state != BallPhysics.BallState.Flying && BallPhysics.instance.state != BallPhysics.BallState.Waiting && BallPhysics.instance.state != BallPhysics.BallState.Idle)
        {
            return;
        }
        if (ifcBase.activeIface == ifcAyudaInGame.instance)
        {
            return;
        }
        PanGesture panGest = (PanGesture)sender;

        switch (e.State)
        {
        case Gesture.GestureState.Began:
            InitGesture();
            if (!playingGoalkeeper)
            {
                Vector2 ballPos   = new Vector2(Camera.main.WorldToScreenPoint(BallPhysics.instance.transform.position).x, Camera.main.WorldToScreenPoint(BallPhysics.instance.transform.position).y);
                float   inputArea = (3500f * Mathf.Clamp(ifcBase.scaleFactor, 1f, float.MaxValue) * (PowerupService.instance.IsPowerActive(Powerup.Sharpshooter)? 15f : 1f));
#if UNITY_ANDROID || UNITY_IPHONE
                float dpi = (float)Screen.dpi;
                if (dpi < 25 || dpi > 1000)
                {
                    dpi = 100;
                }
                inputArea *= dpi / 100f;
#endif
                if ((panGest.ScreenPosition - ballPos).sqrMagnitude > inputArea)
                {
                    m_finishedGesture    = true;
                    m_initializedGesture = false;
                    return;
                }
                else
                {
                    m_initializedGesture = true;
                }
            }
            else
            {
                Vector3 gkPosition = Goalkeeper.instance.transform.FindChild("Body").GetComponent <Renderer>().bounds.center;
                Vector2 gkPos      = new Vector2(Camera.main.WorldToScreenPoint(gkPosition).x, Camera.main.WorldToScreenPoint(gkPosition).y);

                float inputArea = (3500f * Mathf.Clamp(ifcBase.scaleFactor, 1f, float.MaxValue));
#if UNITY_ANDROID || UNITY_IPHONE
                float dpi = (float)Screen.dpi;
                if (dpi < 25 || dpi > 1000)
                {
                    dpi = 100;
                }
                inputArea *= dpi / 100f;
#endif
                if ((panGest.ScreenPosition - gkPos).sqrMagnitude > (inputArea))
                {
                    m_finishedGesture    = true;
                    m_initializedGesture = false;
                    return;
                }
                else
                {
                    m_initializedGesture = true;
                }
            }
            addPoint(new PanInfo(panGest.ScreenPosition, Time.time));
            break;

        case Gesture.GestureState.Changed:
            if (m_finishedGesture)
            {
                return;
            }
            if (playingGoalkeeper)
            {
                m_lastScreenPosition = panGest.ScreenPosition;
            }

            /*if(m_panPoints.Count <= 1) {
             * addPoint(new PanInfo(panGest.ScreenPosition, Time.time));
             * return;
             * }*/

            Vector2 direction = panGest.PreviousScreenPosition - panGest.ScreenPosition;
            if (direction.sqrMagnitude > m_minSQRDistanceRange)
            {
                addPoint(new PanInfo(panGest.ScreenPosition, Time.time));
            }

            updateLine();
            break;

        case Gesture.GestureState.Ended:
            //addPoint(new PanInfo(panGest.ScreenPosition, Time.time));
            if (m_finishedGesture)
            {
                return;
            }


            if (playingGoalkeeper && (BallPhysics.instance.state == BallPhysics.BallState.Flying || BallPhysics.instance.state == BallPhysics.BallState.Waiting || BallPhysics.instance.state == BallPhysics.BallState.Idle))
            {
                sendDefense(m_lastScreenPosition);
            }
            else if (BallPhysics.instance.state == BallPhysics.BallState.Waiting)
            {
                EndPan();
            }

            ClearEffects();
            break;
        }
    }
Exemplo n.º 20
0
    void Update()
    {
        if (Input.GetKeyUp("escape"))
        {
            if (ifcBase.activeIface == this && ifcPausa.instance.PauseEnabled)
            {
                if (ifcPausa.instance.PauseEnabled)
                {
                    DoPause();
                }
            }
            else if (ifcBase.activeIface != this)
            {
                ifcBase.activeIface.m_backMethod("");
            }
        }
#if UNITY_EDITOR
        if (Input.GetKeyDown("1"))
        {
            PowerupService.instance.UsePowerup((Powerup)0);
        }
        if (Input.GetKeyDown("2"))
        {
            PowerupService.instance.UsePowerup((Powerup)1);
        }
        if (Input.GetKeyDown("3"))
        {
            PowerupService.instance.UsePowerup((Powerup)2);
        }
        if (Input.GetKeyDown("4"))
        {
            PowerupService.instance.UsePowerup((Powerup)3);
        }
        if (Input.GetKeyDown("5"))
        {
            PowerupService.instance.UsePowerup((Powerup)4);
        }
        if (Input.GetKeyDown("6"))
        {
            PowerupService.instance.UsePowerup((Powerup)5);
        }
        if (Input.GetKeyDown("7"))
        {
            PowerupService.instance.UsePowerup((Powerup)6);
        }
        if (Input.GetKeyDown("8"))
        {
            PowerupService.instance.UsePowerup((Powerup)7);
        }
        if (Input.GetKeyDown("9"))
        {
            PowerupService.instance.UsePowerup((Powerup)8);
        }
#endif

        // comprobar si el balon esta en estado de espera
        if (BallPhysics.instance.state == BallPhysics.BallState.Waiting &&
            (GameplayService.IsGoalkeeper() || (GoalCamera.instance.stateMachine.current == ThrowerCameraStates.Init.instance)) &&
            (!InputManager.instance.m_initializedGesture))
        {
            // comprobar si la pastilla de powerups debe estar visible
            if (!cntPastillaPowerups.instance.estaVisible)
            {
                if ((GameplayService.IsGoalkeeper() && !PowerupService.instance.usedGoalkeeperPowerup) || (!GameplayService.IsGoalkeeper() && !PowerupService.instance.usedShooterPowerup))
                {
                    cntPastillaPowerups.instance.Show();
                }
            }
        }
        else
        {
            // asegurarse de que la pastilla de powerups esta oculta
            if (cntPastillaPowerups.instance.estaVisible)
            {
                cntPastillaPowerups.instance.Hide();
            }
        }

        // si la barra de powerups no esta visible
    }
Exemplo n.º 21
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyUp("l"))
        {
            m_debugTrace = !m_debugTrace;
        }

        m_ballTime -= Time.deltaTime;

        /*if(m_ballTime - simAnimTime <= 0.1f && destello)
         * {
         * destello = false;
         * kickEffects.instance.destello(m_ballPoint);
         * }*///destello perfect quitado, mejor no borrar todavia...
        if (m_animName != string.Empty)
        {
            // Endereza al portero hasta m_animTime
            m_animTime -= Time.deltaTime;

            if (m_animTime <= 0f)
            {
                GetComponent <Animation>().CrossFade(m_animName);
                // Lanza la animacion del portero
                m_animationState = GetComponent <Animation>()[m_animName];

                if (ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.GoalKeeper &&
                    !GameplayService.networked)// <= si no estamos en modo duelo
                {
                    GoalCamera.instance.stateMachine.changeState = GoalKeeperCameraStates.Action.instance;
                }

                /*else
                 *  GoalCamera.instance.StateMachine.changeState = ThrowerCameraStates.Action.instance; */
                m_animName = "";
            }
        }

        if (m_animationState != null && m_animationState.enabled)
        {
            if (m_ballTime <= 0)
            {
                m_animationState.speed = 1f;
            }
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.identity, 0.05f);
        }

        if ((m_animationState != null && !m_animationState.enabled && !m_ready) || (doGOAnim && (m_animationState == null || !m_animationState.enabled)))
        {
            if (!ServiceLocator.Request <IPlayerService>().IsGameOver() || forceRePositioning)
            {
                forceRePositioning = false;
                Vector3 pos = m_bip01.transform.position;
                pos.y = 0;
                transform.position = pos;
            }
            else if (doGOAnim)
            {
                doGOAnim = false;
                Vector3 pos = m_bip01.transform.position;
                pos.y = 0;
                transform.position = pos;
                m_ready            = false;
                m_animTime         = 0f;


                bool isPlayer1 = GameplayService.initialGameMode != GameMode.Shooter;
                int  score1    = isPlayer1 ? Player.serverState.score_1 : Player.serverState.score_2;
                int  score2    = isPlayer1 ? Player.serverState.score_2 : Player.serverState.score_1;

                bool victory = (ServiceLocator.Request <IPlayerService>().GetPlayerInfo().Attempts > 0);



                if (GameplayService.networked)
                {
                    victory = (score1 > score2) && GameplayService.IsGoalkeeper() || (score1 < score2) && !GameplayService.IsGoalkeeper();
                }
                else
                {
                    if (MissionManager.instance.GetMission().PlayerType == GameMode.Shooter)
                    {
                        victory = !victory;
                    }
                }

                if (!victory)
                {
                    //animaciones de GameOver
                    m_animName = "P_FalloFinal";
                    m_animIdle = "P_IdleFalloFinal";
                    m_grab     = false;
                }
                else
                {
                    if (GrabBall)
                    {
                        m_animName         = "P_Celebracion_03";
                        forceRePositioning = true;
                    }
                    else
                    {
                        m_animName = "P_CelebracionFinal";
                    }

                    m_animIdle = "P_IdleCelebracionFinal";
                }
                GetComponent <Animation>().Play(m_animName);
                return;
            }
            if (m_animIdle == string.Empty)
            {
                m_animIdle = "P_Idle01";
            }
            GetComponent <Animation>().Play(m_animIdle);

            GetComponent <Animation>().Sample();
            m_animationState = null;
        }
    }
Exemplo n.º 22
0
    void Update()
    {
        m_offset += Time.deltaTime * 1.5f;
        line.material.SetTextureOffset("_MainTex", new Vector2(m_offset, 0));

        if (isActive && !hide)
        {
            GameObject.Find("pastilla_tuto/texto").GetComponent <txtText>().SetText(m_textoActual);
            GameObject.Find("pastilla_tuto/texto/sombra").GetComponent <txtText>().SetText(m_textoActual);
            if (!GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallPhysics.BallState.Waiting)
            {
                float mov = Vector3.Distance(Camera.main.transform.position, prevCameraPosition);
                prevCameraPosition = Camera.main.transform.position;
                if (MissionManager.instance.GetMission().indexMision == 0 && mov < 0.01f)
                {
                    if (ServiceLocator.Request <IDifficultyService>().GetRounds() > 2)
                    {
                        LoadThrowerTutorial_2();
                    }
                    else
                    {
                        LoadThrowerTutorial_1();
                    }
                }
            }
            if (GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallPhysics.BallState.Flying)
            {
                if (MissionManager.instance.GetMission().indexMision == 1)
                {
                    LoadGoalkeeperTutorial();
                }
            }
            else if (GameplayService.IsGoalkeeper())
            {
                line.SetVertexCount(0);
            }
        }

        /*if(isActive && !hide)
         * {
         *  if(GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallPhysics.BallState.Flying)
         *  {
         *      GameObject.Find("pastilla_tuto/texto").GetComponent<GUIText>().text = "Para realizar una parada, sigue el\ntrazo desde el portero al punto rojo.";
         *      LoadGoalkeeperTutorial();
         *  }
         *  else
         *  {
         *      line.SetVertexCount(0);
         *  }
         *
         *  if(!GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallPhysics.BallState.Waiting)
         *  {
         *      switch(step)
         *      {
         *      case 0:
         *      case 1:
         *          GameObject.Find("pastilla_tuto/texto").GetComponent<GUIText>().text = "Sigue el trazo desde el balón a la diana\npara efectuar tu lanzamiento";
         *          LoadThrowerTutorial_1();
         *          break;
         *      case 2:
         *      case 3:
         *          GameObject.Find("pastilla_tuto/texto").GetComponent<GUIText>().text = "Puedes añadir efecto a tus lanzamientos.\nSigue el trazo y verás el resultado.";
         *          LoadThrowerTutorial_2();
         *          break;
         *      }
         *  }
         * }*/
    }
Exemplo n.º 23
0
    public Vector3 GetGrab(DefenseInfo _info)
    {
        bool playingGoalkeeper = ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.GoalKeeper;

        m_ready   = false;
        ClearBall = false;
        GrabBall  = false;

        if (_info.Result == GKResult.Idle)
        {
            return(_info.Target);
        }

        transform.position = new Vector3(0, 0, -49.5f);
        bool   success = true;
        string sufix   = MakeAnimSufix(_info.Target);

        if (sufix == "")
        {
            m_animName = "";
            m_animIdle = "";
            return(_info.Target);
        }

        if (!GameplayService.IsGoalkeeper())
        {
            lastResult = GKResult.IAFail;
        }


        float precision = Mathf.Clamp01(Vector3.Distance(_info.Target, m_ballPoint)
                                        / ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(_info.Target));

        if (m_debugTrace)
        {
            Debug.Log("PRECISION: " + precision);
            kickEffects.instance.DebugCircle(_info.Target, ServiceLocator.Request <IDifficultyService>().GetPerfectRadius() * 2f, new Color(1, 0.5f, 0));
            kickEffects.instance.DebugCircle(_info.Target, ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(_info.Target) * 2f, Color.cyan);
            kickEffects.instance.DebugTarget(m_ballPoint);
        }

        if (!GameplayService.networked && !playingGoalkeeper)
        {
            precision = Random.Range(0f, 1f);
        }

        #region powerup reflejo
        if (PowerupService.instance.IsPowerActive(Powerup.Reflejo))
        {
            int casillaX = (int)GetCasilla(_info.Target).x;
            if (casillaX == 7)
            {
                casillaX = 6;
            }
            else if (casillaX == 0)
            {
                casillaX = 1;
            }


            Vector3[] targets = { GetCasillaPosition(casillaX + 1, 0), GetCasillaPosition(casillaX, 0), GetCasillaPosition(casillaX - 1, 0),
                                  GetCasillaPosition(casillaX + 1, 1), GetCasillaPosition(casillaX, 1), GetCasillaPosition(casillaX - 1, 1),
                                  GetCasillaPosition(casillaX + 1, 2), GetCasillaPosition(casillaX, 2), GetCasillaPosition(casillaX - 1, 2) };

            /*Vector3[] targets = {GetCasillaPosition(0,0), GetCasillaPosition(1,0), GetCasillaPosition(2,0), GetCasillaPosition(3,0), GetCasillaPosition(4,0), GetCasillaPosition(5,0), GetCasillaPosition(6,0), GetCasillaPosition(7,0),
             *  GetCasillaPosition(0,1), GetCasillaPosition(1,1), GetCasillaPosition(2,1), GetCasillaPosition(3,1), GetCasillaPosition(4,1), GetCasillaPosition(5,1), GetCasillaPosition(6,1), GetCasillaPosition(7,1),
             *  GetCasillaPosition(0,2), GetCasillaPosition(1,2), GetCasillaPosition(2,2), GetCasillaPosition(3,2), GetCasillaPosition(4,2), GetCasillaPosition(5,2), GetCasillaPosition(6,2), GetCasillaPosition(7,2)
             * };*/

            /*Vector3[] targets = {GetCasillaPosition(0,0), GetCasillaPosition(1,0), GetCasillaPosition(2,0),
             *  GetCasillaPosition(0,1), GetCasillaPosition(1,1), GetCasillaPosition(2,1),
             *  GetCasillaPosition(0,2), GetCasillaPosition(1,2), GetCasillaPosition(2,2)
             * };*/

            Time.timeScale = 0.5f;

            for (int i = 0; i < targets.Length; i++)
            {
                Vector3 mirrorTarget = targets[i];//new Vector3(_info.Target.x * -1f , _info.Target.y, _info.Target.z);
                float   precision2   = Mathf.Clamp01(Vector3.Distance(mirrorTarget, m_ballPoint)
                                                     / ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(mirrorTarget));

                Vector3 mirrorPos = _info.Target;
                if (precision2 < precision)
                {
                    mirrorPos    = _info.Target;
                    precision    = precision2;
                    sufix        = MakeAnimSufix(mirrorTarget);
                    _info.Target = mirrorTarget;
                }
                else
                {
                    mirrorPos = mirrorTarget;
                }

                GameObject doppelganger = Instantiate(FieldControl.instance.goalKeeperPrefab[FieldControl.instance.doppelgangerindex], Goalkeeper.instance.transform.position, Goalkeeper.instance.transform.rotation) as GameObject;

                Destroy(doppelganger.GetComponent <Goalkeeper>());//.enabled = false;

                string mirrorAnimName = MakeAnimSufix(mirrorPos);
                mirrorAnimName += "_01";
                mirrorAnimName  = "P_Dpj" + mirrorAnimName;

                doppelganger.GetComponent <Animation>()[mirrorAnimName].speed = m_animationDescriptorsResource.GetByName(mirrorAnimName).m_grabTime / m_ballTime;

                Doppelganger comp = doppelganger.AddComponent <Doppelganger>();
                comp.m_balltime = m_ballTime;
                comp.m_animName = mirrorAnimName;

                doppelganger.GetComponent <Animation>().Play(mirrorAnimName);
                kickEffects.instance.DoDoppelganger(doppelganger);
            }
        }
        #endregion

        if (playingGoalkeeper)
        {
            //if(m_ballCasilla == sufix) success = true;
            if (precision < successPrecision)
            {
                success = true;
            }
            else
            {
                success = false;
            }
        }
        else
        {
            success = _info.Result == GKResult.Good || _info.Result == GKResult.Perfect;
        }

        if (success)
        {
            sufix = m_ballCasilla;
        }

        sufix += "_01";

        m_animName = "P_Dpj" + sufix;

        m_descriptor = m_animationDescriptorsResource.GetByName(m_animName);

        bool possiblePerfect = false;
        lastPerfect = false;

        if (playingGoalkeeper)
        {
            SetGrabTime(m_descriptor.m_grabTime);

            if (m_animTime <= 0f && !(lastResult == GKResult.Early)) //para comprobar que no se haya hecho la defensa antes incluso de chutar, da 0 en ese caso
            {
                lastResult = GKResult.Late;
                success    = false;
            }
            else if (m_animTime >= 1f)
            {
                lastResult = GKResult.Early;
                success    = false;
                m_animTime = 0.1f;
            }
            else if (m_animTime <= 0.2f && success)
            {
                possiblePerfect = true;
                success         = true;
            }
            else if (m_animTime <= 0.4f && success)
            {
                success = true;
            }
            else if (!success)
            {
                lastResult = GKResult.Fail;
                m_animTime = 0f;
            }
        }

        m_animIdle = "P_Idle01";

        ClearBall = success;

        //preparar el perfect
        float precisionDist  = ServiceLocator.Request <IDifficultyService>().GetPerfectRadius();
        bool  perfectRadius  = Vector3.Distance(_info.Target, m_ballPoint) <= precisionDist;
        float precisionRatio = precisionDist / ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(_info.Target);

        if (PowerupService.instance.IsPowerActive(Powerup.Resbaladiza) && success)
        {
            float max        = successPrecision - precisionRatio;
            float transfProb = (precision - precisionRatio);
            float finalProb  = 0f;
            if (transfProb < 0f)
            {
                finalProb = 0.25f;
            }
            else if (transfProb > max)
            {
                finalProb = 0.55f;
            }
            else
            {
                finalProb = 0.4f * (transfProb / max) + 0.1f;
            }
            bool forcedFail = finalProb > Random.Range(0f, 1f);
            BallPhysics.instance.noCatch = forcedFail;
            Debug.Log("GreasyBall prob = " + finalProb);
        }

        if (BallPhysics.instance.state != BallPhysics.BallState.Idle)
        {
            if ((playingGoalkeeper && success && perfectRadius) ||
                (!playingGoalkeeper && _info.Result == GKResult.Perfect))
            {
                if (possiblePerfect || !playingGoalkeeper)
                {
                    AnimationDescriptorsResource.AnimationDescriptorResource tempDescriptor = m_animationDescriptorsResource.GetByName("P_Par" + sufix);
                    if (tempDescriptor != null)
                    {
                        m_animName   = "P_Par" + sufix;
                        m_animIdle   = "P_IdleCB01";
                        m_descriptor = tempDescriptor;
                        GrabBall     = true;
                    }
                }
            }
            else
            {
                possiblePerfect = false;
            }
        }


        if (playingGoalkeeper && possiblePerfect)
        {
            lastResult    = GKResult.Perfect;
            lastPrecision = 0;
            GeneralSounds.instance.perfect();
            possiblePerfect = true;
        }
        else if (playingGoalkeeper && success)
        {
            if (precision < 0.2)
            {
                lastPrecision = 1;
            }
            else if (precision < 0.45)
            {
                lastPrecision = 2;
            }
            else
            {
                lastPrecision = 3;
            }
            lastResult      = GKResult.Good;
            possiblePerfect = false;
        }
        lastPerfect = possiblePerfect;

        forceWin = success;

        if (playingGoalkeeper && success)
        {
            AdjustAnimation();
        }


        Vector3 preResult = transform.position + m_descriptor.m_grabDiff;

        //preResult.z = InputManager.planeGoalClose.distance;
        return(preResult);
    }
Exemplo n.º 24
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Sabana")
        {
            if (collision.gameObject.GetComponent <Animation>() != null && !collision.gameObject.GetComponent <Animation>().isPlaying)
            {
                collision.gameObject.GetComponent <Animation>().Play();
            }
            if (!GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallState.Flying)
            {
                GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.HitBarrera.instance;
            }
            if (state != BallState.Cooldown)
            {
                state = BallState.Idle;
            }
            GeneralSounds.instance.barrera();
            kickEffects.instance.setSabana = true;
        }

        if (collision.gameObject.tag == "Poste")
        {
            GeneralSounds.instance.posteHit();
            if (state == BallState.Flying)
            {
                kickEffects.instance.setPoste = true;
            }
            if (!GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallState.Flying)
            {
                GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.HitBarrera.instance;
            }
            if (state != BallState.Cooldown)
            {
                state = BallState.Idle;
            }
        }

        if (collision.gameObject.tag == "Red")
        {
            GeneralSounds.instance.posteHit();
            if (state == BallState.Flying)
            {
                kickEffects.instance.setPoste = true;
            }
            if (!GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallState.Flying)
            {
                GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.HitBarrera.instance;
            }
            if (state != BallState.Cooldown)
            {
                state = BallState.Idle;
            }
        }

        if (collision.gameObject.tag == "Larguero")
        {
            GeneralSounds.instance.posteHit();
            if (state == BallState.Flying)
            {
                kickEffects.instance.setLarguero = true;
            }
            if (!GameplayService.IsGoalkeeper() && BallPhysics.instance.state == BallState.Flying)
            {
                GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.HitBarrera.instance;
            }
            if (state != BallState.Cooldown)
            {
                state = BallState.Idle;
            }
        }

        if (collision.gameObject.tag == "Barrera")
        {
            GeneralSounds.instance.posteHit();
            if (state != BallState.Cooldown)
            {
                state = BallState.Idle;
            }
            if (!GameplayService.IsGoalkeeper())
            {
                GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.HitBarrera.instance;
            }
            GeneralSounds.instance.barrera();
            kickEffects.instance.setBarrera = true;
        }

        if ((collision.gameObject.tag == "Grass") && (state == BallState.Idle || state == BallState.Cooldown))
        {
            GeneralSounds.instance.miniHit();
        }
        if (collision.gameObject.tag == "Red" && (state == BallState.Flying))
        {
            GeneralSounds.instance.redHit();
        }

        if (state == BallState.Flying && (collision.gameObject.tag != "Grass"))
        {
            if (state != BallState.Cooldown)
            {
                state = BallState.Idle;
            }
        }
    }