Exemple #1
0
        public TurnDirection TurnTowards(YawHexFacing targetYaw, PitchHexFacing targetPitch = 0,
                                         AccelerationDirection accelerationDirection        = AccelerationDirection.Accelerate,
                                         int maxVelocityChangeCharacterWantsToMake          = 0)
        {
            TurnDirection combineDirection     = new TurnDirection(0, 0);
            TurnDirection yawDirectionToTurn   = new TurnDirection(0, 0);
            TurnDirection pitchDirectionToTurn = new TurnDirection(0, 0);

            if (targetYaw != 0)

            {
                int completeYaw = YawHexFacing.NorthEast - YawHexFacing.North + 1;
                int yawDelta    = yawDelta = Math.Abs(Facing.Yaw - targetYaw);
                int YawDeltaTurningOppositeDirection = 0;
                if (yawDelta > completeYaw / 2)
                {
                    YawDeltaTurningOppositeDirection = Math.Abs((int)targetYaw - yawDelta);
                }
                if (YawDeltaTurningOppositeDirection == 0)
                {
                    if (Facing.Yaw > targetYaw)
                    {
                        yawDirectionToTurn = TurnDirection.Left;
                    }
                    else
                    {
                        yawDirectionToTurn = TurnDirection.Right;
                    }
                }
                else
                {
                    if (Facing.Yaw > targetYaw)
                    {
                        yawDirectionToTurn = TurnDirection.Right;
                    }
                    else
                    {
                        yawDirectionToTurn = TurnDirection.Left;
                    }
                    ;
                }
            }


            if (targetPitch != 0)
            {
                int completePitch = PitchHexFacing.DiagonalDown - PitchHexFacing.Level + 1;
                int pitchDelta    = Math.Abs(Facing.Pitch - targetPitch);
                int PitchDeltaTurningOppositeDirection = 0;
                if (pitchDelta > completePitch / 2)
                {
                    PitchDeltaTurningOppositeDirection = Math.Abs((int)targetPitch - pitchDelta);
                }
                ;
                if (PitchDeltaTurningOppositeDirection == 0)
                {
                    if (Facing.Pitch > targetPitch)
                    {
                        pitchDirectionToTurn = TurnDirection.Down;
                    }
                    else
                    {
                        pitchDirectionToTurn = TurnDirection.Up;
                    }
                }
                else
                {
                    if (Facing.Pitch > targetPitch)
                    {
                        pitchDirectionToTurn = TurnDirection.Up;
                    }
                    else
                    {
                        pitchDirectionToTurn = TurnDirection.Down;
                    }
                    ;
                }
            }

            combineDirection = yawDirectionToTurn + pitchDirectionToTurn;
            TurnDirection originaTurnDirection = new TurnDirection(0, 0) + combineDirection;


            TurnsMade = 0;
            while (true)
            {
                if (CanTurn == false)
                {
                    MoveCharacter(TurnMode, accelerationDirection);
                }

                Turn(combineDirection);
                TurnsMade++;
                if (Facing.Yaw == targetYaw)
                {
                    combineDirection = combineDirection - yawDirectionToTurn;
                    if (Facing.Pitch == targetPitch || targetPitch == 0)
                    {
                        break;
                    }
                }
                if (Facing.Pitch == targetPitch)
                {
                    combineDirection = combineDirection - pitchDirectionToTurn;
                    if (Facing.Yaw == targetYaw || targetYaw == 0)
                    {
                        break;
                    }
                }
            }
            return(originaTurnDirection);
        }
 public void MoveGameObject(HeroSystemCharacter character, int velocity, YawHexFacing yaw, PitchHexFacing pitch)
 {
 }
Exemple #3
0
 public TurnDirection TurnTowards(YawHexFacing targetYaw, PitchHexFacing targetPitch = 0)
 {
     return(ActiveMovement.TurnTowards(targetYaw, targetPitch));
 }