示例#1
0
        public MainWindow()
        {
            InitializeComponent();

            CreateBoard(xOfBoard, yOfBoard);
            CreateTablicaTypowPol();

            PoleCollection plansza = new PoleCollection(xOfBoard, yOfBoard, tablicaTypowPol);

            this.traktorek = new Traktor_agent(25, 100, plansza);
            BoardToTraktor.Children.Add(traktorek.image);

            dispatcherTimer.Tick    += dispatcherTimer_Tick;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 500);

            dispatcherTimerMoving.Tick    += dispatcherTimerMoving_Tick;
            dispatcherTimerMoving.Interval = new TimeSpan(0, 0, 0, 0, 500);

            directionX = RandomNumber(1, xOfBoard + 1);
            directionY = RandomNumber(1, yOfBoard + 1);
            //trasa = traktorek.AGwiazdka(directionX, directionY);

            //dispatcherTimer.Start();
            changeSeason();

            dispatcherTimerToHome.Tick    += dispatcherTimerToHome_Tick;
            dispatcherTimerToHome.Interval = new TimeSpan(0, 0, 0, 0, 500);
        }
示例#2
0
 void refill(Traktor_agent traktor)
 {
     traktor.jednostkiNawozu = 10;
     traktorek.tankuj(traktorek.paliwo_max);
     dispatcherTimerToHome.Stop();
     //dispatcherTimer.Start();
 }
示例#3
0
        void MoveTraktor(int x, int y, Traktor_agent traktor)
        {
            if (x == traktorek.pozycja.x && y == traktorek.pozycja.y)
            {
                return;
            }
            if (traktorek.paliwo_poziom <= 0 || traktorek.jednostkiNawozu < 1)
            {
                goTo(1, 1, traktorek);
                needToRefill = true;
                return;
            }
            NawozLabel.Content  = "Pozostało nawozu: " + traktorek.jednostkiNawozu.ToString();
            PaliwoLabel.Content = "Pozostało paliwa: " + traktorek.paliwo_poziom.ToString();
            //if (x > xOfBoard || y > yOfBoard || GetTypeOfField(x,y)=="stone") return;
            if (GetTypeOfField(x, y) == "stone")
            {
                return;
            }
            //Canvas.SetLeft(traktor.image, (x-1)*50);
            //Canvas.SetTop(traktor.image, (y-1)*50);
            //traktor.poz_x = x;
            //traktor.poz_y = y;
            Console.WriteLine("Jadę do: x " + directionX.ToString() + " y " + directionY.ToString());
            goTo(x, y, traktor);
            Console.WriteLine(GetTypeOfField(traktor.poz_x, traktor.poz_y));
            Console.WriteLine(zasiac(PoraRokuLabel.Content.ToString(), PoraDniaLabel.Content.ToString(), GetTypeOfField(traktor.poz_x, traktor.poz_y)));

            zasiej(traktorek);
            //if (traktorek.jednostkiNawozu < 1) dispatcherTimerToHome.Start();
        }
示例#4
0
 //DRZEWWWWOOO,
 void zasiej(Traktor_agent traktor)
 {
     if (traktor.jednostkiNawozu > 0)
     {
         if (GetTypeOfField(traktor.poz_x, traktor.poz_y) != "stone" && GetTypeOfField(traktor.poz_x, traktor.poz_y) != "error" && zasiac(PoraRokuLabel.Content.ToString(), PoraDniaLabel.Content.ToString(), GetTypeOfField(traktor.poz_x, traktor.poz_y)))
         {
             upgradeField(traktor.poz_x, traktor.poz_y);
             traktor.jednostkiNawozu--;
             NawozLabel.Content = "Pozostało nawozu: " + traktor.jednostkiNawozu.ToString();
         }
     }
     else
     {
         Console.WriteLine("brakuje nawozu");
     }
 }
示例#5
0
        public void goTo(int x, int y, Traktor_agent traktor)
        {
            //dispatcherTimer.Stop();
            directionX = x;
            directionY = y;

            LogJazdy.Content = "Jadę do: x " + x.ToString() + " y " + y.ToString();
            trasa            = traktor.AGwiazdka(x, y);
            int i = 0;

            stepCounterHelper = i;
            while (trasa[i] == traktorek.pozycja && i < trasa.Count - 1)
            {
                i++;
                stepCounterHelper = i;
            }
            dispatcherTimerMoving.Start();
        }