示例#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;
    }
    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);
 }
 /**
  * raises RotationEvent
  */
 private void OnRotationEvent(float e)
 {
     RotationEvent?.Invoke(this, e);
 }