Пример #1
0
 public void setNewTarget( Producer target )
 {
     this.CurrentTarget = target.Position;
     this.targetProducer = target;
     this.Running = true;
     this.IsHome = false;
     directionVector = new PointF( this.CurrentTarget.X - this.Position.X, this.CurrentTarget.Y - this.Position.Y );
     timer.Start();
 }
Пример #2
0
 private void stashRessources()
 {
     this.homeTown.addRessourceToStash( this.Freight );
     this.CurrentTarget = this.Position;
     this.targetProducer = null;
     this.Running = false;
 }
Пример #3
0
        private void createProducers( int producerCount )
        {
            Random random = new Random();
            for ( int i = 0; i <= producerCount; i++ )
            {
                int ressourceID = random.Next( RessourceManager.Instance().ressourceCount() );
                Ressource ressource = new Ressource( ressourceID );
                PointF producerPosition = new PointF( random.Next( -50, 50 ) + this.Position.X, random.Next( -50, 50 ) + this.Position.Y );

                Producer newProducer = new Producer( ressource, random.Next( 10000, 30000 ), random.Next( 1, 10 ), random.Next( 50, 150 ), producerPosition );
                newProducer.newProducts += this.sendCarrier;
                this.repaint += newProducer.Repaint;

                this.producers.Add( newProducer );
            }
        }
Пример #4
0
 private void getRessourcesAndReturnHome()
 {
     this.Freight = this.targetProducer.getRessources();
     this.targetProducer = null;
     this.setNewTarget( this.homeTown );
     this.Running = true;
     this.timer.Start();
 }
Пример #5
0
 private void sendCarrier( Producer producer )
 {
     foreach ( Carrier carrier in this.carriers )
     {
         if ( carrier.IsHome )
         {
             carrier.setNewTarget( producer );
             break;
         }
     }
 }