/// <summary> /// Creates a new Carrier /// </summary> /// <param name="speed">The speed of the Carrier, must be between 1 and 100</param> /// <param name="position">The start position of the Carrier</param> public Carrier( int speed, Town initialLocation ) { this.Speed = speed; this.Position = initialLocation.Position; this.homeTown = initialLocation; CurrentTarget = this.Position; this.Running = false; this.IsHome = true; timer = new System.Timers.Timer( 100 ); // every 1/10th of a second timer.Elapsed += new System.Timers.ElapsedEventHandler( move ); }
public void setNewTarget( Town target ) { this.CurrentTarget = target.Position; this.targetProducer = null; this.Running = true; this.IsHome = false; directionVector = new PointF( this.CurrentTarget.X - this.Position.X, this.CurrentTarget.Y - this.Position.Y ); timer.Start(); }