示例#1
0
        public void initControl(SkinModelSkelAnim skinAniModel)
        {
            m_radar = new Radar();
            m_vehicle = new Biped();

            //m_vehicle.Radar = m_radar;
            //m_vehicle.ArrivalRadius = 1;
            //m_vehicle.AllowedMovementAxes = new Vector3(1, 0, 1);
            //m_vehicle.MaxSpeed = 10;
            //m_vehicle.setSpeed(5);
            //m_vehicle.initOwner(skinAniModel.rootGo);

            //m_radar.Vehicle = m_vehicle;
            //m_radar.initAwake();
            m_radar.DetectionRadius = 100;
        }
        private void HandleDetection(Radar radar)
        {
            /*
		 * Neighbors are cached on radar detection.
		 * 
		 * This means that IsInNeighborhood is evaluated when 
		 * detected, not every time that the behavior is going to 
		 * calculate its forces.  
		 * 
		 * This helps in lowering the processing load, but could 
		 * lead to a case where a vehicle is beyond the set parameters 
		 * but still considered a neighbor.
		 * 
		 * If this is a concern, make sure that vehicles are detected
		 * as often as the vehicle updates is forces.
		 * 
		 */

            _neighbors.Clear();
            // I'd prefer an iterator, but trying to cut down on allocations
            for (var i = 0; i < radar.Vehicles.Count; i++)
            {
                var other = radar.Vehicles[i];
                if (Vehicle.IsInNeighborhood(other, MinRadius, MaxRadius, AngleCos))
                {
                    _neighbors.Add(other);
                }
            }
        }