Exemplo n.º 1
0
    private bool _startMove(Vector3 targetPoint, float speed, float acceleratorTime, bool pauseByCorner, bool changeDir)
    {
        //Debug.LogFormat("_startMove from {0} to {1}, dir {2}", this.GetPositon(), targetPoint, (targetPoint - this.GetPositon()).normalized);

        this._acceleratorTime = acceleratorTime;
        this._pauseByCorner   = pauseByCorner;

        this._targetPoint = targetPoint;
        _velocity         = _targetPoint - this.TF.position;
        Vector3 tempDistance = _velocity;

        tempDistance.y = 0;
        _distance      = tempDistance.magnitude; //注意这边要用平面距离

        if (_distance.IsZero())
        {
            //说明寻路失败.
            _distance = 0f;
            return(false);
        }


        if (!_ispathing)
        {
            _ispathing = true;
        }


        _distanceScalc = _velocity.magnitude / _distance;
        _velocity.Normalize();

        if (changeDir)
        {
            SetDirection(_targetPoint - this.GetPositon(), false);
        }

        _moveStartPoint = this.TF.position;

        this._moveStartTime    = Time.time;
        this._moveTimeElapased = 0f;

        this._remainingDistance = _distance;
        this._currentMoveSpeed  = speed;

        if (acceleratorTime != 0f && _moveStatus != ActorMoveStatus.ePathing)
        {
            this._acceleratorEndTime = Time.time + acceleratorTime;
            this._acceleration       = SPEED / acceleratorTime;
        }
        else
        {
            this._acceleratorEndTime = 0f;
            this._acceleration       = 0f;
        }

        _moveStatus = ActorMoveStatus.ePathing;

        return(true);
    }
Exemplo n.º 2
0
 public virtual void StopMove(bool localStop = true)
 {
     _distance   = 0;
     _ispathing  = false;
     _moveStatus = ActorMoveStatus.eStop;
 }