public virtual void Move(MoveEventArgs e) { if (e.distance == 0) { return; } lock (privateLock) { if (!this._movable) { return; } if ((DateTime.Now - lastMoveTime).TotalSeconds < 1 / _frameRate) { return; } MoveStart?.Invoke(this); XYPosition previousPosition = _position; _position = _position + new XYPosition(e.distance * Math.Cos(e.angle), e.distance * Math.Sin(e.angle)); Debug(this, "Move from " + previousPosition.ToString() + " angle : " + e.angle + " distance : " + e.distance + " aim : " + _position.ToString()); OnMove?.Invoke(this, e, previousPosition); Debug(this, "Move result poition : " + this._position.ToString()); MoveComplete?.Invoke(this); } }
private void SetVelocity(Vector2 velocity) { _rigidbody2D.velocity = velocity; if (!_isMoving && _rigidbody2D.velocity != Vector2.zero) { _isMoving = true; _onMoveStart.Invoke(); } else if (_isMoving && _rigidbody2D.velocity == Vector2.zero) { _isMoving = false; _onMoveEnd.Invoke(); } }
public void MoveToPosition(IntVector2 position) { Position = position; IsMoving = true; float motionSpeed; if (IsDiagonal(Position, position)) { motionSpeed = _unitSettings.MotionSpeed * 1.4f; } else { motionSpeed = _unitSettings.MotionSpeed; } _unit.transform.DOMove(new Vector3(position.x, 0, position.y), motionSpeed) .OnComplete(CompleteMoveHandler) .SetEase(Ease.Linear); MoveStart?.Invoke(); }
public void SetOnPosition(IntVector2 position) { _unit.transform.position = new Vector3(position.x, 0, position.y); Position = position; MoveStart?.Invoke(); }
public void MoveToPosition(IntVector2 position) { MoveStart?.Invoke(); MoveComplete?.Invoke(); }
/// <summary> /// マウスでウィンドウ移動開始のイベントを実行 /// </summary> private void DoMoveStart() { MoveStart?.Invoke(this, new StartWindowMoveMouseEventArgs()); }