Exemplo n.º 1
0
 private void UnitFixedUpdate(UnitFixedUpdateMessage msg)
 {
     if (_unitState == UnitState.Dashing)
     {
         if (_currentDashDistance < _dashDistance)
         {
             var position  = _rigidBody.position;
             var dashSpeed = _dashSpeed * Time.fixedDeltaTime;
             _currentDashDistance       += dashSpeed;
             position                   += Vector2.ClampMagnitude(_direction * dashSpeed, dashSpeed);
             _rigidBody.position         = position;
             _updatePositionMsg.Position = _rigidBody.position;
             _controller.gameObject.SendMessageTo(_updatePositionMsg, _controller.transform.parent.gameObject);
             if (_currentDashDistance >= _dashDistance)
             {
                 _controller.gameObject.SendMessageTo(DeactivateDashMessage.INSTANCE, _controller.transform.parent.gameObject);
             }
         }
         else
         {
             _controller.gameObject.SendMessageTo(DeactivateDashMessage.INSTANCE, _controller.transform.parent.gameObject);
         }
     }
     else
     {
         _controller.gameObject.SendMessageTo(DeactivateDashMessage.INSTANCE, _controller.transform.parent.gameObject);
     }
 }
Exemplo n.º 2
0
 private void UnitFixedUpdate(UnitFixedUpdateMessage msg)
 {
     if (_direction != Vector2.zero && _unitState == UnitState.Active)
     {
         var position  = _rigidBody.position;
         var moveSpeed = _moveSpeed * Time.fixedDeltaTime;
         position += Vector2.ClampMagnitude(_direction * moveSpeed, moveSpeed);
         //_rigidBody.position = position;
         _rigidBody.MovePosition(position);
         _updatePositionMsg.Position = _rigidBody.position;
         _controller.gameObject.SendMessageTo(_updatePositionMsg, _controller.transform.parent.gameObject);
     }
 }