float vehiclerotation(VehicleDirection12 dir)
 {
     switch (dir)
     {
         case VehicleDirection12.VerticalUp:
             return 0;
         case VehicleDirection12.DownRightRight:
         case VehicleDirection12.UpLeftUp:
             return 45;
         case VehicleDirection12.HorizontalRight:
             return 90;
         case VehicleDirection12.UpRightRight:
         case VehicleDirection12.DownLeftDown:
             return 90 + 45;
         case VehicleDirection12.VerticalDown:
             return 180;
         case VehicleDirection12.UpLeftLeft:
         case VehicleDirection12.DownRightDown:
             return 180 + 45;
         case VehicleDirection12.HorizontalLeft:
             return 180 + 90;
         case VehicleDirection12.UpRightUp:
         case VehicleDirection12.DownLeftLeft:
             return 180 + 90 + 45;
         default:
             return 0;
     }
 }
Beispiel #2
0
 public void Draw(Vector3 position, VehicleDirection12 dir, VehicleDirection12 lastdir, double progress)
 {
     if (minecarttexture == -1)
     {
         minecarttexture = d_The3d.LoadTexture(new System.Drawing.Bitmap(new System.IO.MemoryStream(MyStream.ReadAllBytes(d_GetFile.GetFile("minecart.png")))));
     }
     GL.PushMatrix();
     GL.Translate(position + new Vector3(0, -0.7f, 0));
     double currot = vehiclerotation(dir);
     double lastrot = vehiclerotation(lastdir);
     //double rot = lastrot + (currot - lastrot) * progress;
     double rot = AngleInterpolation.InterpolateAngle360(lastrot, currot, progress);
     GL.Rotate(-rot - 90, 0, 1, 0);
     var c = new CharacterRendererMonsterCode();
     var cc = c.CuboidNet(8, 8, 8, 0, 0);
     CharacterRendererMonsterCode.CuboidNetNormalize(cc, 32, 16);
     c.DrawCuboid(new Vector3(-0.5f, -0.3f, -0.5f), new Vector3(1, 1, 1), minecarttexture, cc);
     GL.PopMatrix();
 }
 public void Draw(Game game, float positionX, float positionY, float positionZ, VehicleDirection12 dir, VehicleDirection12 lastdir, float progress)
 {
     float one = 1;
     if (minecarttexture == -1)
     {
         minecarttexture = game.GetTexture("minecart.png");
     }
     game.GLPushMatrix();
     float pX = positionX;
     float pY = positionY;
     float pZ = positionZ;
     pY += -(one * 7 / 10);
     game.GLTranslate(pX, pY, pZ);
     float currot = vehiclerotation(dir);
     float lastrot = vehiclerotation(lastdir);
     //double rot = lastrot + (currot - lastrot) * progress;
     float rot = AngleInterpolation.InterpolateAngle360(game.platform, lastrot, currot, progress);
     game.GLRotate(-rot - 90, 0, 1, 0);
     RectangleFloat[] cc = CuboidRenderer.CuboidNet(8, 8, 8, 0, 0);
     CuboidRenderer.CuboidNetNormalize(cc, 32, 16);
     game.platform.BindTexture2d(minecarttexture);
     CuboidRenderer.DrawCuboid(game, -(one * 5 / 10), -(one * 3 / 10), -(one * 5 / 10), 1, 1, 1, cc, 1);
     game.GLPopMatrix();
 }
Beispiel #4
0
        public static VehicleDirection12Flags ToVehicleDirection12Flags(VehicleDirection12 direction)
        {
            switch (direction)
            {
                case VehicleDirection12.HorizontalLeft:
                    return VehicleDirection12Flags.HorizontalLeft;
                case VehicleDirection12.HorizontalRight:
                    return VehicleDirection12Flags.HorizontalRight;
                case VehicleDirection12.VerticalUp:
                    return VehicleDirection12Flags.VerticalUp;
                case VehicleDirection12.VerticalDown:
                    return VehicleDirection12Flags.VerticalDown;

                case VehicleDirection12.UpLeftUp:
                    return VehicleDirection12Flags.UpLeftUp;
                case VehicleDirection12.UpLeftLeft:
                    return VehicleDirection12Flags.UpLeftLeft;
                case VehicleDirection12.UpRightUp:
                    return VehicleDirection12Flags.UpRightUp;
                case VehicleDirection12.UpRightRight:
                    return VehicleDirection12Flags.UpRightRight;

                case VehicleDirection12.DownLeftDown:
                    return VehicleDirection12Flags.DownLeftDown;
                case VehicleDirection12.DownLeftLeft:
                    return VehicleDirection12Flags.DownLeftLeft;
                case VehicleDirection12.DownRightDown:
                    return VehicleDirection12Flags.DownRightDown;
                case VehicleDirection12.DownRightRight:
                    return VehicleDirection12Flags.DownRightRight;
                default:
                    throw new ArgumentOutOfRangeException("direction");
            }
        }
Beispiel #5
0
        public static RailDirection ToRailDirection(VehicleDirection12 direction)
        {
            switch (direction)
            {
                case VehicleDirection12.HorizontalLeft:
                    return RailDirection.Horizontal;
                case VehicleDirection12.HorizontalRight:
                    return RailDirection.Horizontal;
                case VehicleDirection12.VerticalUp:
                    return RailDirection.Vertical;
                case VehicleDirection12.VerticalDown:
                    return RailDirection.Vertical;

                case VehicleDirection12.UpLeftUp:
                    return RailDirection.UpLeft;
                case VehicleDirection12.UpLeftLeft:
                    return RailDirection.UpLeft;
                case VehicleDirection12.UpRightUp:
                    return RailDirection.UpRight;
                case VehicleDirection12.UpRightRight:
                    return RailDirection.UpRight;

                case VehicleDirection12.DownLeftDown:
                    return RailDirection.DownLeft;
                case VehicleDirection12.DownLeftLeft:
                    return RailDirection.DownLeft;
                case VehicleDirection12.DownRightDown:
                    return RailDirection.DownRight;
                case VehicleDirection12.DownRightRight:
                    return RailDirection.DownRight;
                default:
                    throw new ArgumentOutOfRangeException("direction");
            }
        }
Beispiel #6
0
        public static TileEnterDirection StartEnter(VehicleDirection12 direction)
        {
            switch (direction)
            {
                case VehicleDirection12.HorizontalLeft:
                    return TileEnterDirection.Right;
                case VehicleDirection12.HorizontalRight:
                    return TileEnterDirection.Left;
                case VehicleDirection12.VerticalUp:
                    return TileEnterDirection.Down;
                case VehicleDirection12.VerticalDown:
                    return TileEnterDirection.Up;

                case VehicleDirection12.DownLeftDown:
                    return TileEnterDirection.Left;
                case VehicleDirection12.DownLeftLeft:
                    return TileEnterDirection.Down;
                case VehicleDirection12.DownRightDown:
                    return TileEnterDirection.Right;
                case VehicleDirection12.DownRightRight:
                    return TileEnterDirection.Down;

                case VehicleDirection12.UpLeftLeft:
                    return TileEnterDirection.Up;
                case VehicleDirection12.UpLeftUp:
                    return TileEnterDirection.Left;
                case VehicleDirection12.UpRightRight:
                    return TileEnterDirection.Up;
                case VehicleDirection12.UpRightUp:
                    return TileEnterDirection.Right;

                default:
                    throw new Exception();
            }
        }
Beispiel #7
0
        /// <summary>
        /// VehicleDirection12.UpRightRight -> returns Direction4.Right
        /// </summary>
        /// <param name="direction"></param>
        /// <returns></returns>
        public static TileExitDirection ResultExit(VehicleDirection12 direction)
        {
            switch (direction)
            {
                case VehicleDirection12.HorizontalLeft:
                    return TileExitDirection.Left;
                case VehicleDirection12.HorizontalRight:
                    return TileExitDirection.Right;
                case VehicleDirection12.VerticalUp:
                    return TileExitDirection.Up;
                case VehicleDirection12.VerticalDown:
                    return TileExitDirection.Down;

                case VehicleDirection12.UpLeftUp:
                    return TileExitDirection.Up;
                case VehicleDirection12.UpLeftLeft:
                    return TileExitDirection.Left;
                case VehicleDirection12.UpRightUp:
                    return TileExitDirection.Up;
                case VehicleDirection12.UpRightRight:
                    return TileExitDirection.Right;

                case VehicleDirection12.DownLeftDown:
                    return TileExitDirection.Down;
                case VehicleDirection12.DownLeftLeft:
                    return TileExitDirection.Left;
                case VehicleDirection12.DownRightDown:
                    return TileExitDirection.Down;
                case VehicleDirection12.DownRightRight:
                    return TileExitDirection.Right;
                default:
                    throw new ArgumentOutOfRangeException("direction");
            }
        }
Beispiel #8
0
    public static int ToVehicleDirection12Flags(VehicleDirection12 direction)
    {
        switch (direction)
        {
            case VehicleDirection12.HorizontalLeft:
                return VehicleDirection12Flags.HorizontalLeft;
            case VehicleDirection12.HorizontalRight:
                return VehicleDirection12Flags.HorizontalRight;
            case VehicleDirection12.VerticalUp:
                return VehicleDirection12Flags.VerticalUp;
            case VehicleDirection12.VerticalDown:
                return VehicleDirection12Flags.VerticalDown;

            case VehicleDirection12.UpLeftUp:
                return VehicleDirection12Flags.UpLeftUp;
            case VehicleDirection12.UpLeftLeft:
                return VehicleDirection12Flags.UpLeftLeft;
            case VehicleDirection12.UpRightUp:
                return VehicleDirection12Flags.UpRightUp;
            case VehicleDirection12.UpRightRight:
                return VehicleDirection12Flags.UpRightRight;

            case VehicleDirection12.DownLeftDown:
                return VehicleDirection12Flags.DownLeftDown;
            case VehicleDirection12.DownLeftLeft:
                return VehicleDirection12Flags.DownLeftLeft;
            case VehicleDirection12.DownRightDown:
                return VehicleDirection12Flags.DownRightDown;
            case VehicleDirection12.DownRightRight:
                return VehicleDirection12Flags.DownRightRight;
            default:
                return 0;
        }
    }
Beispiel #9
0
        void RailOnNewFrame(float dt)
        {
            LocalPlayerAnimationHint.InVehicle = railriding;
            LocalPlayerAnimationHint.DrawFix = railriding ? new Vector3(0, -0.7f, 0) : new Vector3();

            bool turnright = keyboardstate[GetKey(OpenTK.Input.Key.D)];
            bool turnleft = keyboardstate[GetKey(OpenTK.Input.Key.A)];
            RailSound();
            if (railriding)
            {
                ENABLE_FREEMOVE = true;
                ENABLE_MOVE = false;
                LocalPlayerPosition = CurrentRailPos();
                currentrailblockprogress += currentvehiclespeed * (float)dt;
                if (currentrailblockprogress >= 1)
                {
                    lastdirection = currentdirection;
                    currentrailblockprogress = 0;
                    var newenter = new TileEnterData();
                    newenter.BlockPosition = NextTile(currentdirection, currentrailblock);
                    //slope
                    if (GetUpDownMove(currentrailblock,
                        DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection))) == UpDown.Up)
                    {
                        newenter.BlockPosition.Z++;
                    }
                    if (GetUpDownMove(newenter.BlockPosition + new Vector3(0, 0, -1),
                        DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection))) == UpDown.Down)
                    {
                        newenter.BlockPosition.Z--;
                    }

                    newenter.EnterDirection = DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection));
                    var newdir = BestNewDirection(PossibleRails(newenter), turnleft, turnright);
                    if (newdir == null)
                    {
                        //end of rail
                        currentdirection = DirectionUtils.Reverse(currentdirection);
                    }
                    else
                    {
                        currentdirection = newdir.Value;
                        currentrailblock = newenter.BlockPosition;
                    }
                }
            }
            if (keyboardstate[GetKey(OpenTK.Input.Key.W)] && GuiTyping != TypingState.Typing)
            {
                currentvehiclespeed += 1f * (float)dt;
            }
            if (keyboardstate[GetKey(OpenTK.Input.Key.S)] && GuiTyping != TypingState.Typing)
            {
                currentvehiclespeed -= 5f * (float)dt;
            }
            if (currentvehiclespeed < 0)
            {
                currentvehiclespeed = 0;
            }
            //todo fix
            //if (viewport.keypressed != null && viewport.keypressed.Key == OpenTK.Input.Key.Q)
            if (!wasqpressed && keyboardstate[GetKey(OpenTK.Input.Key.Q)] && GuiTyping != TypingState.Typing)
            {
                Reverse();
            }

            if (!wasepressed && keyboardstate[GetKey(OpenTK.Input.Key.E)] && !railriding && !ENABLE_FREEMOVE && GuiTyping != TypingState.Typing)
            {
                currentrailblock = new Vector3((int)LocalPlayerPosition.X,
                    (int)LocalPlayerPosition.Z, (int)LocalPlayerPosition.Y - 1);
                if (!MapUtil.IsValidPos(d_Map, (int)currentrailblock.X, (int)currentrailblock.Y, (int)currentrailblock.Z))
                {
                    ExitVehicle();
                }
                else
                {
                    var railunderplayer = d_Data.Rail[d_Map.GetBlock((int)currentrailblock.X, (int)currentrailblock.Y, (int)currentrailblock.Z)];
                    railriding = true;
                    CharacterHeight = minecartheight;
                    currentvehiclespeed = 0;
                    if ((railunderplayer & RailDirectionFlags.Horizontal) != 0)
                    {
                        currentdirection = VehicleDirection12.HorizontalRight;
                    }
                    else if ((railunderplayer & RailDirectionFlags.Vertical) != 0)
                    {
                        currentdirection = VehicleDirection12.VerticalUp;
                    }
                    else if ((railunderplayer & RailDirectionFlags.UpLeft) != 0)
                    {
                        currentdirection = VehicleDirection12.UpLeftUp;
                    }
                    else if ((railunderplayer & RailDirectionFlags.UpRight) != 0)
                    {
                        currentdirection = VehicleDirection12.UpRightUp;
                    }
                    else if ((railunderplayer & RailDirectionFlags.DownLeft) != 0)
                    {
                        currentdirection = VehicleDirection12.DownLeftLeft;
                    }
                    else if ((railunderplayer & RailDirectionFlags.DownRight) != 0)
                    {
                        currentdirection = VehicleDirection12.DownRightRight;
                    }
                    else
                    {
                        ExitVehicle();
                    }
                    lastdirection = currentdirection;
                }
            }
            else if (!wasepressed && keyboardstate[GetKey(OpenTK.Input.Key.E)] && railriding && GuiTyping != TypingState.Typing)
            {
                ExitVehicle();
                LocalPlayerPosition += new Vector3(0, 0.7f, 0);
            }
            wasqpressed = keyboardstate[GetKey(OpenTK.Input.Key.Q)] && GuiTyping != TypingState.Typing;
            wasepressed = keyboardstate[GetKey(OpenTK.Input.Key.E)] && GuiTyping != TypingState.Typing;
        }
Beispiel #10
0
 public static Vector3IntRef NextTile(VehicleDirection12 direction, int currentTileX, int currentTileY, int currentTileZ)
 {
     return NextTile_(DirectionUtils.ResultExit(direction), currentTileX, currentTileY, currentTileZ);
 }
Beispiel #11
0
    /// <summary>
    /// VehicleDirection12.UpRightRight -> returns Direction4.Right
    /// </summary>
    /// <param name="direction"></param>
    /// <returns></returns>
    public static TileExitDirection ResultExit(VehicleDirection12 direction)
    {
        switch (direction)
        {
            case VehicleDirection12.HorizontalLeft:
                return TileExitDirection.Left;
            case VehicleDirection12.HorizontalRight:
                return TileExitDirection.Right;
            case VehicleDirection12.VerticalUp:
                return TileExitDirection.Up;
            case VehicleDirection12.VerticalDown:
                return TileExitDirection.Down;

            case VehicleDirection12.UpLeftUp:
                return TileExitDirection.Up;
            case VehicleDirection12.UpLeftLeft:
                return TileExitDirection.Left;
            case VehicleDirection12.UpRightUp:
                return TileExitDirection.Up;
            case VehicleDirection12.UpRightRight:
                return TileExitDirection.Right;

            case VehicleDirection12.DownLeftDown:
                return TileExitDirection.Down;
            case VehicleDirection12.DownLeftLeft:
                return TileExitDirection.Left;
            case VehicleDirection12.DownRightDown:
                return TileExitDirection.Down;
            case VehicleDirection12.DownRightRight:
                return TileExitDirection.Right;
            default:
                return TileExitDirection.Down;
        }
    }
Beispiel #12
0
 /// <summary>
 /// Enter at TileEnterDirection.Left -> yields VehicleDirection12.UpLeftUp,
 /// VehicleDirection12.HorizontalRight,
 /// VehicleDirection12.DownLeftDown
 /// </summary>
 /// <param name="enter_at"></param>
 /// <returns></returns>
 public static VehicleDirection12[] PossibleNewRails3(TileEnterDirection enter_at)
 {
     VehicleDirection12[] ret = new VehicleDirection12[3];
     switch (enter_at)
     {
         case TileEnterDirection.Left:
             ret[0] = VehicleDirection12.UpLeftUp;
             ret[1] = VehicleDirection12.HorizontalRight;
             ret[2] = VehicleDirection12.DownLeftDown;
             break;
         case TileEnterDirection.Down:
             ret[0] = VehicleDirection12.DownLeftLeft;
             ret[1] = VehicleDirection12.VerticalUp;
             ret[2] = VehicleDirection12.DownRightRight;
             break;
         case TileEnterDirection.Up:
             ret[0] = VehicleDirection12.UpLeftLeft;
             ret[1] = VehicleDirection12.VerticalDown;
             ret[2] = VehicleDirection12.UpRightRight;
             break;
         case TileEnterDirection.Right:
             ret[0] = VehicleDirection12.UpRightUp;
             ret[1] = VehicleDirection12.HorizontalLeft;
             ret[2] = VehicleDirection12.DownRightDown;
             break;
         default:
             return null;
     }
     return ret;
 }
Beispiel #13
0
 public static int ToVehicleDirection12Flags_(VehicleDirection12[] directions, int directionsCount)
 {
     int flags = VehicleDirection12Flags.None;
     for (int i = 0; i < directionsCount; i++)
     {
         VehicleDirection12 d = directions[i];
         flags = flags | DirectionUtils.ToVehicleDirection12Flags(d);
     }
     return flags;
 }
Beispiel #14
0
 public static Vector3 NextTile(VehicleDirection12 direction, Vector3 currentTile)
 {
     return NextTile(DirectionUtils.ResultExit(direction), currentTile);
 }
Beispiel #15
0
 internal int PossibleRails(Game game, TileEnterData enter)
 {
     int possible_railsVehicleDirection12Flags = 0;
     if (game.map.IsValidPos(enter.BlockPositionX, enter.BlockPositionY, enter.BlockPositionZ))
     {
         int newpositionrail = game.d_Data.Rail()[
             game.map.GetBlock(enter.BlockPositionX, enter.BlockPositionY, enter.BlockPositionZ)];
         VehicleDirection12[] all_possible_rails = new VehicleDirection12[3];
         int all_possible_railsCount = 0;
         VehicleDirection12[] possibleRails3 = DirectionUtils.PossibleNewRails3(enter.EnterDirection);
         for (int i = 0; i < 3; i++)
         {
             VehicleDirection12 z = possibleRails3[i];
             if ((newpositionrail & DirectionUtils.ToRailDirectionFlags(DirectionUtils.ToRailDirection(z)))
                 != 0)
             {
                 all_possible_rails[all_possible_railsCount++] = z;
             }
         }
         possible_railsVehicleDirection12Flags = DirectionUtils.ToVehicleDirection12Flags_(all_possible_rails, all_possible_railsCount);
     }
     return possible_railsVehicleDirection12Flags;
 }
Beispiel #16
0
    internal void RailOnNewFrame(Game game, float dt)
    {
        if (localMinecart == null)
        {
            localMinecart = new Entity();
            localMinecart.minecart = new Minecart();
            game.EntityAddLocal(localMinecart);
        }
        localMinecart.minecart.enabled = railriding;
        if (railriding)
        {
            Minecart m = localMinecart.minecart;
            m.positionX = game.player.position.x;
            m.positionY = game.player.position.y;
            m.positionZ = game.player.position.z;
            m.direction = currentdirection;
            m.lastdirection = lastdirection;
            m.progress = currentrailblockprogress;
        }

        game.localplayeranimationhint.InVehicle = railriding;
        game.localplayeranimationhint.DrawFixX = 0;
        game.localplayeranimationhint.DrawFixY = railriding ? (-one * 7 / 10) : 0;
        game.localplayeranimationhint.DrawFixZ = 0;

        bool turnright = game.keyboardState[game.GetKey(GlKeys.D)];
        bool turnleft = game.keyboardState[game.GetKey(GlKeys.A)];
        RailSound(game);
        if (railriding)
        {
            game.controls.freemove = true;
            game.enable_move = false;
            Vector3Ref railPos = CurrentRailPos(game);
            game.player.position.x = railPos.X;
            game.player.position.y = railPos.Y;
            game.player.position.z = railPos.Z;
            currentrailblockprogress += currentvehiclespeed * dt;
            if (currentrailblockprogress >= 1)
            {
                lastdirection = currentdirection;
                currentrailblockprogress = 0;
                TileEnterData newenter = new TileEnterData();
                Vector3IntRef nexttile = NextTile(currentdirection, currentrailblockX, currentrailblockY, currentrailblockZ);
                newenter.BlockPositionX = nexttile.X;
                newenter.BlockPositionY = nexttile.Y;
                newenter.BlockPositionZ = nexttile.Z;
                //slope
                if (GetUpDownMove(game, currentrailblockX, currentrailblockY, currentrailblockZ,
                    DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection))) == UpDown.Up)
                {
                    newenter.BlockPositionZ++;
                }
                if (GetUpDownMove(game, newenter.BlockPositionX,
                    newenter.BlockPositionY,
                    newenter.BlockPositionZ - 1,
                    DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection))) == UpDown.Down)
                {
                    newenter.BlockPositionZ--;
                }

                newenter.EnterDirection = DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection));
                BoolRef newdirFound = new BoolRef();
                VehicleDirection12 newdir = BestNewDirection(PossibleRails(game, newenter), turnleft, turnright, newdirFound);
                if (!newdirFound.value)
                {
                    //end of rail
                    currentdirection = DirectionUtils.Reverse(currentdirection);
                }
                else
                {
                    currentdirection = newdir;
                    currentrailblockX = game.platform.FloatToInt(newenter.BlockPositionX);
                    currentrailblockY = game.platform.FloatToInt(newenter.BlockPositionY);
                    currentrailblockZ = game.platform.FloatToInt(newenter.BlockPositionZ);
                }
            }
        }
        if (game.keyboardState[game.GetKey(GlKeys.W)] && game.GuiTyping != TypingState.Typing)
        {
            currentvehiclespeed += 1 * dt;
        }
        if (game.keyboardState[game.GetKey(GlKeys.S)] && game.GuiTyping != TypingState.Typing)
        {
            currentvehiclespeed -= 5 * dt;
        }
        if (currentvehiclespeed < 0)
        {
            currentvehiclespeed = 0;
        }
        //todo fix
        //if (viewport.keypressed != null && viewport.keypressed.Key == GlKeys.Q)
        if (!wasqpressed && game.keyboardState[game.GetKey(GlKeys.Q)] && game.GuiTyping != TypingState.Typing)
        {
            Reverse();
        }
        if (!wasepressed && game.keyboardState[game.GetKey(GlKeys.E)] && !railriding && !game.controls.freemove && game.GuiTyping != TypingState.Typing)
        {
            currentrailblockX = game.platform.FloatToInt(game.player.position.x);
            currentrailblockY = game.platform.FloatToInt(game.player.position.z);
            currentrailblockZ = game.platform.FloatToInt(game.player.position.y) - 1;
            if (!game.map.IsValidPos(currentrailblockX, currentrailblockY, currentrailblockZ))
            {
                ExitVehicle(game);
            }
            else
            {
                int railunderplayer = game.d_Data.Rail()[game.map.GetBlock(currentrailblockX, currentrailblockY, currentrailblockZ)];
                railriding = true;
                originalmodelheight = game.GetCharacterEyesHeight();
                game.SetCharacterEyesHeight(minecartheight());
                currentvehiclespeed = 0;
                if ((railunderplayer & RailDirectionFlags.Horizontal) != 0)
                {
                    currentdirection = VehicleDirection12.HorizontalRight;
                }
                else if ((railunderplayer & RailDirectionFlags.Vertical) != 0)
                {
                    currentdirection = VehicleDirection12.VerticalUp;
                }
                else if ((railunderplayer & RailDirectionFlags.UpLeft) != 0)
                {
                    currentdirection = VehicleDirection12.UpLeftUp;
                }
                else if ((railunderplayer & RailDirectionFlags.UpRight) != 0)
                {
                    currentdirection = VehicleDirection12.UpRightUp;
                }
                else if ((railunderplayer & RailDirectionFlags.DownLeft) != 0)
                {
                    currentdirection = VehicleDirection12.DownLeftLeft;
                }
                else if ((railunderplayer & RailDirectionFlags.DownRight) != 0)
                {
                    currentdirection = VehicleDirection12.DownRightRight;
                }
                else
                {
                    ExitVehicle(game);
                }
                lastdirection = currentdirection;
            }
        }
        else if (!wasepressed && game.keyboardState[game.GetKey(GlKeys.E)] && railriding && game.GuiTyping != TypingState.Typing)
        {
            ExitVehicle(game);
            game.player.position.y += one * 7 / 10;
        }
        wasqpressed = game.keyboardState[game.GetKey(GlKeys.Q)] && game.GuiTyping != TypingState.Typing;
        wasepressed = game.keyboardState[game.GetKey(GlKeys.E)] && game.GuiTyping != TypingState.Typing;
    }
Beispiel #17
0
    public static RailDirection ToRailDirection(VehicleDirection12 direction)
    {
        switch (direction)
        {
            case VehicleDirection12.HorizontalLeft:
                return RailDirection.Horizontal;
            case VehicleDirection12.HorizontalRight:
                return RailDirection.Horizontal;
            case VehicleDirection12.VerticalUp:
                return RailDirection.Vertical;
            case VehicleDirection12.VerticalDown:
                return RailDirection.Vertical;

            case VehicleDirection12.UpLeftUp:
                return RailDirection.UpLeft;
            case VehicleDirection12.UpLeftLeft:
                return RailDirection.UpLeft;
            case VehicleDirection12.UpRightUp:
                return RailDirection.UpRight;
            case VehicleDirection12.UpRightRight:
                return RailDirection.UpRight;

            case VehicleDirection12.DownLeftDown:
                return RailDirection.DownLeft;
            case VehicleDirection12.DownLeftLeft:
                return RailDirection.DownLeft;
            case VehicleDirection12.DownRightDown:
                return RailDirection.DownRight;
            case VehicleDirection12.DownRightRight:
                return RailDirection.DownRight;
            default:
                return RailDirection.DownLeft;
        }
    }
Beispiel #18
0
 internal void Reverse()
 {
     currentdirection = DirectionUtils.Reverse(currentdirection);
     currentrailblockprogress = 1 - currentrailblockprogress;
     lastdirection = currentdirection;
     //currentvehiclespeed = 0;
 }
Beispiel #19
0
    public static VehicleDirection12 Reverse(VehicleDirection12 direction)
    {
        switch (direction)
        {
            case VehicleDirection12.HorizontalLeft:
                return VehicleDirection12.HorizontalRight;
            case VehicleDirection12.HorizontalRight:
                return VehicleDirection12.HorizontalLeft;
            case VehicleDirection12.VerticalUp:
                return VehicleDirection12.VerticalDown;
            case VehicleDirection12.VerticalDown:
                return VehicleDirection12.VerticalUp;

            case VehicleDirection12.UpLeftUp:
                return VehicleDirection12.UpLeftLeft;
            case VehicleDirection12.UpLeftLeft:
                return VehicleDirection12.UpLeftUp;
            case VehicleDirection12.UpRightUp:
                return VehicleDirection12.UpRightRight;
            case VehicleDirection12.UpRightRight:
                return VehicleDirection12.UpRightUp;

            case VehicleDirection12.DownLeftDown:
                return VehicleDirection12.DownLeftLeft;
            case VehicleDirection12.DownLeftLeft:
                return VehicleDirection12.DownLeftDown;
            case VehicleDirection12.DownRightDown:
                return VehicleDirection12.DownRightRight;
            case VehicleDirection12.DownRightRight:
                return VehicleDirection12.DownRightDown;
            default:
                return VehicleDirection12.DownLeftDown;
        }
    }