예제 #1
0
    private void Update()
    {
        Debug.Log(_isOptionOrPlayOpen);

        if (_isOptionOrPlayOpen)
        {
            _animator.SetBool("IsSlingshoting", false);
            _myRb.velocity = Vector2.zero;
            _timerPower    = 0;
        }


        if (_playerInput == INPUTSTATE.GivingInput && _mustPlayCastSound)
        {
            _newSoundManagerScript.PlayCharge(int.Parse(gameObject.tag.Substring(gameObject.tag.Length - 1)) - 1);
            _mustPlayCastSound = false;
        }
        else if (_playerInput == INPUTSTATE.None)
        {
            _newSoundManagerScript.StopCharge(int.Parse(gameObject.tag.Substring(gameObject.tag.Length - 1)) - 1);
            _mustPlayCastSound = true;
        }

        if (_menuInformationScript == null || _menuInformationScript.GetVibrationsValue())
        {
            if (powerJauge.fillAmount > vibrationTreshold)
            {
                if (gameObject.tag == "Player1")
                {
                    _playerManagerScript.Vibration(_playerManagerScript._player, 0, 1.0f, vibrationTreshold * 0.5f);
                }
                vibrationTreshold += 0.2f;
            }
            else if (powerJauge.fillAmount == vibrationTreshold)
            {
                if (gameObject.tag == "Player1")
                {
                    _playerManagerScript.Vibration(_playerManagerScript._player, 0, 1.0f, tooMuchPowerTimerMax);
                }
            }
        }
    }
예제 #2
0
    private void Update()
    {
        float velX = Mathf.Abs(_myRb.velocity.x);
        float velY = Mathf.Abs(_myRb.velocity.y);

        velX = Mathf.Clamp(velX, 0, 3);
        velY = Mathf.Clamp(velY, 0, 3);

        if (velY >= 1 && velX >= 1)
        {
            squash = ((velY + velX) / speedSquashMultiplier);
        }
        else
        {
            squash = 0.0001f;
        }

        playerSprite.transform.localScale = new Vector3((squash / -2) + originalScale, squash + originalScale, playerSprite.transform.localScale.z);


        if (playerScaleHitWall)
        {
            squashWall = ((velX + velY) / scaleMultiplier);

            timerScale += Time.deltaTime;
            float lerpScaleRatio = timerScale / timerScaleMax;
            playerSprite.transform.localScale = Vector3.Lerp(new Vector3(originalScale, originalScale, originalScale), new Vector3(squashWall + originalScale, (squashWall / -2) + originalScale, playerSprite.transform.localScale.z), lerpScaleRatio);
            if (lerpScaleRatio >= 1)
            {
                timerRescale += Time.deltaTime;
                float lerpRescaleRatio = timerRescale / timerRescaleMax;
                playerSprite.transform.localScale = Vector3.Lerp(playerSprite.transform.localScale, new Vector3(originalScale, originalScale, originalScale), lerpRescaleRatio);
                if (lerpRescaleRatio >= 1)
                {
                    timerScale         = 0;
                    timerRescale       = 0;
                    playerScaleHitWall = false;
                }
            }
        }


        //si les onomatopées sont activés, lance le timer de désactivation
        if (onomatopéesSprite.enabled)
        {
            onomatopéeTimer += Time.deltaTime;
            if (onomatopéeTimer >= onomatopéeTimerMax)
            {
                onomatopéeTimer = 0;
                _animator.SetBool("isHit", false);
                _animator.SetBool("isHitting", false);
                _playerScoreImage.sprite = _playerScoreImageSprites[2];

                onomatopéesSprite.enabled = false;
            }
        }

        //si la jauge d'ulti est inférieure à 1/3 du max, ne fait pas apparaitre les FXs
        if (_ultiCurrentCharge < ultiChargeMax * 0.33f)
        {
            UltiFxStates[0].SetActive(false);
            UltiFxStates[1].SetActive(false);
            UltiFxStates[2].SetActive(false);
        }

        //permet de changer la position du sprite qui apparait quand on touche le mur et de lui lancer son timer de désactivation
        if (wallSpriteTransform.gameObject.activeSelf)
        {
            wallSpriteTransform.position      = wallSpritePosition;
            wallSpriteTransform.localPosition = new Vector3(wallSpriteTransform.localPosition.x, wallSpriteTransform.localPosition.y, 8);
            wallHitSpriteTimer += Time.deltaTime;
            if (wallHitSpriteTimer >= wallHitSpriteTimerMax)
            {
                wallHitSpriteTimer = 0;
                wallSpriteTransform.gameObject.SetActive(false);
            }
        }

        //si on a utilisé l'ulti, reset la jauge.
        if (_ultiCurrentCharge == ultiChargeMax && !_isUltiPossible)
        {
            _ultiCurrentCharge = 0;
        }

        //active et désactive le son de charge.
        if (_playerInput == INPUTSTATE.GivingInput && _mustPlayCastSound)
        {
            if (_newSoundManagerScript != null)
            {
                _newSoundManagerScript.PlayCharge(int.Parse(gameObject.tag.Substring(gameObject.tag.Length - 1)) - 1);
            }
            _mustPlayCastSound = false;
        }
        else if (_playerInput == INPUTSTATE.None)
        {
            if (_newSoundManagerScript != null)
            {
                _newSoundManagerScript.StopCharge(int.Parse(gameObject.tag.Substring(gameObject.tag.Length - 1)) - 1);
            }
            _mustPlayCastSound = true;
        }

        //active les différents stades de vibrations

        if (_menuInformationScript == null || _menuInformationScript.GetVibrationsValue())
        {
            if (powerJauge.fillAmount > vibrationTreshold)
            {
                if (gameObject.tag == "Player1")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[0], 0, 1.0f, vibrationTreshold * 0.5f);
                }
                else if (gameObject.tag == "Player2")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[1], 0, 1.0f, vibrationTreshold * 0.5f);
                }
                if (gameObject.tag == "Player3")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[2], 0, 1.0f, vibrationTreshold * 0.5f);
                }
                else if (gameObject.tag == "Player4")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[3], 0, 1.0f, vibrationTreshold * 0.5f);
                }
                vibrationTreshold += 0.2f;
            }
            else if (powerJauge.fillAmount == vibrationTreshold)
            {
                if (gameObject.tag == "Player1")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[0], 0, 1.0f, tooMuchPowerTimerMax);
                }
                else if (gameObject.tag == "Player2")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[1], 0, 1.0f, tooMuchPowerTimerMax);
                }
                if (gameObject.tag == "Player3")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[2], 0, 1.0f, tooMuchPowerTimerMax);
                }
                else if (gameObject.tag == "Player4")
                {
                    _playerManagerScript.Vibration(_playerManagerScript.player[3], 0, 1.0f, tooMuchPowerTimerMax);
                }
            }
        }
    }