Exemple #1
0
        void Update()
        {
            if (!IsActive || _isBusy || _startTime > Time.time)
            {
                return;
            }

            _isBusy = true;

            var newPos = GetPositionInLookingDirection();

            if ((newPos - _lastMoveToLocation).magnitude > DistanceTrigger || _isJustEnabled)
            {
                _isJustEnabled = false;
                var maxDelta = CollisionDetector.GetMaxDelta(newPos - transform.position);
                if (maxDelta != Vector3.zero)
                {
                    newPos = transform.position + maxDelta;
                    iTween.MoveTo(gameObject,
                                  iTween.Hash("position", newPos, "time", 2.0f * maxDelta.magnitude, "easeType", iTween.EaseType.easeInOutSine,
                                              "islocal", false, "oncomplete", "MovingDone", "oncompletetarget", gameObject));
                    _lastMoveToLocation = newPos;
                }
            }
            else
            {
                _isBusy = false;
            }
        }
Exemple #2
0
        void Update()
        {
            //if (!IsActive || _isBusy || _startTime > Time.time)
            if (!IsActive || _startTime > Time.time)
            {
                return;
            }
            //_isBusy = true;

            var newPos = GetPostionInLookingDirection();

            if ((newPos - _lastMoveToLocation).magnitude > DistanceTrigger || _isJustEnabled)
            {
                _isJustEnabled = false;
                var maxDelta = CollisonDetector.GetMaxDelta(newPos - transform.position);
                if (maxDelta != Vector3.zero)
                {
                    //newPos = transform.position + maxDelta;
                    //iTween.MoveTo(gameObject,
                    //    iTween.Hash("position", newPos, "time", 2.0f * maxDelta.magnitude,
                    //        "easetype", iTween.EaseType.easeInOutSine, "islocal", false,
                    //        "oncomplete", "MovingDone", "oncompletetarget", gameObject));
                    //_lastMoveToLocation = newPos;
                    transform.position   += maxDelta;
                    _lastMoveToLocation   = transform.position;
                    transform.eulerAngles = new Vector3(transform.rotation.eulerAngles.x, Camera.main.transform.rotation.eulerAngles.y + 90, transform.rotation.eulerAngles.z);
                }
                else
                {
                    //_isBusy = false;
                }
            }
            else
            {
                //_isBusy = false;
            }
        }