internal void Reset(WorldFile worldFile)
 {
     Position  = worldFile.KarelStartPosition;
     Direction = worldFile.KarelStartDirection;
     PositionChanged.Invoke(this);
     DirectionChanged.Invoke(this);
 }
Ejemplo n.º 2
0
    private void Update()
    {
        if (Input.touchCount == 0)
        {
            DirectionChanged?.Invoke(Vector2Int.up);
            return;
        }

        Touch directionTouch = Input.touches[0];

        if (directionTouch.phase == TouchPhase.Began)
        {
            TouchData touchData = new TouchData(directionTouch.position, Time.time);
            _directionTouch = touchData;
            if (IsDoubleClicked(directionTouch))
            {
                DoubleClicked?.Invoke();
            }
        }
        else if (directionTouch.phase == TouchPhase.Stationary && Time.time - _directionTouch.Time > 0.1f)
        {
            int direction = (int)Mathf.Sign(_directionTouch.Position.x - Camera.main.pixelWidth / 2);
            DirectionChanged?.Invoke(Vector2Int.left * direction);
        }

        if (Input.touchCount > 1)
        {
            Touch lastTouch = Input.touches[Input.touchCount - 1];
            if (IsDoubleClicked(lastTouch))
            {
                DoubleClicked?.Invoke();
            }
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Callback on internal implementation state changed to synchronize the cached state of this wrapper.
        /// </summary>
        /// <param name="negotiatedDirection">Current negotiated direction of the transceiver</param>
        /// <param name="desiredDirection">Current desired direction of the transceiver</param>
        internal void OnStateUpdated(Direction?negotiatedDirection, Direction desiredDirection)
        {
            _desiredDirection = desiredDirection;

            if (negotiatedDirection == NegotiatedDirection)
            {
                return;
            }

            bool hadSendBefore = HasSend(NegotiatedDirection);
            bool hasSendNow    = HasSend(negotiatedDirection);
            bool hadRecvBefore = HasRecv(NegotiatedDirection);
            bool hasRecvNow    = HasRecv(negotiatedDirection);

            NegotiatedDirection = negotiatedDirection;

            if (hadSendBefore != hasSendNow)
            {
                _localTrack?.OnMute(!hasSendNow);
            }
            if (hadRecvBefore != hasRecvNow)
            {
                _remoteTrack?.OnMute(!hasRecvNow);
            }

            DirectionChanged?.Invoke(this);
        }
Ejemplo n.º 4
0
 public void OnStartMoving()
 {
     movingDirection = GetDirectionToRequestedFloor(currRequest.FloorNum);
     DirectionChanged.Invoke(movingDirection);
     nextFloorNum = movingDirection == ElevatorDirection.up ? currFloorNum + 1 : currFloorNum - 1;
     nextFloorNum = Mathf.Clamp(nextFloorNum, 1, Floors.Count);
 }
    public async Task TurnLeft()
    {
        await _program.AwaitNextStep();

        Direction = Direction.RotateCounterClockwise();
        DirectionChanged?.Invoke(this);
    }
Ejemplo n.º 6
0
        public static void OnDirectionChanged()
        {
#if DEBUG
            Debug.Log($"[RCSBA EVENT]: Direction changed to {RCSBuildAid.Direction}");
#endif
            DirectionChanged?.Invoke(RCSBuildAid.Direction);
        }
Ejemplo n.º 7
0
 private void controllerPictureBox_MouseMove(object sender, MouseEventArgs e)
 {
     if (changing)
     {
         angle = (float)Atan2(e.Y - Width / 2, e.X - Height / 2);
         g.Clear(Color.Transparent);
         Draw();
         DirectionChanged?.Invoke(angle);
     }
 }
Ejemplo n.º 8
0
        protected override Task OnParametersSetAsync()
        {
            if (IsRemovable &&
                Direction != SortDirection.Ascending &&
                Direction != SortDirection.Descending)
            {
                Direction = SortDirection.Ascending;

                return(DirectionChanged.InvokeAsync(Direction));
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 9
0
        protected override void OnUpdate()
        {
            base.OnUpdate();


            if (!UIUtil.IsMouseOverUI() && DirectionRule.Execute())
            {
                DirectionChanged?.Invoke(this);
            }

            if (!UIUtil.IsMouseOverUI() && SpinRule.Execute())
            {
            }
        }
Ejemplo n.º 10
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         tapPosition = Input.mousePosition;
     }
     if (Input.GetMouseButton(0))
     {
         DirectionChanged?.Invoke(Input.mousePosition - tapPosition);
     }
     if (Input.GetMouseButtonUp(0))
     {
         PointerUp?.Invoke();
     }
 }
Ejemplo n.º 11
0
        public async Task SetNewSortAsync(string sortId, MatSortDirection direction)
        {
            SortId    = sortId;
            Direction = direction;
            await SortIdChanged.InvokeAsync(sortId);

            await DirectionChanged.InvokeAsync(direction);

            await SortChanged.InvokeAsync(new MatSortChangedEvent()
            {
                SortId    = sortId,
                Direction = direction
            });

            this.StateHasChanged();
        }
Ejemplo n.º 12
0
        protected override Task OnToggle()
        {
            if (IsStatic)
            {
                return(Task.CompletedTask);
            }

            Direction = Direction switch
            {
                SortDirection.Ascending => SortDirection.Descending,
                SortDirection.Descending => IsRemovable ? SortDirection.Ascending : SortDirection.None,
                _ => SortDirection.Ascending
            };

            return(DirectionChanged.InvokeAsync(Direction));
        }
Ejemplo n.º 13
0
    /// <summary>
    /// Kääntyy.
    /// </summary>
    /// <param name="direction">Suunta</param>
    public void Turn(Direction direction)
    {
        if (direction == FacingDirection || (direction != Direction.Left && direction != Direction.Right))
        {
            return;
        }

        TextureWrapSize = new Vector(-TextureWrapSize.X, TextureWrapSize.Y);

        if (Weapon != null)
        {
            Weapon.TextureWrapSize = new Vector(1, direction.GetVector().X);
            Weapon.Angle           = Angle.Supplement(Weapon.Angle);
        }

        _facingDirection = direction;

        DirectionChanged?.Invoke(direction);
    }
Ejemplo n.º 14
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            DirectionChanged?.Invoke(Vector2Int.right);
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            DirectionChanged?.Invoke(Vector2Int.left);
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow))
        {
            DirectionChanged?.Invoke(Vector2Int.up);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            DoubleClicked?.Invoke();
        }
    }
Ejemplo n.º 15
0
    /// <summary>
    /// Kääntyy.
    /// </summary>
    /// <param name="direction">Suunta</param>
    public void Turn(Direction direction)
    {
        if (direction == FacingDirection || (direction != Direction.Left && direction != Direction.Right))
        {
            return;
        }

        walkSteps       = 0;
        TextureWrapSize = new Vector(-TextureWrapSize.X, TextureWrapSize.Y);

        if (Weapon != null)
        {
            Weapon.X *= -1;
            Weapon.TextureWrapSize = new Vector(1, -Weapon.TextureWrapSize.Y);
            Weapon.Angle           = Angle.Supplement(Weapon.Angle);
        }

        _curDirection = direction;

        DirectionChanged?.Invoke(direction);
    }
Ejemplo n.º 16
0
 protected virtual void OnDirectionChanged(string dir)
 {
     DirectionEvent de = new DirectionEvent();
     de.Direction = dir;
     DirectionChanged?.Invoke(this, de);
 }
Ejemplo n.º 17
0
        protected virtual void OnDirectionChanged(Direction dir)
        {
            DirectionEventArgs de = new DirectionEventArgs(dir);

            DirectionChanged?.Invoke(this, de);
        }
Ejemplo n.º 18
0
 private void OnDirectionChanged(Direction direction)
 {
     CurDirection = direction;
     DirectionChanged?.Invoke(direction);
     InnerOnDirectionChanged(direction);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Occurs when direction changed
 /// </summary>
 /// <param name="direction"></param>
 protected virtual void OnDirectionChanged(Direction direction)
 {
     DirectionChanged?.Invoke(this, direction);
     OnLookChanged(new EventArgs());
 }
Ejemplo n.º 20
0
 protected virtual void OnDirectionChanged()
 {
     DirectionChanged?.Invoke();
 }