コード例 #1
0
 public void LoadFrom(BinaryReader br)
 {
     MovementType = (eMovementType)br.ReadByte();
     Target       = new PointF
     {
         X = br.ReadSingle(),
         Y = br.ReadSingle()
     };
 }
コード例 #2
0
    /// <summary>
    /// _moveVector만큼 Rigidbody를 이동시킵니다( FixedUpdate 권장...).
    /// </summary>
    /// <param name="_moveType">이동 타입입니다.</param>
    /// <param name="_moveVector">방향 * 원하는 속도의 값입니다. 타입 VDP의 경우, 목적지 위치로 사용됩니다.</param>
    public void SetMovement(eMovementType _moveType, Vector2 _moveVector)
    {
        currentMovementType = _moveType;

        MovementInput movementInput = new MovementInput(_moveType, _moveVector);

        //if (haveParents) // 부모가 있다면
        //{
        //    _moveVector = parentsObject.myRigidbody.velocity + _moveVector; //무브 벡터에 벨로시티 더하기
        //}



        switch (_moveType)
        {
        case eMovementType.SetVelocity:
            if (myRigidbody.velocity != _moveVector)
            {
                myRigidbody.velocity = _moveVector;
            }
            break;

        case eMovementType.AddVelocity:
            myRigidbody.velocity += _moveVector;
            break;

        case eMovementType.SetVelocityDesiredPosition:

            myRigidbody.velocity = CalcDesiredVelocity(_moveVector);
            break;
            //case eMovementType.AddForce:

            //    myRigidbody.AddForce(_moveVector, ForceMode2D.Impulse);
            //    break;


            #region 사용하지 않음
            //case eMovementType.AddVelocity:

            //    myRigidbody.velocity += _moveVector;
            //    break;

            //case eMovementType.MovePosition:

            //    myRigidbody.MovePosition(_moveVector);
            //    break;
            #endregion
        default:
            break;
        }
        moveVector = _moveVector;
        //  UpdateParentsFollowMovement();
        CalcLastVelocity();
    }
コード例 #3
0
        private void OnMovementRequestHandler(int clientHash, PointF targetCell, eMovementType movementType)
        {
            var player = gameServer.Players.FirstOrDefault(x => x.ClientHash == clientHash);

            if (player == null)
            {
                return;
            }

            player.MovementType  = movementType;
            player.MovementSpeed = (player.MovementType == eMovementType.Running ? player.GetRunVelocity() : player.GetWalkVeloicty()) / 4f;
            player.Waypoints     = CalculateWaypoints(player, targetCell);

            Send(new MFLocatePlayers(gameServer.Players.Select(x => x.ToPlayerLocationDetails())));
        }
コード例 #4
0
        private void OnMovementRequestHandler(int clientHash, byte direction, eMovementType movementType)
        {
            var player = gameServer.Players.FirstOrDefault(x => x.ClientHash == clientHash);

            if (player == null)
            {
                return;
            }

            player.MovementDirection = direction;
            player.MovementType      = movementType;
            player.MovementDirection = direction;


            Send(new MFLocatePlayers(gameServer.Players.Select(x => x.ToPlayerLocationDetails())));
        }
コード例 #5
0
    public static GhostMovementPattern GetMovementPattern(this eMovementType movementType)
    {
        switch (movementType)
        {
        case eMovementType.Chase:
            return(new ChaseMovementPattern());

        case eMovementType.Evade:
            return(new EvadeMovementPattern());

        case eMovementType.Flank:
            return(new FlankMovementPattern());
        }

        return(new RandomMovementPattern());
    }
コード例 #6
0
    void Move(eMovementType _MovementType)
    {
        switch (_MovementType)
        {
        case eMovementType.Forward: MoveForward(); break;

        case eMovementType.Line: MoveLine(); break;

        case eMovementType.Circle: MoveCircle(); break;

        case eMovementType.Follow: MoveFollow(); break;

        case eMovementType.Patrol: MovePatrol(); break;

        default: break;
        }
    }
コード例 #7
0
ファイル: Game.cs プロジェクト: Indept-Studios/OpenDiablo2
        private void HandleMovement()
        {
            // todo; if clicked on hud, then we don't move. But when clicked on map and move cursor over hud, then it's fine
            if (gameHUD.IsMouseOver())
            {
                return;
            }

            var mx = mouseInfoProvider.MouseX - 400 - gameState.CameraOffset;
            var my = mouseInfoProvider.MouseY - 300;

            var tx = (mx / 60f + my / 40f) / 2f;
            var ty = (my / 40f - (mx / 60f)) / 2f;
            var cursorDirection = (int)Math.Round(Math.Atan2(ty, tx) * Rad2Deg);

            if (cursorDirection < 0)
            {
                cursorDirection += 360;
            }
            var actualDirection = (byte)(cursorDirection / 22);

            if (actualDirection >= 16)
            {
                actualDirection -= 16;
            }

            if (mouseInfoProvider.LeftMouseDown && (lastMovementType == eMovementType.Stopped || lastDirection != actualDirection))
            {
                lastDirection    = actualDirection;
                lastMovementType = gameHUD.IsRunningEnabled ? eMovementType.Running : eMovementType.Walking;
                sessionManager.MoveRequest(actualDirection, lastMovementType);
            }
            else if (!mouseInfoProvider.LeftMouseDown && lastMovementType != eMovementType.Stopped)
            {
                lastDirection    = actualDirection;
                lastMovementType = eMovementType.Stopped;
                sessionManager.MoveRequest(actualDirection, lastMovementType);
            }
        }
コード例 #8
0
 public MFMoveRequest(PointF targetCell, eMovementType movementType)
 {
     this.Target       = targetCell;
     this.MovementType = movementType;
 }
コード例 #9
0
 public void MoveRequest(PointF targetCell, eMovementType movementType)
 => Task.Run(() =>
 {
     Send(new MFMoveRequest(targetCell, movementType));
     ProcessMessageFrame <MFLocatePlayers>();
 });
コード例 #10
0
 public void MoveRequest(byte direction, eMovementType movementType)
 => Task.Run(() =>
 {
     Send(new MFMoveRequest(direction, movementType));
     ProcessMessageFrame <MFLocatePlayers>();
 });
コード例 #11
0
 public MovementInput(eMovementType _movementType, Vector2 _movementVector)
 {
     movementType   = _movementType;
     movementVector = _movementVector;
 }
コード例 #12
0
 public static void ChangeMovementType(eMovementType type)
 {
     GetLocomotionSettings().movementType = type;
 }