Пример #1
0
        public override void InitializeModules()
        {
            if (_areModulesInitialized)
            {
                return;
            }

            _mainModule                   = new WaterMainModule(this, _size);
            _renderingModule              = new WaterRenderingModule(this, GetRenderingModuleParameters());
            _simulationModule             = new WaterSimulationModule(this, GetSimulationModuleParameters());
            _meshModule                   = new WaterMeshModule(this, subdivisionsCountPerUnit);
            _materialModule               = new WaterMaterialModule(this);
            _animationModule              = new WaterAnimationModule(this);
            _onCollisonRipplesModule      = new WaterCollisionRipplesModule(this, GetCollisionRipplesModuleParameters(), GetRipplesEffectsPoolsRoot());
            _constantRipplesModule        = new WaterConstantRipplesModule(this, GetConstantRipplesModuleParameters(), GetRipplesEffectsPoolsRoot());
            _scriptGeneratedRipplesModule = new WaterScriptGeneratedRipplesModule(this, GetScriptGeneratedRipplesModuleParameters(), GetRipplesEffectsPoolsRoot());
            _waterfallRipplesModule       = new WaterWaterfallRipplesModule(this);
            _attachedComponentsModule     = new WaterAttachedComponentsModule(this, buoyancyEffectorSurfaceLevel, buoyancyEffectorSurfaceLevelLocation, boxColliderTopEdgeLocation);

            _mainModule.Initialize();
            _simulationModule.Initialize();
            _meshModule.Initialize();
            _materialModule.Initialize();
            _renderingModule.Initialize();
            _attachedComponentsModule.Initialize();
            _constantRipplesModule.Initialze();
            _onCollisonRipplesModule.Initialize();
            _scriptGeneratedRipplesModule.Initialize();
            _waterfallRipplesModule.Initialize();
            _animationModule.Initialze();

            _areModulesInitialized = true;
        }
Пример #2
0
 internal void Initialize()
 {
     _mainModule               = _waterObject.MainModule;
     _meshModule               = _waterObject.MeshModule;
     _simulationModule         = _waterObject.SimulationModule;
     _attachedComponentsModule = _waterObject.AttachedComponentsModule;
 }
        internal void Initialze()
        {
            _mainModule       = _waterObject.MainModule;
            _meshModule       = _waterObject.MeshModule;
            _simulationModule = _waterObject.SimulationModule;

            _meshModule.OnRecomputeMesh += ResetCachedVariables;
            ResetCachedVariables();
        }
Пример #4
0
        internal void Initialize()
        {
            _mainModule = _waterObject.MainModule;
            _meshModule = _waterObject.MeshModule;

            ResetSimulation();
            _meshModule.OnRecomputeMesh     += ResetSimulation;
            _surfaceHeighestPointDeltaHeight = 0f;
        }
Пример #5
0
        private bool IsWaterObjectVisibleToCamera(WaterMainModule waterObject)
        {
            float waterHalfWidth = waterObject.Width * 0.5f;
            float waterXPos      = waterObject.Position.x;

            float cameraHalfWidth = (Screen.width / (float)Screen.height) * Camera.orthographicSize;
            float cameraXPos      = Camera.transform.position.x;

            return(Mathf.Abs(waterXPos - cameraXPos) < (waterHalfWidth + cameraHalfWidth));
        }
Пример #6
0
        internal void Initialze()
        {
            _mainModule       = _waterObject.MainModule;
            _meshModule       = _waterObject.MeshModule;
            _simulationModule = _waterObject.SimulationModule;

            _ripplesSourcesIndices = new List <int>();
            if (!_randomizeRipplesSourcePositions)
            {
                RecomputeIndices();
            }
        }
Пример #7
0
        internal Bounds GetWaterObjectsBoundsRelativeToSpecifiedWaterObject(WaterMainModule currentWaterObject)
        {
            Vector2 waterSize     = currentWaterObject.WaterSize;
            Vector2 halfWaterSize = waterSize * 0.5f;

            float leftMostWaterPos  = currentWaterObject.TransformWorldToLocal(_leftMostWaterSimulationModule.MainModule.Position).x;
            float rightMostWaterPos = leftMostWaterPos + waterSize.x * (_waterObjectCount - 1);

            Vector2 min = new Vector2(-halfWaterSize.x + leftMostWaterPos, -halfWaterSize.y);
            Vector2 max = new Vector2(halfWaterSize.x + rightMostWaterPos, _waterSurfaceHeighestPoint);

            _waterObjectsBounds.SetMinMax(min, max);
            return(_waterObjectsBounds);
        }
        internal void Initialize()
        {
            _mainModule = _waterObject.MainModule;

            _buoyancyEffector           = _mainModule.Transform.GetComponent <BuoyancyEffector2D>();
            _hasAnimatorAttached        = _mainModule.Transform.GetComponent <Animator>() != null;
            _edgeCollider               = _mainModule.Transform.GetComponent <EdgeCollider2D>();
            _boxCollider                = _mainModule.Transform.GetComponent <BoxCollider2D>();
            _boxCollider.isTrigger      = true;
            _boxCollider.usedByEffector = true; //used by the buoyancy effector

            _cachedWaterSize = _mainModule.WaterSize;
            ApplyChanges();
        }
Пример #9
0
        internal void Initialize()
        {
            _mainModule     = _waterObject.MainModule;
            _materialModule = _waterObject.MaterialModule;
            _meshMask       = _waterObject.RenderingModule.MeshMask;

            _hasAnimatorAttached = _mainModule.Transform.GetComponent <Animator>() != null;

            SetupBuoyancyEffector();
            SetupBoxCollider();
            SetupPolygonCollider();
            SetupEdgeCollider();

            _materialModule.OnSurfaceThicknessOrSubmergeLevelChanged += UpdateBoxColliderSizeAndOffset;
            _materialModule.OnSurfaceThicknessOrSubmergeLevelChanged += UpdateBuoyancySurfaceLevel;

            _cachedWaterSize     = _mainModule.WaterSize;
            _cachedWaterPosition = _mainModule.Position;
            _cachedWaterScale    = _mainModule.Scale;

            ApplyChanges();
        }
Пример #10
0
        public void InitializeModules()
        {
            if (_areModulesInitialized)
            {
                return;
            }

            _mainModule                   = new WaterMainModule(this, waterSize);
            _simulationModule             = new WaterSimulationModule(damping, stiffness, spread, firstCustomBoundary, secondCustomBoundary, useCustomBoundaries);
            _meshModule                   = new Mesh.WaterMeshModule(subdivisionsCountPerUnit);
            _materialModule               = new WaterMaterialModule();
            _renderingModule              = new WaterRenderingModule(GetRenderingModuleParameters(), RenderingCamerasRoot);
            _animationModule              = new WaterAnimationModule();
            _onCollisonRipplesModule      = new WaterCollisionRipplesModule(GetCollisionRipplesModuleParameters(), RipplesEffectsPoolsRoot);
            _constantRipplesModule        = new WaterConstantRipplesModule(GetConstantRipplesModuleParameters(), RipplesEffectsPoolsRoot);
            _scriptGeneratedRipplesModule = new WaterScriptGeneratedRipplesModule(GetScriptGeneratedRipplesModuleParameters(), RipplesEffectsPoolsRoot);
            _attachedComponentsModule     = new WaterAttachedComponentsModule(buoyancyEffectorSurfaceLevel);

            _simulationModule.SetDependencies(_mainModule, _meshModule);
            _meshModule.SetDependencies(_mainModule, _simulationModule);
            _materialModule.SetDependencies(_meshModule);
            _renderingModule.SetDependencies(_mainModule, _meshModule, _materialModule);
            _animationModule.SetDependencies(_mainModule, _meshModule, _simulationModule);
            _onCollisonRipplesModule.SetDependencies(_mainModule, _meshModule, _simulationModule);
            _constantRipplesModule.SetDependencies(_mainModule, _meshModule, _simulationModule);
            _scriptGeneratedRipplesModule.SetDependencies(_mainModule, _meshModule, _simulationModule);
            _attachedComponentsModule.SetDependencies(_mainModule);

            _mainModule.Initialize();
            _simulationModule.Initialize();
            _meshModule.Initialize();
            _materialModule.Initialize();
            _renderingModule.Initialize();
            _attachedComponentsModule.Initialize();
            _constantRipplesModule.Initialze();
            _animationModule.Initialze();

            _areModulesInitialized = true;
        }
 internal void Initialize()
 {
     _meshModule       = _waterObject.MeshModule;
     _mainModule       = _waterObject.MainModule;
     _simulationModule = _waterObject.SimulationModule;
 }
Пример #12
0
 internal void SetDependencies(WaterMainModule mainModule)
 {
     _mainModule = mainModule;
 }
Пример #13
0
 internal void SetDependencies(WaterMainModule mainModule, WaterMeshModule meshModule, WaterSimulationModule simulationModule)
 {
     _mainModule       = mainModule;
     _meshModule       = meshModule;
     _simulationModule = simulationModule;
 }
 internal void SetDependencies(WaterMainModule mainModule, WaterMeshModule meshModule, WaterMaterialModule materialModule)
 {
     _mainModule     = mainModule;
     _meshModule     = meshModule;
     _materialModule = materialModule;
 }
Пример #15
0
 public WaterRenderingVisibleArea(WaterMainModule transformManager)
 {
     _mainModule = transformManager;
 }
 internal WaterRenderingCameraFrustum(WaterMainModule mainModule)
 {
     _mainModule      = mainModule;
     _waterLocalSpace = new FrustumProperties();
     _worldSpace      = new FrustumProperties();
 }