Example #1
0
        public Car(WayPoint initialPoint, HandRule handRule, Brush carColor)
        {
            this.HandRule       = handRule;
            this.CarColor       = carColor;
            this.SquareCollider = new SquareCollider(initialPoint.SquareCollider.Position, new Size2D(10, 7));
            this.Collision     += new EventHandler <BodyEventArgs>(Car_Collision);

            this.CurrentWayPoint = null;
            this.WayPointMatrix  = initialPoint.Parent;

            this.OnCollision(initialPoint, CollisionType.Square, -1);
        }
Example #2
0
        public WayPoint GetNextWayPoint(WayPoint where, HandRule handRule)
        {
            #region where == this.North
            if (where == this.North)
            {
                switch (handRule)
                {
                case HandRule.Right:
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    break;

                case HandRule.Left:
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    break;
                }
            }
            #endregion
            #region where == this.South
            else if (where == this.South)
            {
                switch (handRule)
                {
                case HandRule.Right:
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    break;

                case HandRule.Left:
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    break;
                }
            }
            #endregion
            #region where == this.East
            else if (where == this.East)
            {
                switch (handRule)
                {
                case HandRule.Right:
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    break;

                case HandRule.Left:
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    break;
                }
            }
            #endregion
            #region where == this.West
            else if (where == this.West)
            {
                switch (handRule)
                {
                case HandRule.Right:
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    break;

                case HandRule.Left:
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    break;
                }
            }
            #endregion
            #region where == this
            else if (where == this)
            {
                switch (handRule)
                {
                case HandRule.Right:
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    break;

                case HandRule.Left:
                    if (this.HasNorth)
                    {
                        return(this.North);
                    }
                    if (this.HasEast)
                    {
                        return(this.East);
                    }
                    if (this.HasSouth)
                    {
                        return(this.South);
                    }
                    if (this.HasWest)
                    {
                        return(this.West);
                    }
                    break;
                }
            }
            #endregion

            return(where);
        }