/// <summary> /// Constructor /// </summary> /// <param name="soi"></param> /// <param name="position"></param> /// <param name="heading"></param> public SimObstacle(SimObstacleId soi, Coordinates position, Coordinates heading) { this.ObstacleId = soi; this.Position = position; this.Heading = heading; this.length = 4; this.width = 2; }
/// <summary> /// Constructor /// </summary> /// <param name="soi"></param> /// <param name="position"></param> /// <param name="heading"></param> /// <param name="length"></param> /// <param name="width"></param> public SimObstacle(SimObstacleId soi, Coordinates position, Coordinates heading, double length, double width) { this.ObstacleId = soi; this.Position = position; this.Heading = heading; this.width = width; this.length = length; }
/// <summary> /// Obstacle /// </summary> /// <param name="screenCenter"></param> /// <returns></returns> public SimObstacle AddObstacle(Coordinates screenCenter) { // deafualt id is # of elts int idNumber = this.WorldService.Obstacles.Count + this.Vehicles.Count; // create array to hold used vehicle and obstacle id's bool[] usedIds = new bool[this.WorldService.Obstacles.Count + this.Vehicles.Count]; // loop over obstacles and get ids foreach (SimObstacle ism in this.WorldService.Obstacles.Values) { // make sure num within # of obstacles and vehicles if (ism.ObstacleId.Number < this.WorldService.Obstacles.Count + this.Vehicles.Count) { // check off usedIds[ism.ObstacleId.Number] = true; } } // loop over vehicles and get ids foreach (SimVehicle ism in this.Vehicles.Values) { // make sure num within # of obstacles and vehicles if (ism.VehicleId.Number < this.WorldService.Obstacles.Count + this.Vehicles.Count) { // check off usedIds[ism.VehicleId.Number] = true; } } // loop over checked off id's for (int i = usedIds.Length - 1; i >= 0; i--) { // if find a false one set that id if (usedIds[i] == false) { // set id num idNumber = i; } } // create obstacle id SimObstacleId soi = new SimObstacleId(idNumber); // get position (center of screen) Coordinates position = screenCenter; // create obstacle SimObstacle so = new SimObstacle(soi, position, new Coordinates(1, 0)); // add to obstacles this.WorldService.Obstacles.Add(so.ObstacleId, so); // return return(so); }
/// <summary> /// Check if two id's are equal /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (obj is SimObstacleId) { SimObstacleId other = (SimObstacleId)obj; return(this.number == other.Number); } else { return(false); } }
/// <summary> /// Obstacle /// </summary> /// <param name="screenCenter"></param> /// <returns></returns> public SimObstacle AddObstacle(Coordinates screenCenter) { // deafualt id is # of elts int idNumber = this.WorldService.Obstacles.Count + this.Vehicles.Count; // create array to hold used vehicle and obstacle id's bool[] usedIds = new bool[this.WorldService.Obstacles.Count + this.Vehicles.Count]; // loop over obstacles and get ids foreach (SimObstacle ism in this.WorldService.Obstacles.Values) { // make sure num within # of obstacles and vehicles if (ism.ObstacleId.Number < this.WorldService.Obstacles.Count + this.Vehicles.Count) { // check off usedIds[ism.ObstacleId.Number] = true; } } // loop over vehicles and get ids foreach (SimVehicle ism in this.Vehicles.Values) { // make sure num within # of obstacles and vehicles if (ism.VehicleId.Number < this.WorldService.Obstacles.Count + this.Vehicles.Count) { // check off usedIds[ism.VehicleId.Number] = true; } } // loop over checked off id's for (int i = usedIds.Length - 1; i >= 0; i--) { // if find a false one set that id if (usedIds[i] == false) { // set id num idNumber = i; } } // create obstacle id SimObstacleId soi = new SimObstacleId(idNumber); // get position (center of screen) Coordinates position = screenCenter; // create obstacle SimObstacle so = new SimObstacle(soi, position, new Coordinates(1, 0)); // add to obstacles this.WorldService.Obstacles.Add(so.ObstacleId, so); // return return so; }