Beispiel #1
0
        public static TruckAnimation FindNextTo(
            IMapTile ModelTile,
            Travel.Extremity to)
        {
            if (ModelTile is IRoadTile)
            {
                IRoadTile Road = (IRoadTile)ModelTile;
                switch (Road.Type)
                {
                case RoadTile.RoadType.BottomLeft:
                    if (to == Travel.Extremity.Left)
                    {
                        return(TruckAnimation.Bottom2Left);
                    }
                    else
                    {
                        return(TruckAnimation.Left2Bottom);
                    }

                case RoadTile.RoadType.BottomRight:
                    if (to == Travel.Extremity.Right)
                    {
                        return(TruckAnimation.Bottom2Right);
                    }
                    else
                    {
                        return(TruckAnimation.Right2Bottom);
                    }

                case RoadTile.RoadType.Horizontal:
                    if (to == Travel.Extremity.Right)
                    {
                        return(TruckAnimation.Left2Right);
                    }
                    else
                    {
                        return(TruckAnimation.Right2Left);
                    }

                case RoadTile.RoadType.TopLeft:
                    if (to == Travel.Extremity.Top)
                    {
                        return(TruckAnimation.Left2Top);
                    }
                    else
                    {
                        return(TruckAnimation.Top2Left);
                    }

                case RoadTile.RoadType.TopRight:
                    if (to == Travel.Extremity.Top)
                    {
                        return(TruckAnimation.Right2Top);
                    }
                    else
                    {
                        return(TruckAnimation.Top2Right);
                    }

                case RoadTile.RoadType.Vertical:
                    if (to == Travel.Extremity.Top)
                    {
                        return(TruckAnimation.Bottom2Top);
                    }
                    else
                    {
                        return(TruckAnimation.Top2Bottom);
                    }

                default:
                    throw new ArgumentException("Can't match tile and direction");
                }
            }
            else
            {
                throw new ArgumentException("Can't animate the truck somewhere else than on a road");
            }
        }
Beispiel #2
0
        public static TruckAnimation FindNext(
            Travel.Extremity from,
            Travel.Extremity to)
        {
            switch (from)
            {
            case Travel.Extremity.Top:
                switch (to)
                {
                case Travel.Extremity.Bottom:
                    return(TruckAnimation.Top2Bottom);

                case Travel.Extremity.Left:
                    return(TruckAnimation.Top2Left);

                case Travel.Extremity.Right:
                    return(TruckAnimation.Top2Right);

                default:
                    throw new ArgumentException("Can't move from top to top");
                }

            case Travel.Extremity.Bottom:
                switch (to)
                {
                case Travel.Extremity.Top:
                    return(TruckAnimation.Bottom2Top);

                case Travel.Extremity.Left:
                    return(TruckAnimation.Bottom2Left);

                case Travel.Extremity.Right:
                    return(TruckAnimation.Bottom2Right);

                default:
                    throw new ArgumentException("Can't move from bottom to bottom");
                }

            case Travel.Extremity.Left:
                switch (to)
                {
                case Travel.Extremity.Top:
                    return(TruckAnimation.Left2Top);

                case Travel.Extremity.Right:
                    return(TruckAnimation.Left2Right);

                case Travel.Extremity.Bottom:
                    return(TruckAnimation.Left2Bottom);

                default:
                    throw new ArgumentException("Can't move from left to left");
                }

            case Travel.Extremity.Right:
                switch (to)
                {
                case Travel.Extremity.Top:
                    return(TruckAnimation.Right2Top);

                case Travel.Extremity.Left:
                    return(TruckAnimation.Right2Left);

                case Travel.Extremity.Bottom:
                    return(TruckAnimation.Right2Bottom);

                default:
                    throw new ArgumentException("Can't move from right to right");
                }

            default:
                throw new ArgumentException("Impossible case: " + from);
            }
        }