internal int GetUpDownMove(Game game, int railblockX, int railblockY, int railblockZ, TileEnterDirection dir) { if (!game.map.IsValidPos(railblockX, railblockY, railblockZ)) { return(UpDown.None); } //going up RailSlope slope = d_RailMapUtil.GetRailSlope(railblockX, railblockY, railblockZ); if (slope == RailSlope.TwoDownRaised && dir == TileEnterDirection.Up) { return(UpDown.Up); } if (slope == RailSlope.TwoUpRaised && dir == TileEnterDirection.Down) { return(UpDown.Up); } if (slope == RailSlope.TwoLeftRaised && dir == TileEnterDirection.Right) { return(UpDown.Up); } if (slope == RailSlope.TwoRightRaised && dir == TileEnterDirection.Left) { return(UpDown.Up); } //going down if (slope == RailSlope.TwoDownRaised && dir == TileEnterDirection.Down) { return(UpDown.Down); } if (slope == RailSlope.TwoUpRaised && dir == TileEnterDirection.Up) { return(UpDown.Down); } if (slope == RailSlope.TwoLeftRaised && dir == TileEnterDirection.Left) { return(UpDown.Down); } if (slope == RailSlope.TwoRightRaised && dir == TileEnterDirection.Right) { return(UpDown.Down); } return(UpDown.None); }
UpDown GetUpDownMove(Vector3 railblock, TileEnterDirection dir) { if (!MapUtil.IsValidPos(d_Map, (int)railblock.X, (int)railblock.Y, (int)railblock.Z)) { return(UpDown.None); } //going up RailSlope slope = d_RailMapUtil.GetRailSlope((int)railblock.X, (int)railblock.Y, (int)railblock.Z); if (slope == RailSlope.TwoDownRaised && dir == TileEnterDirection.Up) { return(UpDown.Up); } if (slope == RailSlope.TwoUpRaised && dir == TileEnterDirection.Down) { return(UpDown.Up); } if (slope == RailSlope.TwoLeftRaised && dir == TileEnterDirection.Right) { return(UpDown.Up); } if (slope == RailSlope.TwoRightRaised && dir == TileEnterDirection.Left) { return(UpDown.Up); } //going down if (slope == RailSlope.TwoDownRaised && dir == TileEnterDirection.Down) { return(UpDown.Down); } if (slope == RailSlope.TwoUpRaised && dir == TileEnterDirection.Up) { return(UpDown.Down); } if (slope == RailSlope.TwoLeftRaised && dir == TileEnterDirection.Left) { return(UpDown.Down); } if (slope == RailSlope.TwoRightRaised && dir == TileEnterDirection.Right) { return(UpDown.Down); } return(UpDown.None); }
internal Vector3Ref CurrentRailPos(Game game) { RailSlope slope = d_RailMapUtil.GetRailSlope(currentrailblockX, currentrailblockY, currentrailblockZ); float aX = currentrailblockX; float aY = currentrailblockY; float aZ = currentrailblockZ; float x_correction = 0; float y_correction = 0; float z_correction = 0; float half = one / 2; switch (currentdirection) { case VehicleDirection12.HorizontalRight: x_correction += currentrailblockprogress; y_correction += half; if (slope == RailSlope.TwoRightRaised) { z_correction += currentrailblockprogress; } if (slope == RailSlope.TwoLeftRaised) { z_correction += 1 - currentrailblockprogress; } break; case VehicleDirection12.HorizontalLeft: x_correction += 1 - currentrailblockprogress; y_correction += half; if (slope == RailSlope.TwoRightRaised) { z_correction += 1 - currentrailblockprogress; } if (slope == RailSlope.TwoLeftRaised) { z_correction += currentrailblockprogress; } break; case VehicleDirection12.VerticalDown: x_correction += half; y_correction += currentrailblockprogress; if (slope == RailSlope.TwoDownRaised) { z_correction += currentrailblockprogress; } if (slope == RailSlope.TwoUpRaised) { z_correction += 1 - currentrailblockprogress; } break; case VehicleDirection12.VerticalUp: x_correction += half; y_correction += 1 - currentrailblockprogress; if (slope == RailSlope.TwoDownRaised) { z_correction += 1 - currentrailblockprogress; } if (slope == RailSlope.TwoUpRaised) { z_correction += currentrailblockprogress; } break; case VehicleDirection12.UpLeftLeft: x_correction += half * (1 - currentrailblockprogress); y_correction += half * currentrailblockprogress; break; case VehicleDirection12.UpLeftUp: x_correction += half * currentrailblockprogress; y_correction += half - half * currentrailblockprogress; break; case VehicleDirection12.UpRightRight: x_correction += half + half * currentrailblockprogress; y_correction += half * currentrailblockprogress; break; case VehicleDirection12.UpRightUp: x_correction += 1 - half * currentrailblockprogress; y_correction += half - half * currentrailblockprogress; break; case VehicleDirection12.DownLeftLeft: x_correction += half * (1 - currentrailblockprogress); y_correction += 1 - half * currentrailblockprogress; break; case VehicleDirection12.DownLeftDown: x_correction += half * currentrailblockprogress; y_correction += half + half * currentrailblockprogress; break; case VehicleDirection12.DownRightRight: x_correction += half + half * currentrailblockprogress; y_correction += 1 - half * currentrailblockprogress; break; case VehicleDirection12.DownRightDown: x_correction += 1 - half * currentrailblockprogress; y_correction += half + half * currentrailblockprogress; break; } //+1 because player can't be inside rail block (picking wouldn't work) return(Vector3Ref.Create(aX + x_correction, aZ + railheight + 1 + z_correction, aY + y_correction)); }