public override void Close()
 {
     _team1.Clear();
     _team2.Clear();
     _missiles.Clear();
     _pd = null;
 }
Example #2
0
 private void CreateDatabase()
 {
     Vector3 center = Vector3.Zero;
     const float DIV = 10.0f;
     Vector3 divisions = new Vector3(DIV, DIV, DIV);
     const float DIAMETER = Fighter.WORLD_RADIUS * 2;
     Vector3 dimensions = new Vector3(DIAMETER, DIAMETER, DIAMETER);
     _pd = new LocalityQueryProximityDatabase<IVehicle>(center, dimensions, divisions);
 }
Example #3
0
        // constructor
        public Pedestrian(IProximityDatabase <IVehicle> pd, IAnnotationService annotations = null)
            : base(annotations)
        {
            // allocate a token for this boid in the proximity database
            _proximityToken = null;
            NewPD(pd);

            // reset Pedestrian state
            Reset();
        }
        private void CreateDatabase()
        {
            Vector3     center     = Vector3.Zero;
            const float DIV        = 10.0f;
            Vector3     divisions  = new Vector3(DIV, DIV, DIV);
            const float DIAMETER   = Fighter.WORLD_RADIUS * 2;
            Vector3     dimensions = new Vector3(DIAMETER, DIAMETER, DIAMETER);

            _pd = new LocalityQueryProximityDatabase <IVehicle>(center, dimensions, divisions);
        }
Example #5
0
 public Missile(IProximityDatabase <IVehicle> proximity, IVehicle target, IAnnotationService annotation)
     : base(annotation)
 {
     _trail = new Trail(1, 10)
     {
         TrailColor = Color.Red,
         TickColor  = Color.DarkRed
     };
     _proximityToken = proximity.AllocateToken(this);
     Target          = target;
 }
Example #6
0
 public Missile(IProximityDatabase<IVehicle> proximity, IVehicle target, IAnnotationService annotation)
     :base(annotation)
 {
     _trail = new Trail(1, 10)
     {
         TrailColor = Color.Red,
         TickColor = Color.DarkRed
     };
     _proximityToken = proximity.AllocateToken(this);
     Target = target;
 }
Example #7
0
		// constructor
		public Boid(IProximityDatabase<IVehicle> pd, IAnnotationService annotations = null)
            :base(annotations)
		{
			// allocate a token for this boid in the proximity database
			_proximityToken = null;
			NewPD(pd);

		    _trail = new Trail(2f, 60);

			// reset all boid state
			Reset();
		}
Example #8
0
        // switch to new proximity database -- just for demo purposes
        public void NewPD(IProximityDatabase <IVehicle> pd)
        {
            // delete this boid's token in the old proximity database
            if (_proximityToken != null)
            {
                _proximityToken.Dispose();
                _proximityToken = null;
            }

            // allocate a token for this boid in the proximity database
            _proximityToken = pd.AllocateToken(this);
        }
Example #9
0
        public Fighter(IProximityDatabase <IVehicle> proximity, IAnnotationService annotation, Action <Fighter, Fighter> fireMissile)
            : base(annotation)
        {
            _trail = new Trail(5, 50)
            {
                TrailColor = Color.WhiteSmoke,
                TickColor  = Color.LightGray
            };
            _proximityToken = proximity.AllocateToken(this);

            _fireMissile = fireMissile;
        }
Example #10
0
        // constructor
        public Boid(IProximityDatabase <IVehicle> pd, IAnnotationService annotations = null)
            : base(annotations)
        {
            // allocate a token for this boid in the proximity database
            _proximityToken = null;
            NewPD(pd);

            _trail = new Trail(2f, 60);

            // reset all boid state
            Reset();
        }
        private static ITokenForProximityDatabase<object> CreateToken(IProximityDatabase<object> db, Vector3 position, IDictionary<object, Vector3> lookup)
        {
            var obj = new object();

            if (lookup != null)
                lookup.Add(obj, position);

            var token = db.AllocateToken(obj);
            token.UpdateForNewPosition(position);

            return token;
        }
Example #12
0
        public Fighter(IProximityDatabase<IVehicle> proximity, IAnnotationService annotation, Action<Fighter, Fighter> fireMissile)
            :base(annotation)
        {
            _trail = new Trail(5, 50)
            {
                TrailColor = Color.WhiteSmoke,
                TickColor = Color.LightGray
            };
            _proximityToken = proximity.AllocateToken(this);

            _fireMissile = fireMissile;
        }
Example #13
0
        private static ITokenForProximityDatabase <object> CreateToken(IProximityDatabase <object> db, Vector3 position, IDictionary <object, Vector3> lookup)
        {
            var obj = new object();

            if (lookup != null)
            {
                lookup.Add(obj, position);
            }

            var token = db.AllocateToken(obj);

            token.UpdateForNewPosition(position);

            return(token);
        }
Example #14
0
		// switch to new proximity database -- just for demo purposes
		public void NewPD(IProximityDatabase<IVehicle> pd)
		{
			// delete this boid's token in the old proximity database
			if (_proximityToken != null)
			{
				_proximityToken.Dispose();
				_proximityToken = null;
			}

			// allocate a token for this boid in the proximity database
			_proximityToken = pd.AllocateToken(this);
		}
Example #15
0
		// constructor
        public Pedestrian(IProximityDatabase<IVehicle> pd, IAnnotationService annotations = null)
            :base(annotations)
		{
			// allocate a token for this boid in the proximity database
			_proximityToken = null;
			NewPD(pd);

			// reset Pedestrian state
			Reset();
		}
Example #16
0
 public override void Close()
 {
     _team1.Clear();
     _team2.Clear();
     _missiles.Clear();
     _pd = null;
 }