Ejemplo n.º 1
0
 private void HandleAtPathNodeEvent(ZMWaypointMovementIntEventArgs args)
 {
     if (args.movement.CompareTag("MainCamera"))
     {
         Invoke(kSwitchFocusMethodName, 0.1f);
     }
 }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        // state sets
        if (_moveState == MoveState.MOVE && _waypointIndex < _waypointSize)
        {
            // set up the movement variables
            _distanceTraveled = 0.0f;

            if (_waypoints[_waypointIndex] != null)
            {
                _targetPosition   = _waypoints[_waypointIndex].position;
                _distanceToTarget = (_targetPosition - transform.position).magnitude;

                _moveState = MoveState.MOVING;
            }

            _waypointIndex += 1;
        }

        // state checks
        if (_moveState == MoveState.MOVING)
        {
            float   distanceRatio;
            Vector3 newPosition;

            _distanceTraveled += moveSpeed * Time.deltaTime;
            distanceRatio      = _distanceTraveled / _distanceToTarget;

            newPosition = Vector3.Lerp(transform.position, _targetPosition, distanceRatio);

            transform.position = newPosition;

            if ((_targetPosition - transform.position).sqrMagnitude < 4.0f * 4.0f)
            {
                _moveState         = MoveState.AT_TARGET;
                transform.position = _targetPosition;
            }
        }
        else if (_moveState == MoveState.AT_TARGET)
        {
            if (_waypointIndex < _waypointSize)
            {
                var args = new ZMWaypointMovementIntEventArgs(this, _waypointIndex);

                _moveState = MoveState.MOVE;

                Notifier.SendEventNotification(AtPathNodeEvent, args);
            }
            else if (_waypointIndex == _waypointSize)
            {
                var args = new ZMWaypointMovementEventArgs(this);

                _moveState      = MoveState.COMPLETED;
                _waypointIndex += 1;

                Notifier.SendEventNotification(AtPathEndEvent, args);
            }
        }
    }
Ejemplo n.º 3
0
 private void HandleAtPathNodeEvent(ZMWaypointMovementIntEventArgs args)
 {
     if (args.value - 1 == _playerInfo.ID)
     {
         StopPulsing();
         ScaleToTargetOverTime(Vector3.zero, shrinkRate);
         _scaleCoroutineCallback.OnFinished += OnFinishedShrink;
     }
 }