Example #1
0
        private void Update()
        {
            if (_time <= 0)
            {
                switch (Direction)
                {
                case WaveDirection.Left:
                    _water.Splash(_water.GetLeftPosition(), Force.GetValue());
                    break;

                case WaveDirection.Right:
                    _water.Splash(_water.GetRightPosition(), Force.GetValue());
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                _time = Period;
            }

            _time -= Time.deltaTime;
        }
Example #2
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            var sailingObject = other.gameObject.GetComponent <SailingObject>();

            if (sailingObject == null)
            {
                return;
            }

            var collisionObjectPos = other.transform.position;

            _water.Splash(collisionObjectPos.x, sailingObject.GetFallForce());

            var hitPos     = new Vector2(collisionObjectPos.x, _water.GetTopPosition());
            var waterDrops = Instantiate(WaterDrops);

            waterDrops.transform.position = hitPos;
            waterDrops.GetComponent <WaterDrops>().Initialize();

            sailingObject.SetFloatingForce(FloatingForce, FloatingPeriod);
            _sailingObjects.Add(sailingObject);
        }