/// <inheritdoc />
        public override void HandleComponentState(ComponentState state)
        {
            var newState = (TransformComponentState)state;

            if (LocalRotation != newState.Rotation)
            {
                SetRotation(newState.Rotation);
                OnRotate?.Invoke(newState.Rotation);
            }

            if (_position != newState.LocalPosition || GridID != newState.GridID)
            {
                var oldPos = LocalPosition;
                // TODO: this is horribly broken if the parent changes too, because the coordinates are all messed up.
                // Help.
                OnMove?.Invoke(this, new MoveEventArgs(oldPos, LocalCoordinatesFor(newState.LocalPosition, newState.GridID)));
                SetPosition(newState.LocalPosition);
                GridID = newState.GridID;
            }

            var newParentId = newState.ParentID;

            if (Parent?.Owner?.Uid != newParentId)
            {
                DetachParent();

                if (!newParentId.HasValue || !newParentId.Value.IsValid())
                {
                    return;
                }

                var newParent = Owner.EntityManager.GetEntity(newParentId.Value);
                AttachParent(newParent.GetComponent <ITransformComponent>());
            }
        }
    void Update()
    {
        Vector3 mp = Input.mousePosition;

        if (Input.GetMouseButtonDown(1))
        {
            mousePositionOnRotateStart = mp.x;
        }
        else if (Input.GetMouseButton(1))
        {
            if (mp.x < mousePositionOnRotateStart)
            {
                OnRotate?.Invoke(-1);
            }
            else if (mp.x > mousePositionOnRotateStart)
            {
                OnRotate?.Invoke(1);
            }
        }

        if (Input.mouseScrollDelta.y > 0 && !EventSystem.current.IsPointerOverGameObject())
        {
            OnZoom?.Invoke(-3f);
        }
        else if (Input.mouseScrollDelta.y < 0 && !EventSystem.current.IsPointerOverGameObject())
        {
            OnZoom?.Invoke(3f);
        }
    }
예제 #3
0
        public override void ApplyInput(Vector2 deltaPosition)
        {
            OnRotate?.Invoke(deltaPosition);

            if (deltaPosition != Vector2.zero)
            {
                OnChange?.Invoke();
            }
        }
예제 #4
0
    private void Start()
    {
#if UNITY_STANDALONE
        ReticlePointer.SetActive(false);
#endif
        Cursor.lockState = CursorLockMode.Locked;
        OnRotateAction   = Rotate;
        PickupBehaviour.OnPickUpAction     = UsePickup;
        PataoBehaviour.OnEnemyLockedAction = SetShootingState;
        PataoBehaviour.OnPunchAction       = RecievePunch;
    }
예제 #5
0
    internal void Rotate()
    {
        if (OnRotate == null)
        {
            return;
        }
        if (!AllowMovement)
        {
            return;
        }

        OnRotate.Invoke(_recentMoveDirection);
    }
예제 #6
0
    private void FireRotateEvent(float angle)
    {
        Vector2         midPoint      = gestureFinger1.position.GetMidPoint(gestureFinger2.position);
        GameObject      hitGameObject = GetHitGameObject(midPoint);
        RotateEventArgs args          = new RotateEventArgs(gestureFinger1, gestureFinger2, angle, hitGameObject);

        OnRotate?.Invoke(this, args);

        if (hitGameObject != null)
        {
            if (hitGameObject.TryGetComponent(out IRotatable rotate))
            {
                rotate.OnRotate(args);
            }
        }
    }
예제 #7
0
        private void UpdateMovementAxis()
        {
            OnRotate?.Invoke(new Vector3(
                                 Input.GetAxisRaw(xRotAxisName),
                                 Input.GetAxisRaw(yRotAxisName),
                                 Input.GetAxisRaw(zRotAxisName)
                                 ));


            OnMoveBackward?.Invoke(Input.GetAxis(backwardAxisName));


            OnMoveVertical?.Invoke(Input.GetAxis(verticalAxisName));


            OnMoveSideways?.Invoke(Input.GetAxis(sidewaysAxisName));
            OnMoveForward?.Invoke(Input.GetAxis(forwardAxisName));


            OnBoost?.Invoke(Input.GetAxis(boostAxisName));
        }
예제 #8
0
 protected void ActivateOnRotateEvent(T direction) => OnRotate?.Invoke(direction);
예제 #9
0
 protected void OnRotateEvent(float angle, Axis axis)
 {
     OnRotate?.Invoke(angle, axis);
 }
예제 #10
0
        IEnumerator<ITask> OnRotateHandler(OnRotate onRotate)
        {
            if (onRotate.DriveControl == _driveControl && _drivePort != null)
            {
                drive.RotateDegreesRequest request = new drive.RotateDegreesRequest();
                request.Degrees = onRotate.Angle;
                request.Power = (double)onRotate.Power * MOTOR_POWER_SCALE_FACTOR;

                yield return Arbiter.Choice(
                    _drivePort.RotateDegrees(request),
                    delegate(DefaultUpdateResponseType response) { },
                    delegate(Fault f)
                    {
                        LogError(f);
                    }
                );
            }
        }
예제 #11
0
 public void RotateWebViewer()
 {
     OnRotate?.Invoke();
 }