Advertisement
shekohex

Untitled

Jul 15th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using MySql;
  7. using MySql.Data.MySqlClient;
  8. using System.Threading.Tasks;
  9.  
  10. namespace Test
  11. {
  12.     class Program
  13.     {
  14.         public static  string fileLoc = @"npc.txt";
  15.         public static int counter = 0;
  16.         public static string line;
  17.         static void Main(string[] args)
  18.  
  19.         {
  20.             //String name;
  21.             #region start old
  22.             //Console.WriteLine("Can You Enter Your Name :");
  23.             //name = Console.ReadLine();
  24.             //  Console.WriteLine("Hallo  " + name);
  25.             //  System.IO.StreamWriter file = new System.IO.StreamWriter(fileLoc);
  26.             //  file.WriteLine(name);
  27.             //  file.Close();
  28.             #endregion
  29.             WorkConsole();
  30.             #region While Loop
  31.             //while (number < 2)
  32.             //{
  33.             //    Console.WriteLine(number);
  34.             //    number = number + 1;
  35.             //}
  36.             #endregion
  37.             #region Do Loop
  38.             //do
  39.             //{
  40.             //   Console.WriteLine(number);
  41.             //   number = number + 1;
  42.             //} while (number < 1000000);
  43.             #endregion
  44.             Console.ReadLine();
  45.         }
  46.         public static void CommandsAI(string command)
  47.         {
  48.             long number = 0;
  49.             int contcase = 1;
  50.             if (command == null)
  51.                 return;
  52.             string[] data = command.Split('/');
  53.             Console.WriteLine("What Do You Want? (enter /help for commands)");
  54.             string input = Console.ReadLine();
  55.             switch (input.ToLower())
  56.             {
  57.                 case "/help":
  58.                 case "/Help":
  59.                     Console.WriteLine("/cerate : for cerate new npc");
  60.                     Console.WriteLine("/delete : for delete npc :( ");
  61.                     Console.WriteLine("/update : for update npc data");
  62.                     Console.WriteLine("/cerate 2 : for cerate new npc dialog");
  63.                     Console.WriteLine("/save : to save your work");
  64.                     Console.WriteLine("/view : for view npcs in npc.txt");
  65.                     Console.WriteLine("/exit : to save your work and exit");
  66.                     break;
  67.                 case "/view":
  68.                     System.IO.StreamReader file2 = new System.IO.StreamReader(fileLoc);
  69.                     while ((line = file2.ReadLine()) != null)
  70.                     {
  71.                         Console.WriteLine(line);
  72.                         counter++;
  73.                     }
  74.                     file2.Close();
  75.                     break;
  76.                 case "/open":
  77.                     DBConnect.OpenConnection();
  78.                     break;
  79.                 case "/close":
  80.                     DBConnect.CloseConnection();
  81.                     break;
  82.                 case "/exit":
  83.                     Environment.Exit(0);
  84.                     break;
  85.                 case "/cerate":
  86.                     DBConnect.Insert();
  87.                     break;
  88.                 case "/save":
  89.                     Console.WriteLine("Please Wait For 5s !");
  90.                     Console.WriteLine("all things has been saved!");
  91.                     do
  92.                     {
  93.                       Console.WriteLine(number);
  94.                        number = number + 1;
  95.                     } while (number < 15);
  96.                     break;
  97.                 case "/cerate2" :
  98.                     Console.WriteLine("Now, We Will Make A NPC Dialog");
  99.                     Console.WriteLine("ok enter npc region name");
  100.                     string npc_region = Console.ReadLine();
  101.                     Console.WriteLine("ok now enter npc Case");
  102.                     int npc_case = int.Parse(Console.ReadLine());
  103.                     Console.WriteLine("ok now enter npc Dialog Text");
  104.                     string npc_dialogtxt = Console.ReadLine();
  105.                     Console.WriteLine("ok now enter npc Dialog Option case " + contcase+ "");
  106.                     string npc_optionc1 = Console.ReadLine();
  107.                     String New_NPC = "#region" + npc_region + "@" + "case" + npc_case + ":" +"@"+ "{";
  108.                     New_NPC = New_NPC.Replace("@", "@" + System.Environment.NewLine);
  109.                    // New_NPC = New_NPC.Remove("@");
  110.                             Console.WriteLine("ok NPC Has Been Done ! ");
  111.                               System.IO.StreamWriter file = new System.IO.StreamWriter(fileLoc);
  112.                               file.WriteLine(New_NPC);
  113.                               file.Close();
  114.                             break;
  115.                 default:
  116.                     Console.WriteLine("I'm sorry, I don't understand that!");
  117.                     break;
  118.             }
  119.         }
  120.         public static void WorkConsole()
  121.         {
  122.             while (true)
  123.             {
  124.                 try
  125.                 {
  126.                     DBConnect.Initialize();
  127.                     CommandsAI(Console.ReadLine());
  128.                 }
  129.                 catch (Exception e) { Console.WriteLine(e); }
  130.             }
  131.         }
  132.  
  133.        
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement