//<summary>
    //Checks if the camera moves into the cylinder or quad mounted by the corresponding waterplane
    //Works with circular and squared planes
    //<returns>underWater</returns>
    //</summary>
    bool CheckIfUnderWater(int waterPlanesCount)
    {
        if (!gameObjects.useSquaredPlanes)
        {
            for (int i = 0; i < waterPlanesCount; i++)
            {
                if (Mathf.Pow((transform.position.x - gameObjects.waterPlanes[i].transform.position.x), 2) + Mathf.Pow((transform.position.z - gameObjects.waterPlanes[i].transform.position.z), 2) < Mathf.Pow(gameObjects.waterPlanes[i].GetComponent <Renderer> ().bounds.extents.x, 2))
                {
                    if (activePlane != lastActivePlane)
                    {
                        if (gameObjects.waterPlanes[activePlane].transform.Find("PrimaryCausticsProjector") != null)
                        {
                            primaryCausticsProjector = gameObjects.waterPlanes[activePlane].transform.Find("PrimaryCausticsProjector").GetComponent <Projector>();
                            primaryAquasCaustics     = gameObjects.waterPlanes[activePlane].transform.Find("PrimaryCausticsProjector").GetComponent <AQUAS_Caustics>();
                        }

                        if (gameObjects.waterPlanes[activePlane].transform.Find("SecondaryCausticsProjector") != null)
                        {
                            secondaryCausticsProjector = gameObjects.waterPlanes[activePlane].transform.Find("SecondaryCausticsProjector").GetComponent <Projector>();
                            secondaryAquasCaustics     = gameObjects.waterPlanes[activePlane].transform.Find("SecondaryCausticsProjector").GetComponent <AQUAS_Caustics>();
                        }

                        lastActivePlane = activePlane;
                    }

                    activePlane = i;

                    if (transform.position.y < gameObjects.waterPlanes[i].transform.position.y)
                    {
                        waterPlaneMaterial = gameObjects.waterPlanes[i].GetComponent <Renderer> ().material;
                        activePlane        = i;
                        return(true);
                        //break;
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < waterPlanesCount; i++)
            {
                if (Mathf.Abs(transform.position.x - gameObjects.waterPlanes[i].transform.position.x) < gameObjects.waterPlanes[i].GetComponent <Renderer>().bounds.extents.x&& Mathf.Abs(transform.position.z - gameObjects.waterPlanes[i].transform.position.z) < gameObjects.waterPlanes[i].GetComponent <Renderer> ().bounds.extents.z)
                {
                    if (activePlane != lastActivePlane)
                    {
                        if (gameObjects.waterPlanes[activePlane].transform.Find("PrimaryCausticsProjector") != null)
                        {
                            primaryCausticsProjector = gameObjects.waterPlanes[activePlane].transform.Find("PrimaryCausticsProjector").GetComponent <Projector>();
                            primaryAquasCaustics     = gameObjects.waterPlanes[activePlane].transform.Find("PrimaryCausticsProjector").GetComponent <AQUAS_Caustics>();
                        }

                        if (gameObjects.waterPlanes[activePlane].transform.Find("SecondaryCausticsProjector") != null)
                        {
                            secondaryCausticsProjector = gameObjects.waterPlanes[activePlane].transform.Find("SecondaryCausticsProjector").GetComponent <Projector>();
                            secondaryAquasCaustics     = gameObjects.waterPlanes[activePlane].transform.Find("SecondaryCausticsProjector").GetComponent <AQUAS_Caustics>();
                        }

                        lastActivePlane = activePlane;
                    }

                    activePlane = i;

                    if (transform.position.y < gameObjects.waterPlanes[i].transform.position.y)
                    {
                        waterPlaneMaterial = gameObjects.waterPlanes[0].GetComponent <Renderer> ().material;
                        activePlane        = i;
                        return(true);
                        //break;
                    }
                }
            }
        }
        return(false);
    }
 private bool CheckIfUnderWater(int waterPlanesCount)
 {
     if (!this.gameObjects.useSquaredPlanes)
     {
         for (int index = 0; index < waterPlanesCount; ++index)
         {
             double num1   = (double)Mathf.Pow((float)(((Component)this).get_transform().get_position().x - this.gameObjects.waterPlanes[index].get_transform().get_position().x), 2f) + (double)Mathf.Pow((float)(((Component)this).get_transform().get_position().z - this.gameObjects.waterPlanes[index].get_transform().get_position().z), 2f);
             Bounds bounds = ((Renderer)this.gameObjects.waterPlanes[index].GetComponent <Renderer>()).get_bounds();
             double num2   = (double)Mathf.Pow((float)((Bounds) ref bounds).get_extents().x, 2f);
             if (num1 < num2)
             {
                 if (this.activePlane != this.lastActivePlane)
                 {
                     if (Object.op_Inequality((Object)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("PrimaryCausticsProjector"), (Object)null))
                     {
                         this.primaryCausticsProjector = (Projector)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("PrimaryCausticsProjector")).GetComponent <Projector>();
                         this.primaryAquasCaustics     = (AQUAS_Caustics)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("PrimaryCausticsProjector")).GetComponent <AQUAS_Caustics>();
                     }
                     if (Object.op_Inequality((Object)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("SecondaryCausticsProjector"), (Object)null))
                     {
                         this.secondaryCausticsProjector = (Projector)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("SecondaryCausticsProjector")).GetComponent <Projector>();
                         this.secondaryAquasCaustics     = (AQUAS_Caustics)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("SecondaryCausticsProjector")).GetComponent <AQUAS_Caustics>();
                     }
                     this.lastActivePlane = this.activePlane;
                 }
                 this.activePlane = index;
                 if (((Component)this).get_transform().get_position().y < this.gameObjects.waterPlanes[index].get_transform().get_position().y)
                 {
                     this.waterPlaneMaterial = ((Renderer)this.gameObjects.waterPlanes[index].GetComponent <Renderer>()).get_material();
                     this.activePlane        = index;
                     return(true);
                 }
             }
         }
     }
     else
     {
         for (int index = 0; index < waterPlanesCount; ++index)
         {
             double num1    = (double)Mathf.Abs((float)(((Component)this).get_transform().get_position().x - this.gameObjects.waterPlanes[index].get_transform().get_position().x));
             Bounds bounds1 = ((Renderer)this.gameObjects.waterPlanes[index].GetComponent <Renderer>()).get_bounds();
             // ISSUE: variable of the null type
             __Null x = ((Bounds) ref bounds1).get_extents().x;
             if (num1 < x)
             {
                 double num2    = (double)Mathf.Abs((float)(((Component)this).get_transform().get_position().z - this.gameObjects.waterPlanes[index].get_transform().get_position().z));
                 Bounds bounds2 = ((Renderer)this.gameObjects.waterPlanes[index].GetComponent <Renderer>()).get_bounds();
                 // ISSUE: variable of the null type
                 __Null z = ((Bounds) ref bounds2).get_extents().z;
                 if (num2 < z)
                 {
                     if (this.activePlane != this.lastActivePlane)
                     {
                         if (Object.op_Inequality((Object)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("PrimaryCausticsProjector"), (Object)null))
                         {
                             this.primaryCausticsProjector = (Projector)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("PrimaryCausticsProjector")).GetComponent <Projector>();
                             this.primaryAquasCaustics     = (AQUAS_Caustics)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("PrimaryCausticsProjector")).GetComponent <AQUAS_Caustics>();
                         }
                         if (Object.op_Inequality((Object)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("SecondaryCausticsProjector"), (Object)null))
                         {
                             this.secondaryCausticsProjector = (Projector)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("SecondaryCausticsProjector")).GetComponent <Projector>();
                             this.secondaryAquasCaustics     = (AQUAS_Caustics)((Component)this.gameObjects.waterPlanes[this.activePlane].get_transform().Find("SecondaryCausticsProjector")).GetComponent <AQUAS_Caustics>();
                         }
                         this.lastActivePlane = this.activePlane;
                     }
                     this.activePlane = index;
                     if (((Component)this).get_transform().get_position().y < this.gameObjects.waterPlanes[index].get_transform().get_position().y)
                     {
                         this.waterPlaneMaterial = ((Renderer)this.gameObjects.waterPlanes[0].GetComponent <Renderer>()).get_material();
                         this.activePlane        = index;
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }