Esempio n. 1
0
 //définit l'apparence de l'outline du mur selon sa propriété
 public Mesh[] UpdateWallShadowAppearance(WallProprieties wallProprieties)
 {
     if (wallProprieties.GetIsBouncy())
     {
         Mesh[] tempWallShadowAppearance = new Mesh[wallBouncyShadowAppearance.Length];
         for (int i = 0; i < wallBouncyShadowAppearance.Length; i++)
         {
             tempWallShadowAppearance[i] = wallBouncyShadowAppearance[i];
         }
         return(tempWallShadowAppearance);
     }
     else if (wallProprieties.GetIsIndestructible())
     {
         Mesh[] tempWallShadowAppearance = new Mesh[wallIndestructibleShadowAppearance.Length];
         for (int i = 0; i < wallIndestructibleShadowAppearance.Length; i++)
         {
             tempWallShadowAppearance[i] = wallIndestructibleShadowAppearance[i];
         }
         return(tempWallShadowAppearance);
     }
     else
     {
         Mesh[] tempWallShadowAppearance = new Mesh[wallNormalShadowAppearance.Length];
         for (int i = 0; i < wallNormalShadowAppearance.Length; i++)
         {
             tempWallShadowAppearance[i] = wallNormalShadowAppearance[i];
         }
         return(tempWallShadowAppearance);
     }
 }
Esempio n. 2
0
 //gère les dommages des murs connectés
 public void ConnectedtWallDammage(float myDammage, GameObject thisWall, WallProprieties connectedWallProprieties, WallChange connectedWallChange)
 {
     if (!connectedWallProprieties.GetIsIndestructible())
     {
         connectedWallChange.SetDammageFromConnect(myDammage);
     }
 }
Esempio n. 3
0
    //définit quel mur affiché selon sa propriété
    public void WhichWall(WallProprieties wallProprieties)
    {
        if (wallProprieties.GetIsBouncy())
        {
            wallProprieties.theWalls[2].SetActive(true);
        }
        else if (wallProprieties.GetIsIndestructible())
        {
            wallProprieties.theWalls[1].SetActive(true);
        }
        else
        {
            wallProprieties.theWalls[0].SetActive(true);
        }

        if (wallProprieties.GetIsConnected())
        {
            wallProprieties.theWalls[3].SetActive(true);
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        if (_isWallShaking)
        {
            ShakeWall();
        }

        if (_isShaderNeeded)
        {
            if (_shaderLerp <= 1 && !_hasShaderCompletelyAppeared)
            {
                _shaderLerp += Time.deltaTime * _shaderLerpMax;
                if (_shaderLerp >= 1)
                {
                    _shaderLerp = 1;
                    _hasShaderCompletelyAppeared = true;
                }
            }
            else if (_shaderLerp >= -1 && _hasShaderCompletelyAppeared)
            {
                _shaderLerp -= Time.deltaTime * _shaderLerpMax;
                if (_shaderLerp <= -1)
                {
                    _shaderLerp = -1;
                    _hasShaderCompletelyAppeared = false;
                    _isShaderNeeded = false;
                }
            }

            _shaderRenderer.material.SetFloat("_Etatdudissolve", _shaderLerp);
        }

        if (_attackTestOnCollision != null)
        {
            lerpTimerRatio += Time.deltaTime;
            _attackTestOnCollision.GetPlayerScoreImage().color = Color32.Lerp(_attackTestOnCollision.GetPlayerScoreImage().color, new Color32(255, 255, 255, 100), lerpTimerRatio);
            if (lerpTimerRatio >= 1)
            {
                lerpTimerRatio         = 0;
                _attackTestOnCollision = null;
            }
        }



        if (lastEjectedPlayer != null && lastEjectedPlayer.GetComponent <AttackTest>().hasPositionBeenSet())
        {
            _gameManagerScript.currentFace    = _nextFace - 1;
            _arenaRotationScript._currentFace = _nextFace - 1;
            lastEjectedPlayer = null;
        }
        //si la caméra est en train de changer de face, désactive les sprites ainsi que les colliders des murs, reset la vie des murs et
        //actualise la face actuelle de la caméra
        if (_arenaRotationScript._isTurning)
        {
            _hasCreatedArrayTwo = false;
            _hasCreatedArray    = false;
            _wallProprieties.UpdateProprieties();
            _wallManagerScript.WhichWall(_wallProprieties);
            _wallProprieties.IAmConnectedIMustConnect();
            InitiateWall();
            _wallCollider[0].enabled  = true;
            _wallCollider[1].enabled  = false;
            _wallMeshRenderer.enabled = true;

            _currentFace = _arenaRotationScript._currentFace;
            _lastHit     = false;
            wallLife     = _wallLifeMax;
            if (!_wallProprieties.GetIsBouncy())
            {
                _wallMesh.mesh = wallAppearance[0];
                _wallShadowMeshRenderer.enabled = true;
                _wallShadowMesh.mesh            = wallShadowAppearance[0];
            }
            else
            {
                _wallBambouAppearance.sharedMesh         = wallAppearance[0];
                _wallBambouAppearance.enabled            = true;
                _wallShadowMeshRendererBambou.enabled    = true;
                _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[0];
            }

            if (!_wallProprieties.GetIsIndestructible())
            {
                if (_wallProprieties.GetIsBouncy())
                {
                    _meshMaterialsBambou[0].color = new Color32(30, 255, 0, 255);
                }
                //réinitialise le tableau de matériaux du mur normal
                else
                {
                    _meshMaterials[0].color = new Color32(30, 255, 0, 255);
                    Material[] temp = new Material[_wallMeshRendererOriginalMaterials.Length];
                    for (int i = 0; i < temp.Length; i++)
                    {
                        temp[i] = _wallMeshRendererOriginalMaterials[i];
                    }
                    _wallMeshRenderer.materials = temp;
                }
            }
            if (gameObject.layer == 15)
            {
                gameObject.SetActive(false);
                _wallShadowMeshRenderer.enabled = false;
                if (_wallShadowMeshRendererBambou != null)
                {
                    _wallShadowMeshRendererBambou.enabled = false;
                }
            }

            if (gameObject.layer == 14)
            {
                gameObject.SetActive(true);
                BoxCollider2D[] boxColliderTab = GetComponents <BoxCollider2D>();
                for (int i = 0; i < boxColliderTab.Length; i++)
                {
                    boxColliderTab[i].enabled = false;
                }
            }
        }


        if (wallLife == _wallLifeMax)
        {
            if (_wallProprieties.GetIsBouncy())
            {
                if (_hasPlayerCollided)
                {
                    _bouncyAnimator.SetBool("isState4", true);
                }
                else
                {
                    _bouncyAnimator.SetBool("isState4", false);
                }
            }
        }
        if (wallLife <= 0)
        {
            _lastHit = true;
            if (transform.GetChild(3).gameObject.activeSelf)
            {
                transform.GetChild(3).gameObject.SetActive(false);
            }
            if (numberWallState > numberWallStateMax - 4)
            {
                ShakeScreen();
            }
            _wallMeshRenderer.enabled = false;

            if (!_wallProprieties.GetIsBouncy())
            {
                _wallShadowMeshRenderer.enabled = false;
            }
            else
            {
                _wallBambouAppearance.enabled         = false;
                _wallShadowMeshRendererBambou.enabled = false;
            }

            _wallCollider[0].enabled = false;
            _wallCollider[1].enabled = true;
        }
        else if (wallLife < _wallLifeMax && wallLife >= (_wallLifeMax * 0.66))
        {
            if (numberWallState > numberWallStateMax - 1)
            {
                ShakeScreen();
            }
            if (!_wallProprieties.GetIsBouncy())
            {
                _wallMesh.mesh       = wallAppearance[1];
                _wallShadowMesh.mesh = wallShadowAppearance[1];
            }
            else
            {
                _wallBambouAppearance.sharedMesh         = wallAppearance[1];
                _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[1];
                if (_hasPlayerCollided)
                {
                    _bouncyAnimator.SetBool("isState3", true);
                }
                else
                {
                    _bouncyAnimator.SetBool("isState3", false);
                }
            }
        }
        else if (wallLife < (_wallLifeMax * 0.66) && wallLife > (_wallLifeMax * 0.33))
        {
            if (numberWallState > numberWallStateMax - 2)
            {
                ShakeScreen();
            }

            if (!_wallProprieties.GetIsBouncy())
            {
                _wallMesh.mesh       = wallAppearance[2];
                _wallShadowMesh.mesh = wallShadowAppearance[2];
                //on change le nombre de matériaux du mur normal car son mesh a changé
                if (!_wallProprieties.GetIsIndestructible() && !_hasCreatedArray)
                {
                    Material[] temp = new Material[(3)]; /*_wallMeshRenderer.materials.Length - 2*/ //valeur d'avant au cas où bugg
                    for (int i = 0; i < temp.Length; i++)
                    {
                        temp[i] = _wallMeshRenderer.materials[i];
                    }
                    _wallMeshRenderer.materials = temp;
                    _hasCreatedArray            = true;
                }
            }
            else
            {
                _wallBambouAppearance.sharedMesh         = wallAppearance[2];
                _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[2];
                if (_hasPlayerCollided)
                {
                    _bouncyAnimator.SetBool("isState2", true);
                }
                else
                {
                    _bouncyAnimator.SetBool("isState2", false);
                }
            }
        }
        else if (wallLife < (_wallLifeMax * 0.33) && wallLife > 0)
        {
            if (numberWallState > numberWallStateMax - 3)
            {
                ShakeScreen();
            }


            if (!_wallProprieties.GetIsBouncy())
            {
                _wallMesh.mesh       = wallAppearance[3];
                _wallShadowMesh.mesh = wallShadowAppearance[3];
                //on change le nombre de matériaux du mur normal car son mesh a changé
                if (!_wallProprieties.GetIsIndestructible() && !_hasCreatedArrayTwo)
                {
                    Material[] temp = new Material[(2)]; /*_wallMeshRenderer.materials.Length - 1*/ //valeur d'avant au cas où bugg
                    for (int i = 0; i < temp.Length; i++)
                    {
                        temp[i] = _wallMeshRenderer.materials[i];
                    }
                    _wallMeshRenderer.materials = temp;
                    _hasCreatedArrayTwo         = true;
                }
            }
            else
            {
                _wallBambouAppearance.sharedMesh         = wallAppearance[3];
                _wallShadowMeshRendererBambou.sharedMesh = wallShadowAppearance[3];
                if (_hasPlayerCollided)
                {
                    _bouncyAnimator.SetBool("isState1", true);
                }
                else
                {
                    _bouncyAnimator.SetBool("isState1", false);
                }
            }
        }
    }