예제 #1
0
        public void Next(MoveProps moveProps)
        {
            _enemyTracker.Next(moveProps);
            _attackController.NextStart(moveProps, _lastNavigationResult);


            if (_lastNavigationResult != null)
            {
                //Before we move
                if (_attackController.TryFireTorpedo(_lastNavigationResult, out var torpedoTarget1))
                {
                    Torpedo(torpedoTarget1.Value);
                }
            }

            var next = _navigator.Next(moveProps.MyPosition);

            if (next != null && moveProps.SilenceCooldown == 0)
            {
                Silence(next);

                //After silence
                if (_attackController.TryFireTorpedo(next, out var torpedoTarget2))
                {
                    Torpedo(torpedoTarget2.Value);
                }

                next = _navigator.Next(next.Position);
            }

            if (_attackController.TryTriggerMine(moveProps, next, out var position))
            {
                TriggerMine(position.Value);
            }

            if (next == null)
            {
                Surface();
            }
            else
            {
                Move(next.Direction, moveProps);
                if (_attackController.TryFireTorpedo(next, out var torpedoTarget))
                {
                    Torpedo(torpedoTarget.Value);
                }

                if (_attackController.TryDropMine(moveProps, next, out var dropMineDirection))
                {
                    DropMine(dropMineDirection);
                }
            }

            ExecuteActions();
            _lastNavigationResult = next;
            _attackController.NextEnd();
        }