Exemplo n.º 1
0
        public Animal(MutexTable table, int range, int tickTimeMsec,
            WanderDelegate wander, EvadeOrHuntDelegate evadeOrHunt)
        {
            _thread = new Thread(doBehaviour);
            _thread.SetApartmentState(ApartmentState.STA);

            if (table == null)
                throw new NullReferenceException();

            _table = table;

            _tickTimeMsec = tickTimeMsec;

            if (range <= 0)
                throw new InvalidOperationException();

            _range = range;

            if (evadeOrHunt == null || wander == null)
                throw new InvalidOperationException();

            _evadeOrHunt = evadeOrHunt;
            _wander = wander;

            _symbol = new Ellipse();
            Dispatcher.FromThread(_table.WindowThread).BeginInvoke(DispatcherPriority.Render, (Action)(() =>
            {
                _table.DrawingGrid.Children.Add(_symbol);
            }
            ));
        }
Exemplo n.º 2
0
 public Wolf(MutexTable table,
     WanderDelegate wander, EvadeOrHuntDelegate evadeOrHunt)
     : base(table, table.WolfRange, table.WolfTickTimeMsec, wander, evadeOrHunt)
 {
     _symbol.Height = 12;
     _symbol.Width = 12;
     _symbol.Fill= System.Windows.Media.Brushes.Blue;
     _symbol.StrokeThickness = 2;
 }
Exemplo n.º 3
0
 public Wolf(MutexTable table,
             WanderDelegate wander, EvadeOrHuntDelegate evadeOrHunt) :
     base(table, table.WolfRange, table.WolfTickTimeMsec, wander, evadeOrHunt)
 {
     _symbol.Height          = 12;
     _symbol.Width           = 12;
     _symbol.Fill            = System.Windows.Media.Brushes.Blue;
     _symbol.StrokeThickness = 2;
 }
Exemplo n.º 4
0
 public Sheep(MutexTable table, WanderDelegate wander, EvadeOrHuntDelegate evadeOrHunt)
     : base(table, table.SheepRange, table.SheepTickTimeMsec, wander, evadeOrHunt)
 {
     //do nothing for now
     _symbol.Height          = 10;
     _symbol.Width           = 10;
     _symbol.Stroke          = System.Windows.Media.Brushes.Red;
     _symbol.Fill            = System.Windows.Media.Brushes.Red;
     _symbol.StrokeThickness = 2;
 }
Exemplo n.º 5
0
 public Sheep(MutexTable table, WanderDelegate wander, EvadeOrHuntDelegate evadeOrHunt)
     : base(table, table.SheepRange, table.SheepTickTimeMsec, wander, evadeOrHunt)
 {
     //do nothing for now
     _symbol.Height = 10;
     _symbol.Width = 10;
     _symbol.Stroke = System.Windows.Media.Brushes.Red;
     _symbol.Fill = System.Windows.Media.Brushes.Red;
     _symbol.StrokeThickness = 2;
 }
Exemplo n.º 6
0
        public Animal(MutexTable table, int range, int tickTimeMsec,
                      WanderDelegate wander, EvadeOrHuntDelegate evadeOrHunt)
        {
            _thread = new Thread(doBehaviour);
            _thread.SetApartmentState(ApartmentState.STA);

            if (table == null)
            {
                throw new NullReferenceException();
            }

            _table = table;

            _tickTimeMsec = tickTimeMsec;

            if (range <= 0)
            {
                throw new InvalidOperationException();
            }

            _range = range;

            if (evadeOrHunt == null || wander == null)
            {
                throw new InvalidOperationException();
            }

            _evadeOrHunt = evadeOrHunt;
            _wander      = wander;

            _symbol = new Ellipse();
            Dispatcher.FromThread(_table.WindowThread).BeginInvoke(DispatcherPriority.Render, (Action)(() =>
            {
                _table.DrawingGrid.Children.Add(_symbol);
            }
                                                                                                       ));
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     tb = new MutexTable(50, 9, 5, grid, 300);
     grid.ShowGridLines = true;
 }