PhotoShaman

Doors OS v1.025

Jul 25th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 38.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7.  
  8.  
  9. namespace ConsoleApplication65
  10. {
  11.     class Program
  12.     {
  13.         private static int  x, y, timeStart, xBox, yBox, xPBox, yPBox, color,
  14.                             ballPosX, ballPosY, playerPos, botPos, playerpadSize,
  15.                             botpadSize, playerResult, botResult, botLvlHard, ballSlow;
  16.  
  17.         private static bool StartOpen, FolderOpen, DrawingOpen, Drawing, SaveOrLoadOpen, ExitOpen, SaveDrawing, PingPongOpen,
  18.                             ballDirectionUp, ballDirectionRight,
  19.                             Image1Save = false, Image2Save = false, Image3Save = false, Kitty = false, ToUpDate = true;
  20.  
  21.         private static int[,] image, AnimationSettins1, AnimationSettins2;
  22.         private static int[,] DrawingSaveMain = new int[18, 52];
  23.         private static int[,] DrawingSave1, DrawingSave2, DrawingSave3 = new int[18, 52];
  24.  
  25.         private static List<string> botsName;
  26.  
  27.         static Random randomGenerator = new Random();
  28.  
  29.         static void Main()
  30.         {
  31.             Settings();
  32.             LoadingDraw();
  33.             OperatingSystem();
  34.         }
  35.  
  36.         private static void Settings()
  37.         {
  38.             timeStart = TimeCheck();
  39.             StartOpen = false;
  40.             FolderOpen = false;
  41.             DrawingOpen = false;
  42.             PingPongOpen = false;
  43.             ExitOpen = false;
  44.             color = 1;
  45.  
  46.             Console.SetWindowSize(120, 30);
  47.             Console.BufferHeight = Console.WindowHeight;
  48.             Console.BufferWidth = Console.WindowWidth;
  49.             Console.Title = "Doors OS";
  50.  
  51.             x = 2;
  52.             y = Console.WindowHeight - 5;
  53.  
  54.             ResetDrawingSaveMain();
  55.         }
  56.  
  57.         private static void ResetDrawingSaveMain()
  58.         {
  59.             for (int i = 0; i <= 17; i++)
  60.             {
  61.                 for (int j = 0; j <= 50; j++)
  62.                 {
  63.                     DrawingSaveMain[i, j] = 15;
  64.                 }
  65.                 DrawingSaveMain[i, 51] = 0;
  66.             }
  67.         }
  68.  
  69.         private static int TimeCheck()
  70.         {
  71.             int timeReturn;
  72.             string curTimeShort = DateTime.Now.ToString("mm");
  73.             timeReturn = Convert.ToInt32(curTimeShort);
  74.             return timeReturn;
  75.         }
  76.  
  77.         private static void LoadingAnimationSettings()
  78.         {
  79.             AnimationSettins1 = new int[,]
  80.                 {
  81.                 {1,1,10,5,45,7,0},
  82.                 {0,2,10,5,65,7,0},
  83.                 {0,3,10,5,45,17,0},
  84.                 {0,4,10,5,65,17,200},
  85.                 {1,1,10,5,47,8,0},
  86.                 {0,2,10,5,63,8,0},
  87.                 {0,3,10,5,47,16,0},
  88.                 {0,4,10,5,63,16,300},
  89.                 {1,1,10,5,50,10,0},
  90.                 {0,2,10,5,60,10,0},
  91.                 {0,3,10,5,50,15,0},
  92.                 {0,4,10,5,60,15,300},
  93.                 {1,1,10,10,50,5,0},
  94.                 {0,2,10,10,60,5,0},
  95.                 {0,3,10,10,50,15,0},
  96.                 {0,4,10,10,60,15,300},
  97.                 {1,1,10,10,50,5,0},
  98.                 {0,2,10,10,60,5,0},
  99.                 {0,4,10,10,60,15,0},
  100.                 {0,3,15,15,50,10,200},
  101.                 {1,3,20,20,50,5,200},
  102.                 {0,5,2,1,65,15,0}
  103.                 };
  104.             AnimationSettins2 = new int[,]
  105.                 {
  106.                 {1,34,13,100},
  107.                 {2,46,13,100},
  108.                 {2,56,13,100},
  109.                 {3,66,13,100},
  110.                 {4,76,13,100},
  111.                 {2,88,13,100},
  112.                 {4,98,13,2000}
  113.                 };
  114.         }
  115.  
  116.         private static void LoadingDraw()
  117.         {
  118.             Console.CursorVisible = false;
  119.  
  120.             LoadingAnimationSettings();
  121.  
  122.             for (int p = 0; p <= 21; p++)
  123.             {
  124.                 if (AnimationSettins1[p, 0] == 1)
  125.                 {
  126.                     Console.ResetColor();
  127.                     Console.Clear();
  128.                 }
  129.                 if (AnimationSettins1[p, 1] == 1)
  130.                 {
  131.                     Console.BackgroundColor = ConsoleColor.Red;
  132.                 }
  133.                 if (AnimationSettins1[p, 1] == 2)
  134.                 {
  135.                     Console.BackgroundColor = ConsoleColor.Green;
  136.                 }
  137.                 if (AnimationSettins1[p, 1] == 3)
  138.                 {
  139.                     Console.BackgroundColor = ConsoleColor.Blue;
  140.                 }
  141.                 if (AnimationSettins1[p, 1] == 4)
  142.                 {
  143.                     Console.BackgroundColor = ConsoleColor.Yellow;
  144.                 }
  145.                 if (AnimationSettins1[p, 1] == 5)
  146.                 {
  147.                     Console.BackgroundColor = ConsoleColor.Black;
  148.                 }
  149.                 xBox = AnimationSettins1[p, 2];
  150.                 yBox = AnimationSettins1[p, 3];
  151.                 xPBox = AnimationSettins1[p, 4];
  152.                 yPBox = AnimationSettins1[p, 5];
  153.                 Box(xBox, yBox, xPBox, yPBox);
  154.                 Thread.Sleep(AnimationSettins1[p, 6]);
  155.             }
  156.  
  157.             for (int i = 1; i <= 40; i++)
  158.             {
  159.                 Console.ResetColor();
  160.                 Console.Clear();
  161.                 Console.BackgroundColor = ConsoleColor.Blue;
  162.                 Box(20, 20, (Console.WindowWidth / 2) - 10 - i, (Console.WindowHeight / 2) - 10);
  163.                 Console.BackgroundColor = ConsoleColor.Black;
  164.                 Box(2, 1, (Console.WindowWidth / 2) + 5 - i, Console.WindowHeight / 2);
  165.                 Thread.Sleep(10);
  166.             }
  167.  
  168.             for (int p = 0; p <= 6; p++)
  169.             {
  170.                 ChooseImage(AnimationSettins2[p, 0]);
  171.                 DrawImage(AnimationSettins2[p, 1], AnimationSettins2[p, 2]);
  172.                 Thread.Sleep(AnimationSettins2[p, 3]);
  173.             }
  174.  
  175.             Console.CursorVisible = true;
  176.  
  177.         }
  178.  
  179.         private static void Box(int Width, int Height, int XPos, int YPos)
  180.         {
  181.             for (int i = 0; i < Height; i++)
  182.             {
  183.                 Console.SetCursorPosition(XPos, YPos);
  184.                 Console.Write(" ".PadRight(Width));
  185.                 YPos++;
  186.             }
  187.         }
  188.  
  189.         private static void DrawImage(int m, int n)
  190.         {
  191.             Console.ResetColor();
  192.  
  193.             Console.SetCursorPosition(m, n);
  194.  
  195.             for (int i = 0; i < image.GetLength(0); i++)
  196.             {
  197.                 for (int j = 0; j < image.GetLength(1); j++)
  198.                 {
  199.                     if (image[i, j] == 0)
  200.                     {
  201.                         n++;
  202.                         Console.SetCursorPosition(m, n);
  203.                     }
  204.                     else if (image[i, j] > 0)
  205.                     {
  206.                         ChooseColor(image[i, j]);
  207.                         Console.Write("  ");
  208.                     }
  209.                 }
  210.             }
  211.             Console.SetCursorPosition(0, 0);
  212.         }
  213.  
  214.         private static void ChooseColor(int number)
  215.         {
  216.             //Знаю, что не хорошо так записывать if'ы, но так красивее и выходит меньше строчек..
  217.             if (number == 1)  Console.BackgroundColor = ConsoleColor.Black;
  218.             if (number == 2)  Console.BackgroundColor = ConsoleColor.Blue;
  219.             if (number == 3)  Console.BackgroundColor = ConsoleColor.Cyan;
  220.             if (number == 4)  Console.BackgroundColor = ConsoleColor.DarkBlue;
  221.             if (number == 5)  Console.BackgroundColor = ConsoleColor.DarkCyan;
  222.             if (number == 6)  Console.BackgroundColor = ConsoleColor.DarkGray;
  223.             if (number == 7)  Console.BackgroundColor = ConsoleColor.DarkGreen;
  224.             if (number == 8)  Console.BackgroundColor = ConsoleColor.DarkMagenta;
  225.             if (number == 9)  Console.BackgroundColor = ConsoleColor.DarkRed;
  226.             if (number == 10) Console.BackgroundColor = ConsoleColor.DarkYellow;
  227.             if (number == 11) Console.BackgroundColor = ConsoleColor.Gray;
  228.             if (number == 12) Console.BackgroundColor = ConsoleColor.Green;
  229.             if (number == 13) Console.BackgroundColor = ConsoleColor.Magenta;
  230.             if (number == 14) Console.BackgroundColor = ConsoleColor.Red;
  231.             if (number == 15) Console.BackgroundColor = ConsoleColor.White;
  232.             if (number == 16) Console.BackgroundColor = ConsoleColor.Yellow;
  233.         }
  234.  
  235.         private static void ChooseImage(int i)
  236.         {
  237.             if (i == 0)
  238.             {
  239.                 if (Kitty)
  240.                 {
  241.                     image = new int[,] //Kitty
  242.                     {
  243.                 {2 ,1 ,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,1 ,1 ,2 ,2 ,0},
  244.                 {2 ,1 ,11,1 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,1 ,11,11,1 ,2 ,0},
  245.                 {2 ,1 ,11,11,1 ,2 ,2 ,2 ,2 ,2 ,1 ,11,11,11,1 ,2 ,0},
  246.                 {2 ,1 ,11,11,11,1 ,1 ,1 ,1 ,1 ,11,11,11,11,1 ,2 ,0},
  247.                 {1 ,11,11,11,11,11,11,11,11,11,11,11,11,11,1 ,2 ,0},
  248.                 {1 ,11,11,11,11,11,11,11,11,11,11,11,11,11,1 ,2 ,0},
  249.                 {1 ,11,11,11,11,11,11,11,11,11,11,11,11,11,11,1 ,0},
  250.                 {1 ,11,11,11,15,1 ,11,11,11,11,11,15,1 ,11,11,1 ,0},
  251.                 {1 ,11,11,11,1 ,1 ,11,11,11,1 ,11,1 ,1 ,11,11,1 ,0},
  252.                 {1 ,11,9 ,9 ,11,11,11,11,11,11,11,11,11,9 ,9 ,1 ,0},
  253.                 {1 ,11,9 ,9 ,11,1 ,11,11,1 ,11,11,1 ,11,9 ,9 ,1 ,0},
  254.                 {2 ,1 ,11,11,11,11,1 ,1 ,11,1 ,1 ,11,11,11,1 ,2 ,0},
  255.                 {2 ,2 ,1 ,11,11,11,11,11,11,11,11,11,11,1 ,2 ,2 ,0},
  256.                 {2 ,2 ,2 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,2 ,2 ,2 ,0}
  257.                     };
  258.                 }
  259.                 else
  260.                 {
  261.                     image = new int[,] //Mario
  262.             {
  263.                 {2 ,2 ,2 ,14,14,14,14,14,2 ,2 ,2 ,2 ,0},
  264.                 {2 ,2 ,14,14,14,14,14,14,14,14,14,2 ,0},
  265.                 {2 ,2 ,9 ,9 ,9 ,15,15,1 ,15,2 ,2 ,2 ,0},
  266.                 {2 ,9 ,15,9 ,15,15,15,1 ,15,15,15,2 ,0},
  267.                 {2 ,9 ,15,9 ,9 ,15,15,15,9 ,15,15,15,0},
  268.                 {2 ,9 ,9 ,15,15,15,15,9 ,9 ,9 ,9 ,2 ,0},
  269.                 {2 ,2 ,2 ,15,15,15,15,15,15,15,2 ,2 ,0},
  270.                 {2 ,2 ,14,14,4 ,14,14,14,2 ,2 ,2 ,2 ,0},
  271.                 {2 ,14,14,14,4 ,14,14,4 ,14,14,14,2 ,0},
  272.                 {14,14,14,14,4 ,4 ,4 ,4 ,14,14,14,14,0},
  273.                 {15,15,14,4 ,16,4 ,4 ,16,4 ,14,15,15,0},
  274.                 {15,15,15,4 ,4 ,4 ,4 ,4 ,4 ,15,15,15,0},
  275.                 {15,15,4 ,4 ,4 ,4 ,4 ,4 ,4 ,4 ,15,15,0},
  276.                 {2 ,2 ,4 ,4 ,4 ,2 ,2 ,4 ,4 ,4 ,2 ,2 ,0},
  277.                 {2 ,9 ,9 ,9 ,2 ,2 ,2 ,2 ,9 ,9 ,9 ,2 ,0},
  278.                 {9 ,9 ,9 ,9 ,2 ,2 ,2 ,2 ,9 ,9 ,9 ,9 ,0}
  279.             };
  280.                 }
  281.             }
  282.             if (i == 1)
  283.             {
  284.                 image = new int[,]
  285.                 {
  286.                 {15,15,15,15,1 ,0},
  287.                 {15,1 ,1 ,1 ,15,0},
  288.                 {15,1 ,1 ,1 ,15,0},
  289.                 {15,1 ,1 ,1 ,15,0},
  290.                 {15,15,15,15,1 ,0},
  291.                 };
  292.             }
  293.             if (i == 2)
  294.             {
  295.                 image = new int[,]
  296.                 {
  297.                 {15,15,15,15,0},
  298.                 {15,1 ,1 ,15,0},
  299.                 {15,1 ,1 ,15,0},
  300.                 {15,1 ,1 ,15,0},
  301.                 {15,15,15,15,0},
  302.                 };
  303.             }
  304.             if (i == 3)
  305.             {
  306.                 image = new int[,]
  307.                 {
  308.                 {15,15,15,15,0},
  309.                 {15,1 ,1 ,15,0},
  310.                 {15,15,15,15,0},
  311.                 {15,1 ,15,1 ,0},
  312.                 {15,1 ,15,1 ,0},
  313.                 };
  314.             }
  315.             if (i == 4)
  316.             {
  317.                 image = new int[,]
  318.                 {
  319.                 {15,15,15,0},
  320.                 {15,1 ,1 ,0},
  321.                 {15,15,15,0},
  322.                 {1 ,1 ,15,0},
  323.                 {15,15,15,0},
  324.                 };
  325.             }
  326.             if (i == 5)
  327.             {
  328.                 image = new int[,]
  329.                 {
  330.                 {1 ,0},
  331.                 {2 ,0},
  332.                 {3 ,0},
  333.                 {4 ,0},
  334.                 {5 ,0},
  335.                 {6 ,0},
  336.                 {7 ,0},
  337.                 {8 ,0},
  338.                 {9 ,0},
  339.                 {10,0},
  340.                 {11,0},
  341.                 {12,0},
  342.                 {13,0},
  343.                 {14,0},
  344.                 {15,0},
  345.                 {16,0}
  346.                 };
  347.             }
  348.             if (i == 6)
  349.             {
  350.                 image = DrawingSaveMain;
  351.             }
  352.         }
  353.  
  354.         private static void MoveCursor()
  355.         {
  356.             Update();
  357.  
  358.             Console.SetCursorPosition(x, y);
  359.  
  360.             ConsoleKey k = Console.ReadKey(true).Key;
  361.  
  362.             if (k == ConsoleKey.D || k == ConsoleKey.RightArrow)
  363.             {
  364.                 x += 2;
  365.                 if (x > Console.WindowWidth - 3)
  366.                 {
  367.                     x = 2;
  368.                 }
  369.             }
  370.             if (k == ConsoleKey.A || k == ConsoleKey.LeftArrow)
  371.             {
  372.                 x -= 2;
  373.                 if (x < 1)
  374.                 {
  375.                     x = Console.WindowWidth - 4;
  376.                 }
  377.             }
  378.             if (k == ConsoleKey.W || k == ConsoleKey.UpArrow)
  379.             {
  380.                 y -= 1;
  381.                 if (y < 1)
  382.                 {
  383.                     y = Console.WindowHeight - 2;
  384.                 }
  385.             }
  386.             if (k == ConsoleKey.S || k == ConsoleKey.DownArrow)
  387.             {
  388.                 y += 1;
  389.                 if (y > Console.WindowHeight - 2)
  390.                 {
  391.                     y = 1;
  392.                 }
  393.             }
  394.             if (k == ConsoleKey.Enter || k == ConsoleKey.Spacebar)
  395.             {
  396.                 Bottoms();
  397.             }
  398.         }
  399.  
  400.         private static void Time()
  401.         {
  402.             Console.BackgroundColor = ConsoleColor.Green;
  403.             Console.ForegroundColor = ConsoleColor.Black;
  404.             Console.SetCursorPosition(Console.WindowWidth - 28, Console.WindowHeight - 3);
  405.             Console.Write(DateTime.Now.ToString("dd MMMM yyyy | HH:mm:ss"));
  406.             Console.ResetColor();
  407.         }
  408.  
  409.         private static void Bottoms()
  410.         {
  411.             if (x <= 10 && y >= Console.WindowHeight - 4 && !StartOpen)
  412.             {
  413.                 StartOpen = true;
  414.                 StartDraw();
  415.             }
  416.             else if (x <= 10 && y >= Console.WindowHeight - 4 && StartOpen)
  417.             {
  418.                 StartOpen = false;
  419.                 OperatingSystem();
  420.             }
  421.             else if (x <= 26 && (y > Console.WindowHeight - 27) && (y < Console.WindowHeight - 23) && StartOpen)
  422.             {
  423.                 FolderOpen = true;
  424.                 DrawingOpen = false;
  425.                 StartOpen = false;
  426.                 PingPongOpen = false;
  427.                 OperatingSystem();
  428.             }
  429.             else if (x <= 26 && (y > Console.WindowHeight - 23) && (y < Console.WindowHeight - 19) && StartOpen)
  430.             {
  431.                 DrawingOpen = true;
  432.                 Drawing = true;
  433.                 PingPongOpen = false;
  434.                 StartOpen = false;
  435.                 OperatingSystem();
  436.             }
  437.             else if (x == 6 && y >= 7 && y <= 22 && DrawingOpen)
  438.             {
  439.                 for (int i = 7; i <= 22; i++)
  440.                 {
  441.                     if (y == i)
  442.                     {
  443.                         color = i - 6;
  444.                     }
  445.                 }
  446.             }
  447.             else if (x >= 64 && x <= 72 && y == 6 && SaveOrLoadOpen)
  448.             {
  449.                 Drawing = true;
  450.                 SaveOrLoadOpen = false;
  451.                 OperatingSystem();
  452.             }
  453.             else if (x >= 64 && x <= 76 && (y == 8 || y == 10 || y == 12) && SaveOrLoadOpen)
  454.             {
  455.                 if (SaveDrawing)
  456.                 {
  457.                     if (y == 8)
  458.                     {
  459.                         Image1Save = true;
  460.                         Array.Copy(DrawingSaveMain, DrawingSave1 = new int[18, 52], DrawingSaveMain.Length);
  461.                     }
  462.                     if (y == 10)
  463.                     {
  464.                         Image2Save = true;
  465.                         Array.Copy(DrawingSaveMain, DrawingSave2 = new int[18, 52], DrawingSaveMain.Length);
  466.                     }
  467.                     if (y == 12)
  468.                     {
  469.                         Image3Save = true;
  470.                         Array.Copy(DrawingSaveMain, DrawingSave3 = new int[18, 52], DrawingSaveMain.Length);
  471.                     }
  472.                 }
  473.                 else
  474.                 {
  475.                     if (y == 8)
  476.                         if (Image1Save)
  477.                             Array.Copy(DrawingSave1, DrawingSaveMain = new int[18, 52], DrawingSave1.Length);
  478.                     if (y == 10)
  479.                         if (Image2Save)
  480.                             Array.Copy(DrawingSave2, DrawingSaveMain = new int[18, 52], DrawingSave1.Length);
  481.                     if (y == 12)
  482.                         if (Image3Save)
  483.                             Array.Copy(DrawingSave3, DrawingSaveMain = new int[18, 52], DrawingSave1.Length);
  484.                 }
  485.                 Drawing = true;
  486.                 SaveOrLoadOpen = false;
  487.                 OperatingSystem();
  488.             }
  489.             else if (x >= 12 && x <= 30 && y == 4 && DrawingOpen && Drawing)
  490.             {
  491.                 ResetDrawingSaveMain();
  492.                 OperatingSystem();
  493.             }
  494.             else if (x >= 12 && x <= 112 && y >= 6 && y <= 23 && DrawingOpen && Drawing)
  495.             {
  496.                 DrawingSaveMain[y - 6, (x - 12) / 2] = color;
  497.                 ChooseColor(color);
  498.                 Console.Write("  ");
  499.             }
  500.             else if (x >= 40 && x <= 80 && y == 4 && DrawingOpen)
  501.             {
  502.                 SaveOrLoadOpen = true;
  503.                 if (x >= 40 && x <= 53)
  504.                 {
  505.                     Drawing = false;
  506.                     SaveDrawing = true;
  507.                     SaveOrLoadDrawingDraw();
  508.                 }
  509.                 else if (x >= 66 && x <= 78)
  510.                 {
  511.                     Drawing = false;
  512.                     SaveDrawing = false;
  513.                     SaveOrLoadDrawingDraw();
  514.                 }
  515.             }
  516.             else if (x <= 26 && (y > Console.WindowHeight - 19) && (y < Console.WindowHeight - 15) && StartOpen)
  517.             {
  518.                 PingPongOpen = true;
  519.                 DrawingOpen = false;
  520.                 FolderOpen = false;
  521.                 StartOpen = false;
  522.                 OperatingSystem();
  523.             }
  524.             else if (x >= 50 && x <= 70 && y >= 9 && y <= 18 && PingPongOpen && !ExitOpen)
  525.             {
  526.                 botLvlHard = (y - 8) * 10;
  527.                 if (y == 9)  ballSlow = 75;
  528.                 if (y == 10) ballSlow = 70;
  529.                 if (y == 11) ballSlow = 65;
  530.                 if (y == 12) ballSlow = 60;
  531.                 if (y == 13) ballSlow = 55;
  532.                 if (y == 14) ballSlow = 50;
  533.                 if (y == 15) ballSlow = 45;
  534.                 if (y == 16) ballSlow = 40;
  535.                 if (y == 17) ballSlow = 35;
  536.                 if (y == 18) ballSlow = 30;
  537.  
  538.                 string botName = botsName[y - 9];
  539.  
  540.                 Console.BackgroundColor = ConsoleColor.White;
  541.                 Console.ForegroundColor = ConsoleColor.Black;
  542.  
  543.                 Console.SetCursorPosition(66, 4);
  544.                 Console.Write(botName);
  545.  
  546.                 PingPong();
  547.             }
  548.             else if (x >= Console.WindowWidth - 18 && x <= Console.WindowWidth - 6 && y == Console.WindowHeight - 28 && PingPongOpen)
  549.             {
  550.                 PingPongOpen = false;
  551.                 OperatingSystem();
  552.             }
  553.             else if (x <= 26 && (y > Console.WindowHeight - 8) && (y < Console.WindowHeight - 4) && StartOpen)
  554.             {
  555.                 ExitOpen = true;
  556.                 StartOpen = false;
  557.                 OperatingSystem();
  558.             }
  559.             else if (x >= Console.WindowWidth - 18 && x <= Console.WindowWidth - 6 && y == Console.WindowHeight - 28 && FolderOpen)
  560.             {
  561.                 FolderOpen = false;
  562.                 OperatingSystem();
  563.             }
  564.             else if (x >= Console.WindowWidth - 18 && x <= Console.WindowWidth - 6 && y == 2 && DrawingOpen)
  565.             {
  566.                 SaveOrLoadOpen = false;
  567.                 DrawingOpen = false;
  568.                 OperatingSystem();
  569.             }
  570.             else if (x >= Console.WindowWidth - 74 && x <= Console.WindowWidth - 66 && y >= 16 && y <= Console.WindowHeight - 12 && ExitOpen)
  571.             {
  572.                 ExitOpen = false;
  573.                 OperatingSystem();
  574.             }
  575.             else if (x >= Console.WindowWidth - 56 && x <= Console.WindowWidth - 48 && y >= 16 && y <= Console.WindowHeight - 12 && ExitOpen)
  576.             {
  577.                 System.Environment.Exit(1);
  578.             }
  579.         }
  580.  
  581.         private static void UIDraw()
  582.         {
  583.             Console.BackgroundColor = ConsoleColor.Blue;
  584.             Box(Console.WindowWidth - 4, Console.WindowHeight - 5, 2, 1);
  585.  
  586.             Console.BackgroundColor = ConsoleColor.DarkCyan;
  587.             Box(Console.WindowWidth - 43, 3, 11, (Console.WindowHeight - 4));
  588.  
  589.             for (int i = 1; i <= 3; i++)
  590.             {
  591.                 Console.SetCursorPosition(12, Console.WindowHeight - i - 1);
  592.                 Console.Write("║");
  593.             }
  594.  
  595.             Console.BackgroundColor = ConsoleColor.Green;
  596.             Box(9, 3, 2, (Console.WindowHeight - 4));
  597.  
  598.             Box(30, 3, (Console.WindowWidth - 32), (Console.WindowHeight - 4));
  599.  
  600.             Console.ForegroundColor = ConsoleColor.Black;
  601.             Console.SetCursorPosition(4, Console.WindowHeight - 3);
  602.             Console.Write("Старт");
  603.  
  604.             if (!FolderOpen && !DrawingOpen && !ExitOpen && !PingPongOpen)
  605.             {
  606.                 ChooseImage(0);
  607.  
  608.                 DrawImage((Console.WindowWidth / 2 - 16), (Console.WindowHeight - 18) / 2);
  609.             }
  610.  
  611.             if (StartOpen)
  612.             {
  613.                 StartDraw();
  614.             }
  615.             if (FolderOpen)
  616.             {
  617.                 FolderDraw();
  618.             }
  619.             if (DrawingOpen)
  620.             {
  621.                 DrawingDraw();
  622.             }
  623.             if (PingPongOpen)
  624.             {
  625.                 PingPongDraw();
  626.             }
  627.             if (ExitOpen)
  628.             {
  629.                 ExitDraw();
  630.             }
  631.             Console.BackgroundColor = ConsoleColor.Black;
  632.         }
  633.  
  634.         private static void StartDraw()
  635.         {
  636.             Console.BackgroundColor = ConsoleColor.Black;
  637.             Box(26, 1, 2, Console.WindowHeight - 23);
  638.  
  639.             Console.ForegroundColor = ConsoleColor.White;
  640.             Console.SetCursorPosition(2, Console.WindowHeight - 28);
  641.             Console.Write("USER PC           DOORS OS");
  642.  
  643.             Console.BackgroundColor = ConsoleColor.White;
  644.             Box(26, Console.WindowHeight - 10, 2, Console.WindowHeight - 27);
  645.  
  646.             Console.BackgroundColor = ConsoleColor.Red;
  647.             Box(26, 3, 2, Console.WindowHeight - 7);
  648.  
  649.             Console.ForegroundColor = ConsoleColor.Black;
  650.             Console.SetCursorPosition(6, Console.WindowHeight - 6);
  651.             Console.Write("Завершение работы");
  652.  
  653.             Console.BackgroundColor = ConsoleColor.Yellow;
  654.             Box(26, 3, 2, Console.WindowHeight - 26);
  655.  
  656.             Console.ForegroundColor = ConsoleColor.Black;
  657.             Console.SetCursorPosition(6, Console.WindowHeight - 25);
  658.             Console.Write("Папка с файлами");
  659.  
  660.             Console.BackgroundColor = ConsoleColor.Cyan;
  661.             Box(26, 3, 2, Console.WindowHeight - 22);
  662.  
  663.             Console.ForegroundColor = ConsoleColor.Black;
  664.             Console.SetCursorPosition(6, Console.WindowHeight - 21);
  665.             Console.Write("Рисовалка");
  666.  
  667.             Console.BackgroundColor = ConsoleColor.Green;
  668.             Box(26, 3, 2, 12);
  669.  
  670.             Console.ForegroundColor = ConsoleColor.Black;
  671.             Console.SetCursorPosition(6, 13);
  672.             Console.Write("Пинг-Понг");
  673.         }
  674.  
  675.         private static void ExitDraw()
  676.         {
  677.             Console.BackgroundColor = ConsoleColor.Black;
  678.             Box(32, 3, (Console.WindowWidth - 32) / 2, (Console.WindowHeight - 10) / 2);
  679.  
  680.             Console.ForegroundColor = ConsoleColor.White;
  681.             Console.SetCursorPosition((Console.WindowWidth - 20) / 2, (Console.WindowHeight - 8) / 2);
  682.             Console.Write("Выключить Doors OS?");
  683.  
  684.             Console.BackgroundColor = ConsoleColor.Cyan;
  685.             Box(32, 7, (Console.WindowWidth - 32) / 2, Console.WindowHeight - 17);
  686.  
  687.             Console.BackgroundColor = ConsoleColor.Red;
  688.             Box(10, 3, Console.WindowWidth - 74, Console.WindowHeight - 14);
  689.  
  690.             Console.ForegroundColor = ConsoleColor.Black;
  691.             Console.SetCursorPosition(Console.WindowWidth - 71, Console.WindowHeight - 13);
  692.             Console.Write("Нет");
  693.  
  694.             Console.BackgroundColor = ConsoleColor.Green;
  695.             Box(10, 3, Console.WindowWidth - 56, Console.WindowHeight - 14);
  696.  
  697.             Console.SetCursorPosition(Console.WindowWidth - 52, Console.WindowHeight - 13);
  698.             Console.Write("Да");
  699.         }
  700.  
  701.         private static void FolderDraw()
  702.         {
  703.             Console.BackgroundColor = ConsoleColor.Black;
  704.             Box(Console.WindowWidth - 8, 1, 4, Console.WindowHeight - 28);
  705.  
  706.             Console.ForegroundColor = ConsoleColor.White;
  707.             Console.SetCursorPosition(4, Console.WindowHeight - 28);
  708.             Console.Write("Папка с файлами");
  709.  
  710.             Console.BackgroundColor = ConsoleColor.Red;
  711.             Box(14, 1, Console.WindowWidth - 18, Console.WindowHeight - 28);
  712.  
  713.             Console.ForegroundColor = ConsoleColor.Black;
  714.             Console.SetCursorPosition(Console.WindowWidth - 16, Console.WindowHeight - 28);
  715.             Console.Write("Закрыть[X]");
  716.  
  717.             Console.BackgroundColor = ConsoleColor.White;
  718.             Box(Console.WindowWidth - 8, Console.WindowHeight - 8, 4, Console.WindowHeight - 27);
  719.  
  720.             Console.ForegroundColor = ConsoleColor.Black;
  721.             Console.SetCursorPosition(8, Console.WindowHeight - 26);
  722.             Console.Write("Файлов и функционала пока нет, но Вы там держитесь!");
  723.         }
  724.  
  725.         private static void DrawingDraw()
  726.         {
  727.             Console.BackgroundColor = ConsoleColor.Black;
  728.             Console.ForegroundColor = ConsoleColor.Gray;
  729.             Console.SetCursorPosition(4, 2);
  730.             Console.Write("Рисовалка".PadRight(98));
  731.  
  732.             Console.BackgroundColor = ConsoleColor.Red;
  733.             Console.ForegroundColor = ConsoleColor.Black;
  734.             Console.SetCursorPosition(102, 2);
  735.             Console.Write("  Закрыть[X]  ");
  736.  
  737.             Console.BackgroundColor = ConsoleColor.Gray;
  738.             Box(112, 22, 4, 3);
  739.  
  740.             Console.SetCursorPosition(5, 4);
  741.             Console.Write("Цвет:");
  742.  
  743.             Console.SetCursorPosition(5, 6);
  744.             Console.Write("╔══╗");
  745.  
  746.             for (int i = 1; i <= 16; i++)
  747.             {
  748.                 Console.SetCursorPosition(5, 6 + i);
  749.                 Console.Write("║  ║");
  750.             }
  751.  
  752.             Console.SetCursorPosition(5, 23);
  753.             Console.Write("╚══╝");
  754.  
  755.             Console.BackgroundColor = ConsoleColor.Black;
  756.             Console.ForegroundColor = ConsoleColor.White;
  757.  
  758.             Console.SetCursorPosition(12, 4);
  759.             Console.Write("  Очистить полотно  ");
  760.  
  761.             Console.SetCursorPosition(40, 4);
  762.             Console.Write("  Сохранить   ");
  763.  
  764.             Console.SetCursorPosition(66, 4);
  765.             Console.Write("  Загрузить   ");
  766.  
  767.             ChooseImage(5);
  768.             DrawImage(6, 7);
  769.  
  770.             ChooseImage(6);
  771.             DrawImage(12, 6);
  772.  
  773.             if (SaveOrLoadOpen)
  774.             {
  775.                 SaveOrLoadDrawingDraw();
  776.             }
  777.         }
  778.  
  779.         private static void SaveOrLoadDrawingDraw()
  780.         {
  781.             Console.BackgroundColor = ConsoleColor.DarkCyan;
  782.             Box(40, 9, 40, 5);
  783.             string chooseText;
  784.  
  785.             string chooseCell;
  786.             string SaveOrLoad;
  787.  
  788.             if (SaveDrawing)
  789.             {
  790.                 chooseText = "ячейки  ";
  791.                 chooseCell = "ячейка  ";
  792.                 SaveOrLoad = "  Сохранить   ";
  793.             }
  794.             else
  795.             {
  796.                 chooseText = "картинки  ";
  797.                 chooseCell = "картинка  ";
  798.                 SaveOrLoad = "  Загрузить   ";
  799.             }
  800.  
  801.             Console.ForegroundColor = ConsoleColor.White;
  802.             Console.SetCursorPosition(42, 6);
  803.             Console.Write("Выбор {0}", chooseText);
  804.  
  805.             Console.BackgroundColor = ConsoleColor.White;
  806.             Console.ForegroundColor = ConsoleColor.Black;
  807.  
  808.             for (int i = 1; i <= 3; i++)
  809.             {
  810.                 Console.SetCursorPosition(42, 6 + i * 2);
  811.                 Console.Write("{0} {1}", i, chooseCell);
  812.  
  813.                 Console.SetCursorPosition(64, 6 + i * 2);
  814.                 Console.Write(SaveOrLoad);
  815.             }
  816.             Console.SetCursorPosition(64, 6);
  817.             Console.Write("  Отмена  ");
  818.         }
  819.  
  820.         private static void UpdateDraw()
  821.         {
  822.             Console.CursorVisible = false;
  823.  
  824.             Console.BackgroundColor = ConsoleColor.Blue;
  825.             Box(Console.WindowWidth - 4, Console.WindowHeight - 2, 2, 1);
  826.  
  827.             Console.ForegroundColor = ConsoleColor.White;
  828.             string UpdateDoorsOS = "Обновление Doors OS";
  829.             string EverythingIsFine = "Все нормально. Это может занять некоторое время.";
  830.  
  831.             Console.SetCursorPosition((Console.WindowWidth - UpdateDoorsOS.Length) / 2, (Console.WindowHeight / 2) - 10);
  832.             Console.WriteLine(UpdateDoorsOS);
  833.  
  834.             Console.SetCursorPosition((Console.WindowWidth - EverythingIsFine.Length) / 2, (Console.WindowHeight / 2) - 8);
  835.             Console.WriteLine(EverythingIsFine);
  836.  
  837.             int ProgressPersents = 0;
  838.  
  839.             while (ProgressPersents < 100)
  840.             {
  841.                 Random r = new Random();
  842.                 int ProgressPlus = r.Next(0, 6);
  843.  
  844.                 if (ProgressPersents > 95)
  845.                 {
  846.                     ProgressPlus = 100 - ProgressPersents;
  847.                 }
  848.  
  849.                 ProgressPersents += ProgressPlus;
  850.  
  851.                 string Progress = "Выполнено: " + ProgressPersents + " % ";
  852.  
  853.                 Console.SetCursorPosition((Console.WindowWidth - Progress.Length) / 2, (Console.WindowHeight / 2) - 4);
  854.                 Console.WriteLine(Progress);
  855.  
  856.                 Thread.Sleep(400);
  857.                 Console.CursorVisible = true;
  858.             }
  859.         }
  860.  
  861.         private static void Update()
  862.         {
  863.             if ((timeStart + 2) <= TimeCheck() && ToUpDate)
  864.             {
  865.                 Kitty = true;
  866.                 ToUpDate = false;
  867.                 UpdateDraw();
  868.                 Main();
  869.             }
  870.         }
  871.  
  872.         private static void OperatingSystem()
  873.         {
  874.             UIDraw();
  875.             while (true)
  876.             {
  877.                 Time();
  878.                 MoveCursor();
  879.                 Update();
  880.             }
  881.         }
  882.  
  883.         private static void PingPongDraw()
  884.         {
  885.             Console.BackgroundColor = ConsoleColor.Black;
  886.             Console.ForegroundColor = ConsoleColor.Gray;
  887.             Console.SetCursorPosition(4, 2);
  888.             Console.Write("Пинг-Понг".PadRight(98));
  889.  
  890.             Console.BackgroundColor = ConsoleColor.Red;
  891.             Console.ForegroundColor = ConsoleColor.Black;
  892.             Console.SetCursorPosition(102, 2);
  893.             Console.Write("  Закрыть[X]  ");
  894.  
  895.             Console.BackgroundColor = ConsoleColor.White;
  896.             Box(112, 22, 4, 3);
  897.  
  898.             Console.BackgroundColor = ConsoleColor.Black;
  899.             Box(4, 2, 6, 4);
  900.             Box(4, 2, 6, 22);
  901.             Box(4, 2, 110, 4);
  902.             Box(4, 2, 110, 22);
  903.  
  904.             Console.BackgroundColor = ConsoleColor.Green;
  905.             Box(104, 18, 8, 5);
  906.  
  907.             ChooseBot();
  908.         }
  909.  
  910.         private static void PingPong()
  911.         {
  912.             PingPongSettings();
  913.  
  914.             Console.CursorVisible = false;
  915.  
  916.             while (true)
  917.             {
  918.                 Time();
  919.                 PlayerMove();
  920.  
  921.                 BotMove();
  922.                 MoveBall();
  923.                 Console.BackgroundColor = ConsoleColor.Green;
  924.                 Console.ForegroundColor = ConsoleColor.Black;
  925.                 Box(104, 18, 8, 5);
  926.                 DrawPlayer();
  927.                 DrawBot();
  928.  
  929.                 Console.SetCursorPosition(ballPosX, ballPosY);
  930.                 Console.Write("  ");
  931.  
  932.                 PrintResult();
  933.                 Thread.Sleep(ballSlow);
  934.             }
  935.         }
  936.  
  937.         private static void ChooseBot()
  938.         {
  939.             botsName = new List<string>()
  940.             {"Неудачник", "Новичок", "Середнячок", "Опытный", "Тот чел с района",
  941.              "Городская легенда", "Чемпион Гондураса", "Жека Чан", "Мастер унижения", "Борис Лихач"};
  942.            
  943.             Console.BackgroundColor = ConsoleColor.Black;
  944.             Console.ForegroundColor = ConsoleColor.White;
  945.  
  946.             Console.SetCursorPosition(50,6);
  947.             Console.Write("Выберите противника:  ");
  948.  
  949.             int i = 0;
  950.             foreach (string s in botsName)
  951.             {
  952.                 Console.SetCursorPosition(50, 9 + i);
  953.                 Console.Write("{0}. {1}".PadRight(27 - s.Length), i, s);
  954.                 i++;
  955.             }
  956.         }
  957.  
  958.         private static void PingPongSettings()
  959.         {
  960.             ResetBall();
  961.  
  962.             playerPos = Console.WindowHeight / 2 - playerpadSize / 2;
  963.             botPos = Console.WindowHeight / 2 - botpadSize / 2;
  964.  
  965.             playerpadSize = 5;
  966.             botpadSize = 5;
  967.  
  968.             playerResult = 0;
  969.             botResult = 0;
  970.  
  971.             ballDirectionUp = true;
  972.             ballDirectionRight = true;
  973.  
  974.             Console.ForegroundColor = ConsoleColor.Black;
  975.             Console.BackgroundColor = ConsoleColor.White;
  976.  
  977.             Console.SetCursorPosition(50, 4);
  978.             Console.Write("Вы");
  979.  
  980.             Console.SetCursorPosition(30, 23);
  981.             Console.Write("Нажмите Esc, чтобы закончить раунд и выбрать другого соперника");
  982.         }
  983.  
  984.         private static void ResetBall()
  985.         {
  986.             ballPosX = Console.WindowWidth / 2;
  987.             ballPosY = Console.WindowHeight / 2;
  988.         }
  989.  
  990.         static void DrawPlayer()
  991.         {
  992.             Console.BackgroundColor = ConsoleColor.Black;
  993.  
  994.             Box(2, playerpadSize, 8, playerPos);
  995.         }
  996.  
  997.         private static void DrawBot()
  998.         {
  999.             Box(2, playerpadSize, 110, botPos);
  1000.         }
  1001.  
  1002.         private static void PrintResult()
  1003.         {
  1004.             Console.BackgroundColor = ConsoleColor.White;
  1005.             Console.SetCursorPosition(Console.WindowWidth / 2 - 3, 4);
  1006.             Console.WriteLine("{0} - {1}", playerResult, botResult);
  1007.             Console.ResetColor();
  1008.         }
  1009.  
  1010.         private static void MovePlayerUp()
  1011.         {
  1012.             if (playerPos > 5)
  1013.             {
  1014.                 playerPos--;
  1015.             }
  1016.         }
  1017.  
  1018.         private static void MovePlayerDown()
  1019.         {
  1020.             if (playerPos < 23 - playerpadSize)
  1021.             {
  1022.                 playerPos++;
  1023.             }
  1024.         }
  1025.  
  1026.         private static void MoveBotUp()
  1027.         {
  1028.             if (botPos > 5)
  1029.             {
  1030.                 botPos--;
  1031.             }
  1032.         }
  1033.  
  1034.         private static void MoveBotDown()
  1035.         {
  1036.             if (botPos < 23 - botpadSize)
  1037.             {
  1038.                 botPos++;
  1039.             }
  1040.         }
  1041.  
  1042.         private static void PlayerMove()
  1043.         {
  1044.             if (Console.KeyAvailable)
  1045.             {
  1046.                 Console.BackgroundColor = ConsoleColor.Green;
  1047.                 Console.ForegroundColor = ConsoleColor.Green;
  1048.  
  1049.                 ConsoleKeyInfo keyInfo = Console.ReadKey();
  1050.  
  1051.                 if (keyInfo.Key == ConsoleKey.UpArrow || keyInfo.Key == ConsoleKey.W)
  1052.                 {
  1053.                     MovePlayerUp();
  1054.                 }
  1055.  
  1056.                 if (keyInfo.Key == ConsoleKey.DownArrow || keyInfo.Key == ConsoleKey.S)
  1057.                 {
  1058.                     MovePlayerDown();
  1059.                 }
  1060.                 if (keyInfo.Key == ConsoleKey.Escape)
  1061.                 {
  1062.                     Console.CursorVisible = true;
  1063.                     OperatingSystem();
  1064.                 }
  1065.             }
  1066.         }
  1067.  
  1068.         private static void BotMove()
  1069.         {
  1070.             int randomNumber = randomGenerator.Next(1, 100);
  1071.  
  1072.             if (randomNumber < botLvlHard)
  1073.             {
  1074.  
  1075.                 if (ballDirectionUp == true)
  1076.                 {
  1077.                     MoveBotUp();
  1078.                 }
  1079.                 else
  1080.                 {
  1081.                     MoveBotDown();
  1082.                 }
  1083.             }
  1084.         }
  1085.  
  1086.         private static void MoveBall()
  1087.         {
  1088.             if (ballPosY == 5)
  1089.             {
  1090.                 ballDirectionUp = false;
  1091.             }
  1092.  
  1093.             if (ballPosY == 22)
  1094.             {
  1095.                 ballDirectionUp = true;
  1096.             }
  1097.  
  1098.             if (ballPosX == 110)
  1099.             {
  1100.                 ResetBall();
  1101.                 ballDirectionUp = false;
  1102.                 ballDirectionRight = false;
  1103.                 playerResult++;
  1104.             }
  1105.  
  1106.             if (ballPosX == 8)
  1107.             {
  1108.                 ResetBall();
  1109.                 ballDirectionUp = true;
  1110.                 ballDirectionRight = true;
  1111.                 botResult++;
  1112.             }
  1113.  
  1114.             if (ballPosX < 11)
  1115.             {
  1116.                 if (ballPosY >= playerPos && ballPosY < playerPos + playerpadSize)
  1117.                 {
  1118.                     ballDirectionRight = true;
  1119.                 }
  1120.             }
  1121.  
  1122.             if (ballPosX >= 108)
  1123.             {
  1124.                 if (ballPosY >= botPos && ballPosY < botPos + botpadSize)
  1125.                 {
  1126.                     ballDirectionRight = false;
  1127.                 }
  1128.             }
  1129.  
  1130.             if (ballDirectionUp)
  1131.             {
  1132.                 ballPosY--;
  1133.             }
  1134.             else
  1135.             {
  1136.                 ballPosY++;
  1137.             }
  1138.  
  1139.             if (ballDirectionRight)
  1140.             {
  1141.                 ballPosX++;
  1142.             }
  1143.             else
  1144.             {
  1145.                 ballPosX--;
  1146.             }
  1147.         }
  1148.     }
  1149. }
Advertisement
Add Comment
Please, Sign In to add comment