예제 #1
0
 public MatrixRotationInfo(MatrixMove matrixMove, RotationOffset rotationOffset, NetworkSide networkSide, RotationEvent rotationEvent)
 {
     MatrixMove     = matrixMove;
     RotationOffset = rotationOffset;
     NetworkSide    = networkSide;
     RotationEvent  = rotationEvent;
 }
    public override void UpdateEventHandler()
    {
        RotationEvent newEvent = new RotationEvent();

        newEvent.rotation = target.rotation;
        TimeController.instance.AddEvent(newEvent, this);
    }
예제 #3
0
        private async Task _loop()
        {
            while (_running)
            {
                try
                {
                    var result = await _mouseDevice.ReadAsync();

                    if (result.BytesRead >= 7)
                    {
                        if (result.Data[0] == (int)EventType.Translation)
                        {
                            CurrentTranslation = toVector3(result.Data) * TranslationScale;
                            TranslationEvent?.Invoke(this, CurrentTranslation);
                        }
                        else if (result.Data[0] == (int)EventType.Rotation)
                        {
                            CurrentRotation = toVector3(result.Data) * RotationScale;
                            RotationEvent?.Invoke(this, CurrentRotation);
                        }
                        else if (result.Data[0] == (int)EventType.Buttons)
                        {
                            CurrentButtons = ConvertByteArrayToBoolArray(result.Data.Skip(1).ToArray());
                            ButtonEvent?.Invoke(this, CurrentButtons);
                        }
                    }
                } catch (Exception ex) { }
            }
        }
예제 #4
0
    void Rotate(RotationEvent e)
    {
        Vector3 rotation = transform.eulerAngles;

        rotation.z = e.rotation; // Standart Left-/Right Arrows and A & D Keys

        transform.eulerAngles = rotation;
    }
예제 #5
0
        //=======================================================
        // Rotation Handlers
        //=======================================================
        public override void OnUpdateRotation(byte newFlags)
        {
            base.OnUpdateRotation(newFlags);
            Quaternion rotation = SegmentCustomRenderer.GetRotationQuaternion(newFlags);

            Forward = rotation * Vector3.forward;
            Left    = rotation * Vector3.left;
            Up      = rotation * Vector3.up;

            RotationEvent?.Invoke(this, rotation);
        }
예제 #6
0
    private void Update()
    {
        if (!IsApplying)
        {
            return;
        }
        if (target.transform.rotation != _rotationPrevious)
        {
            RotationEvent?.Invoke(target.transform.localEulerAngles);
            onRotation?.Invoke();
        }

        _rotationPrevious = target.transform.rotation;
    }
예제 #7
0
    void Update()
    {
        if (Input.anyKey)
        {
            Vector3 rotation = transform.eulerAngles;

            rotation.z += Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime; // Standart Left-/Right Arrows and A & D Keys

            transform.eulerAngles = rotation;

            RotationEvent e = new RotationEvent(rotation.z);

            e.FireEvent();
        }
    }
예제 #8
0
 /// <summary>
 /// Matrix rotation info where a rotation is performed from the matrixmove's initial facing to its current facing.
 /// </summary>
 /// <returns></returns>
 public static MatrixRotationInfo FromInitialRotation(MatrixMove matrixMove, NetworkSide side, RotationEvent rotationEvent)
 {
     return(new MatrixRotationInfo(matrixMove, matrixMove.FacingOffsetFromInitial, side, rotationEvent));
 }
    public override void ApplyEvent(TimeEvent timeEvent, bool reverse)
    {
        RotationEvent newEvent = (RotationEvent)timeEvent;

        target.rotation = newEvent.rotation;
    }
예제 #10
0
 // Start is called before the first frame update
 void Start()
 {
     RotationEvent.RegisterListener(Rotate);
 }
예제 #11
0
 /**
  * raises RotationEvent
  */
 private void OnRotationEvent(float e)
 {
     RotationEvent?.Invoke(this, e);
 }