static void Main(string[] args) { /* Get directives */ Console.WriteLine("Komutları giriniz"); string directives = Console.ReadLine(); /* Split directives then run commands. */ Harita.splitDirectiveThenRun(directives); }
/* Prepare map */ public static int[,] PrepareMap(string boyut) { int dizi_boyutu = convert(boyut); /* Set size from struct of map. */ Harita.setSize(dizi_boyutu); Map.dizi = prepareArray(dizi_boyutu); /* Fill array with 0 */ fillArray(); return(Map.dizi); }
/* Show map */ public static void ShowMap() { for (int i = 0; i < Harita.getSize(); i++) { for (int j = 0; j < Harita.getSize(); j++) { if (Map.dizi[i, j] == 1) { Console.Write("* "); } else { Console.Write(Map.dizi[i, j] + " "); } } Console.WriteLine(); } }
public static void move(int x, int y) { if (marked) { Harita.mark(Araba.x, Araba.y); } int i_temp = (Araba.x + x) % Harita.getSize(); if (i_temp < 0) { i_temp = Harita.getSize() - 1; } Araba.x = i_temp; i_temp = (Araba.y + y) % Harita.getSize(); if (i_temp < 0) { i_temp = Harita.getSize() - 1; } Araba.y = i_temp; }
public static int getMove(string directive) { String[] split = directive.Split('_'); return(Harita.convert(split[1])); }
public static void splitDirectiveThenRun(string directives) { /* * Split string from '+' (plus) char then check directive. */ for (int i = 0; i < directives.Split('+').Length; i++) { /* Handle first loop */ if (i == 0) { /* Prepare map */ Harita.PrepareMap(directives.Split('+')[i]); } /* If is move directive */ if (ExtractInput.checkMove(directives.Split('+')[i])) { int move = ExtractInput.getMove(directives.Split('+')[i]); Araba.setMove(move); /* Debug point */ //Console.WriteLine(move); continue; } else /* If ısn't moving action. */ { /* Command shortcut */ int command = Harita.convert(directives.Split('+')[i]); /* Switch case skeleton */ switch (command) { case 1: /* Set brush up */ Araba.setCarBrush(true); continue; case 2: /* Set brush down */ Araba.setCarBrush(false); continue; case 3: /* Turn right */ Araba.setCarRotate(-1); continue; case 4: /* Turn left */ Araba.setCarRotate(1); continue; case 6: /* Jump */ Araba.setCarBrush(false); // Set brush up Araba.setMove(3); continue; case 7: /* Reverse route 180* degree. */ Araba.setCarRotate(-1); Araba.setCarRotate(-1); continue; case 8: /* Show map. */ Harita.ShowMap(); continue; case 0: /* Exit. */ break; } } /* Switch case skeleton */ } }