Esempio n. 1
0
        public void calcNextCollision()
        {
            this.distanceToNextCollision = 1000;

            // calculate next obstruction & future collsisions
            for (int t = 0; t < _waypoints.Count; t++)
            {
                foreach (intActor worldActor in this.world.actors)
                {
                    if (worldActor.worldObject.collisionDetection != CollisionType.None) // only process where collsisions are on
                    {
                        if (worldActor.yielding == false)                                // if they are not already yielding
                        {
                            if (worldActor.route != null)                                // make sure its has an route its following
                            {
                                if (worldActor.route != this)                            // don't compare to yourself.
                                {
                                    Vector2?waypoint = worldActor.route.getWaypoint(t);  // get the same route waypoint for this world actor as we are checking for ours
                                    if ((waypoint != null) && (waypoint.Equals(_waypoints[t])))
                                    {
                                        this.nextCollision           = worldActor.worldObject;
                                        this.distanceToNextCollision = t;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public void conflictResolution(clsObject conflictingObject)
 {
     // yeild to cars on the right
     if (!this.yielding)
     {
         int cardinalDistance = (this.worldObject.cardinalDirection - conflictingObject.cardinalDirection) + 4;
         if (cardinalDistance >= 2)
         {
             this.yielding = true;
         }
     }
 }
Esempio n. 3
0
        public void calcNextObstruction()
        {
            this.distanceToNextObstruction = 1000;

            // calculate next obstruction & future collsisions
            for (int t = 0; t < _waypoints.Count; t++)
            {
                // get the tile in questions
                intTile tile = world.getTileFromTileCoordinate(_waypoints[t]);

                // look for next obstruction
                foreach (intObject worldObject in tile.worldObjects)
                {
                    if (worldObject.collisionDetection != CollisionType.None) // make sure collision detection is on
                    {
                        // we have to add check it it has collision with self
                        this.nextObstruction           = (clsObject)worldObject;
                        this.distanceToNextObstruction = t;
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
 public clsActor(clsWorld world, clsObject worldObject)
 {
     this.world       = world;
     this.worldObject = worldObject;
     this.yielding    = false;
 }