예제 #1
0
 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);
     }
 }
예제 #2
0
 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();
     }
 }
예제 #3
0
        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();
        }
예제 #4
0
 public void SetOnPosition(IntVector2 position)
 {
     _unit.transform.position = new Vector3(position.x, 0, position.y);
     Position = position;
     MoveStart?.Invoke();
 }
예제 #5
0
 public void MoveToPosition(IntVector2 position)
 {
     MoveStart?.Invoke();
     MoveComplete?.Invoke();
 }
예제 #6
0
 /// <summary>
 /// マウスでウィンドウ移動開始のイベントを実行
 /// </summary>
 private void DoMoveStart()
 {
     MoveStart?.Invoke(this, new StartWindowMoveMouseEventArgs());
 }