コード例 #1
0
        public void lineManagement()
        {
            // lots of driver stuff in here that probably shouldn't be. Needs to be more generic line drawing

            lines = new List <clsLine>();
            foreach (intActor driver in this.camera.world.actors)
            {
                clsDriverAI driverAI = driver as clsDriverAI;   // Here is where I get typeof(AI)
                if (driverAI != null)
                {
                    if (driverAI.route != null)
                    {
                        Vector2 lastWaypointWorldLocation = driverAI.car.location;
                        for (int t = 0; t < driverAI.route.waypoints; t++)
                        {
                            Vector2 thisWaypointWorldLocation = this.camera.world.tileCoordinateToWorldLocation((Vector2)driverAI.route.getWaypoint(t));
                            if (this.camera.isInVisibleArea(thisWaypointWorldLocation))
                            {
                                lines.Add(new clsLine(lastWaypointWorldLocation, thisWaypointWorldLocation, driverAI.car.color, 4));
                            }
                            lastWaypointWorldLocation = thisWaypointWorldLocation;
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void update()
        {
            if (inputControled)
            {
                float zoomScale = 1.25f;
                if (world.input.isActivated(InputActions.ZoomIn))
                {
                    this.size = new Vector2(this.size.X / zoomScale, this.size.Y / zoomScale);
                }

                if (world.input.isActivated(InputActions.ZoomOut))
                {
                    this.size = new Vector2(this.size.X * zoomScale, this.size.Y * zoomScale);
                }
            }


            // filter world objects to viewable items
            visibleObjects = new List <intObject>();
            foreach (intObject o in this.world.worldObjects)
            {
                if (this.isInVisibleArea(o.location))
                {
                    visibleObjects.Add(o);
                }
            }


            // camera overlay
            text = new List <string>();
            for (int a = 0; a < world.actors.Count; a++)
            {
                intActor driver = world.actors[a];

                clsDriverHuman driverHuman = driver as clsDriverHuman;   // Here is where I get typeof(IA)
                if (driverHuman != null)
                {
                    text.Add("--------------------");
                    text.Add("Name : " + driverHuman.car.name + " (" + a + ")");
                    text.Add("Speed : " + Math.Floor(driverHuman.car.mph) + " MPH");
                    //text.Add("Collisions : " + c.collisions.Count);
                    //text.Add("Direction : " + c.cardinalDirection.ToString());
                    //text.Add("Coordinates : ( " + c.location.X + " , " + c.location.Y + " )");
                    //text.Add("velocity : " + c.velocity.Length());
                    //text.Add("Steering : " + c.steeringWheel);
                    text.Add("Shifter : " + driverHuman.car.shifter.ToString().ToUpper());
                    text.Add("Acceleerator Pedal : " + driverHuman.car.acceleratorPedal);
                    text.Add("Break Pedal : " + driverHuman.car.breakPedal);
                }

                // route lines
                clsDriverAI driverAI = driver as clsDriverAI;
                if (driverAI != null)
                {
                    text.Add("--------------------");
                    text.Add("Name : " + driverAI.car.name + " (" + a + ")");
                    text.Add("Speed : " + Math.Floor(driverAI.car.mph) + " MPH");
                    text.Add("Obstruction : " + driverAI.route.distanceToNextObstruction);
                    text.Add("Collision : " + driverAI.route.distanceToNextCollision);
                    text.Add("Turn : " + driverAI.route.distanceToNextCollision);
                    text.Add("Yield : " + driverAI.yielding);
                    //text.Add("Direction : " + c.cardinalDirection.ToString());
                    //text.Add("Coordinates : ( " + c.location.X + " , " + c.location.Y + " )");
                    //text.Add("velocity : " + c.velocity.Length());
                    //text.Add("Steering : " + c.steeringWheel);
                    //text.Add("Shifter : " + c.shifter.ToString().ToUpper());
                    //text.Add("Acceleerator Pedal : " + c.acceleratorPedal);
                    //text.Add("Break Pedal : " + c.breakPedal);
                }
            }
        }