Example #1
0
    protected override void LoseControl()
    {
        if (_timeToBoardUI != null)
        {
            DestroyImmediate(_timeToBoardUI.gameObject);
            _timeToBoardUI = null;
        }

        _controller.RemoveIcon("Submit Boarding Icon");
    }
Example #2
0
    protected override bool CheckForBoarding()
    {
        Vector3 heading = GetHeadingToTarget();

        if (_boardTime >= 0)
        {
            if (_timeToBoardUI == null)
            {
                _timeToBoardUI = UI.UIMain.AddTimeToBoard(_ship.transform);
            }

            _boardTime += GetProgressIncrement() * Time.deltaTime;
            _timeToBoardUI.progress = _boardTime / _requiredBoardTime;

            if (_target.velocity.magnitude <= 0.01f)
            {
                float distance = GetHeadingToTarget().magnitude;

                if (distance < 3)
                {
                    _ship.SetSailState(SailState.Half);
                }
                else if (distance < 1.5f)
                {
                    _ship.SetSailState(SailState.None);
                }
            }

            if (_boardTime >= _requiredBoardTime)
            {
                BoardingManager.BeginBoardingAction(_ship);
                _controller.ChangeToState <WaitState>();
                return(true);
            }
        }
        else
        {
            GiveUpChase();
        }

        return(false);
    }